finalized for productive deployment

This commit is contained in:
Jottyfan
2023-03-22 22:37:34 +01:00
parent 45943b415b
commit 437b9cbd43
31 changed files with 248 additions and 380 deletions

View File

@@ -38,7 +38,6 @@ public class AdminController extends CommonController {
@GetMapping("/admin/mail")
public String getMail(Model model, HttpServletRequest request) {
super.setupSession(model, request);
MailBean mailBean = new MailBean();
mailBean.setFrom(from);
mailBean.getTo().add(getCurrentEmail(request));
@@ -49,7 +48,6 @@ public class AdminController extends CommonController {
@PostMapping("/admin/mail/send")
public String sendMail(@Valid @ModelAttribute("bean") MailBean bean, final BindingResult bindingResult, Model model,
HttpServletRequest request) {
super.setupSession(model, request);
if (bindingResult.hasErrors()) {
for (ObjectError error : bindingResult.getAllErrors())
LOGGER.error("error {}: {}", error.getCode(), error.getDefaultMessage());
@@ -61,29 +59,25 @@ public class AdminController extends CommonController {
@GetMapping("/admin/document")
public String getDocuments(Model model, HttpServletRequest request) {
super.setupSession(model, request);
model.addAttribute("documents", service.getAllDocuments());
return "/admin/document";
}
@GetMapping("/admin/document/add")
public String prepareAddDocument(Model model, HttpServletRequest request) {
super.setupSession(model, request);
model.addAttribute("bean", new DocumentBean());
return "/admin/document_edit";
}
@GetMapping("/admin/document/edit/{id}")
public String prepareAddDocument(@PathVariable Integer id, Model model, HttpServletRequest request) {
super.setupSession(model, request);
model.addAttribute("bean", service.getDocument(id));
return "/admin/document_edit";
}
@PostMapping("/admin/document/update")
public String updateDocument(@Valid @ModelAttribute("bean") DocumentBean bean,
final BindingResult bindingResult, Model model, HttpServletRequest request) {
super.setupSession(model, request);
public String updateDocument(@Valid @ModelAttribute("bean") DocumentBean bean, final BindingResult bindingResult,
Model model, HttpServletRequest request) {
if (bindingResult.hasErrors()) {
for (ObjectError error : bindingResult.getAllErrors())
LOGGER.error("error {}: {}", error.getCode(), error.getDefaultMessage());
@@ -95,21 +89,18 @@ public class AdminController extends CommonController {
@GetMapping("/admin/document/delete/{id}")
public String deleteDocument(@PathVariable Integer id, Model model, HttpServletRequest request) {
super.setupSession(model, request);
service.deleteDocument(id);
return "redirect:/admin/document";
}
@GetMapping("/admin/location")
public String getLocations(Model model, HttpServletRequest request) {
super.setupSession(model, request);
model.addAttribute("locations", service.getLocations());
return "/admin/location";
}
@GetMapping("/admin/location/add")
public String prepareAddLocation(Model model, HttpServletRequest request) {
super.setupSession(model, request);
model.addAttribute("bean", new LocationBean());
model.addAttribute("documents", service.getLocationDocuments());
return "/admin/location_edit";
@@ -117,16 +108,14 @@ public class AdminController extends CommonController {
@GetMapping("/admin/location/edit/{id}")
public String prepareAddLocation(@PathVariable Integer id, Model model, HttpServletRequest request) {
super.setupSession(model, request);
model.addAttribute("bean", service.getLocation(id));
model.addAttribute("documents", service.getLocationDocuments());
return "/admin/location_edit";
}
@PostMapping("/admin/location/update")
public String updateDocument(@Valid @ModelAttribute("bean") LocationBean bean,
final BindingResult bindingResult, Model model, HttpServletRequest request) {
super.setupSession(model, request);
public String updateDocument(@Valid @ModelAttribute("bean") LocationBean bean, final BindingResult bindingResult,
Model model, HttpServletRequest request) {
if (bindingResult.hasErrors()) {
for (ObjectError error : bindingResult.getAllErrors()) {
LOGGER.error("error {}: {}", error.getCode(), error.getDefaultMessage());
@@ -140,14 +129,12 @@ public class AdminController extends CommonController {
@GetMapping("/admin/location/delete/{id}")
public String deleteLocation(@PathVariable Integer id, Model model, HttpServletRequest request) {
super.setupSession(model, request);
service.deleteLocation(id);
return "redirect:/admin/location";
}
@GetMapping("/admin/camp")
public String getCamplist(Model model, HttpServletRequest request) {
super.setupSession(model, request);
model.addAttribute("camps", service.getAllCamps());
model.addAttribute("locations", service.getLocations());
return "/admin/camp";
@@ -155,7 +142,6 @@ public class AdminController extends CommonController {
@GetMapping("/admin/camp/add")
public String prepareAddCamp(Model model, HttpServletRequest request) {
super.setupSession(model, request);
model.addAttribute("bean", new CampBean());
model.addAttribute("documents", service.getCampDocuments());
model.addAttribute("locations", service.getLocations());
@@ -165,7 +151,6 @@ public class AdminController extends CommonController {
@GetMapping("/admin/camp/edit/{id}")
public String prepareEditCamp(@PathVariable Integer id, Model model, HttpServletRequest request) {
super.setupSession(model, request);
model.addAttribute("bean", service.getCamp(id));
model.addAttribute("documents", service.getCampDocuments());
model.addAttribute("locations", service.getLocations());
@@ -178,9 +163,8 @@ public class AdminController extends CommonController {
}
@PostMapping("/admin/camp/update")
public String updateDocument(@Valid @ModelAttribute("bean") CampBean bean,
final BindingResult bindingResult, Model model, HttpServletRequest request, RedirectAttributes redirect) {
super.setupSession(model, request);
public String updateDocument(@Valid @ModelAttribute("bean") CampBean bean, final BindingResult bindingResult,
Model model, HttpServletRequest request, RedirectAttributes redirect) {
if (bindingResult.hasErrors()) {
for (ObjectError error : bindingResult.getAllErrors()) {
LOGGER.error("error {}: {}", error.getCode(), error.getDefaultMessage());
@@ -198,8 +182,8 @@ public class AdminController extends CommonController {
}
@GetMapping("/admin/camp/delete/{id}")
public String deleteCamp(@PathVariable Integer id, Model model, HttpServletRequest request, RedirectAttributes redirect) {
super.setupSession(model, request);
public String deleteCamp(@PathVariable Integer id, Model model, HttpServletRequest request,
RedirectAttributes redirect) {
String error = service.deleteCamp(id);
redirect.addAttribute("error", error);
return error != null ? "redirect:/admin/camp/edit/" + id : "redirect:/admin/camp";

View File

@@ -1,7 +1,6 @@
package de.jottyfan.camporganizer.module.business.bookings;
import javax.annotation.security.RolesAllowed;
import javax.servlet.http.HttpServletRequest;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -16,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import de.jottyfan.camporganizer.module.business.bookings.impl.AddPaymentBean;
import de.jottyfan.camporganizer.module.business.bookings.impl.BookerBean;
import de.jottyfan.camporganizer.module.business.business.IBusinessService;
import de.jottyfan.camporganizer.module.camplist.CommonController;
/**
*
@@ -24,24 +23,16 @@ import de.jottyfan.camporganizer.module.business.business.IBusinessService;
*
*/
@Controller
public class BookingsController {
public class BookingsController extends CommonController {
private static final Logger LOGGER = LogManager.getLogger(BookingsController.class);
@Autowired
private HttpServletRequest request;
@Autowired
private IBusinessService indexService;
@Autowired
private IBookingsService bookingsService;
@GetMapping("/business/bookings")
@RolesAllowed({"business_booking"})
public String getBookings(Model model) {
String username = indexService.getCurrentUser(request);
model.addAttribute("currentUser", username);
model.addAttribute("bookers", bookingsService.getBookers(username));
model.addAttribute("bookers", bookingsService.getBookers(getCurrentUser()));
model.addAttribute("addBean", new AddPaymentBean());
return "business/bookings";
}
@@ -49,9 +40,7 @@ public class BookingsController {
@GetMapping("/business/bookings/{id}")
@RolesAllowed({"business_booking"})
public String getBooking(Model model, @PathVariable Integer id) {
String username = indexService.getCurrentUser(request);
model.addAttribute("currentUser", username);
BookerBean bean = bookingsService.getBooker(id, username);
BookerBean bean = bookingsService.getBooker(id, getCurrentUser());
model.addAttribute("booker", bean);
model.addAttribute("addBean", new AddPaymentBean());
return bean == null ? getBookings(model) : "business/booker";

View File

@@ -7,13 +7,15 @@ import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import de.jottyfan.camporganizer.module.camplist.CommonController;
/**
*
* @author jotty
*
*/
@Controller
public class BusinessController {
public class BusinessController extends CommonController {
@Autowired
private HttpServletRequest request;

View File

@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import de.jottyfan.camporganizer.module.business.business.IBusinessService;
import de.jottyfan.camporganizer.module.camplist.CommonController;
/**
*
@@ -17,7 +18,7 @@ import de.jottyfan.camporganizer.module.business.business.IBusinessService;
*
*/
@Controller
public class CampController {
public class CampController extends CommonController {
@Autowired
private HttpServletRequest request;

View File

@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import de.jottyfan.camporganizer.module.business.business.IBusinessService;
import de.jottyfan.camporganizer.module.business.privileges.impl.PrivilegesBean;
import de.jottyfan.camporganizer.module.camplist.CommonController;
/**
*
@@ -20,7 +21,7 @@ import de.jottyfan.camporganizer.module.business.privileges.impl.PrivilegesBean;
*
*/
@Controller
public class PrivilegesController {
public class PrivilegesController extends CommonController {
@Autowired
private HttpServletRequest request;

View File

@@ -34,14 +34,12 @@ public class CamplistController extends CommonController {
@GetMapping("/camplist")
public String index(Model model) {
super.setupSession(model, request);
model.addAttribute("camps", service.getAllCamps(true));
return super.isLoggedIn(request) ? dashboard(model) : "/camplist";
}
@GetMapping("/dashboard")
public String dashboard(Model model) {
super.setupSession(model, request);
model.addAttribute("mybookings", service.getBookingsOf(super.getCurrentUser(request)));
model.addAttribute("bookingBean", new BookingBean());
model.addAttribute("keycloakProfileUrl", keycloak.getUserClientUrl());

View File

@@ -93,7 +93,7 @@ public class CamplistGateway {
.leftJoin(V_CAMP).on(V_CAMP.PK.eq(T_PERSON.FK_CAMP))
.where(T_PROFILE.USERNAME.eq(username))
.and(T_PERSON.PK.isNotNull())
.orderBy(V_CAMP.ARRIVE, T_PERSON.CREATED);
.orderBy(V_CAMP.ARRIVE.desc(), T_PERSON.CREATED);
// @formatter:on
LOGGER.debug(sql.toString());
List<BookingBean> list = new ArrayList<>();

View File

@@ -3,7 +3,8 @@ package de.jottyfan.camporganizer.module.camplist;
import javax.servlet.http.HttpServletRequest;
import org.keycloak.KeycloakSecurityContext;
import org.springframework.ui.Model;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
/**
*
@@ -12,6 +13,9 @@ import org.springframework.ui.Model;
*/
public abstract class CommonController {
@Autowired
private HttpServletRequest request;
/**
* try to get current keycloak user
*
@@ -36,15 +40,9 @@ public abstract class CommonController {
return ksc == null ? null : ksc.getIdToken().getEmail();
}
/**
* setup the session for the template
*
* @param model the model
* @param request the request
*/
public void setupSession(Model model, HttpServletRequest request) {
String username = getCurrentUser(request);
model.addAttribute("currentUser", username);
@ModelAttribute("currentUser")
public String getCurrentUser() {
return getCurrentUser(request);
}
/**

View File

@@ -10,6 +10,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import de.jottyfan.camporganizer.module.camplist.CommonController;
import de.jottyfan.camporganizer.module.confirmation.confirmation.impl.CampOverviewBean;
/**
@@ -18,7 +19,7 @@ import de.jottyfan.camporganizer.module.confirmation.confirmation.impl.CampOverv
*
*/
@Controller
public class ConfirmationController {
public class ConfirmationController extends CommonController {
@Autowired
private HttpServletRequest request;
@@ -28,7 +29,6 @@ public class ConfirmationController {
@GetMapping("/confirmation")
public String getIndex(Model model) {
String username = indexService.getCurrentUser(request);
List<CampOverviewBean> campoverview = indexService.getCampOverview(request);
CampOverviewBean campoverviewsummary = new CampOverviewBean(LocalDate.now(), "summary");
for (CampOverviewBean bean : campoverview) {
@@ -36,7 +36,6 @@ public class ConfirmationController {
campoverviewsummary.setRejected(bean.getRejected() + campoverviewsummary.getRejected());
campoverviewsummary.setUntouched(bean.getUntouched() + campoverviewsummary.getUntouched());
}
model.addAttribute("currentUser", username);
model.addAttribute("campoverview", campoverview);
model.addAttribute("campoverviewsummary", campoverviewsummary);
model.addAttribute("untouched", indexService.getUntouched(request));

View File

@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import de.jottyfan.camporganizer.module.camplist.CommonController;
import de.jottyfan.camporganizer.module.confirmation.confirmation.IConfirmationService;
import de.jottyfan.camporganizer.module.confirmation.person.impl.PersonBean;
@@ -19,7 +20,7 @@ import de.jottyfan.camporganizer.module.confirmation.person.impl.PersonBean;
*
*/
@Controller
public class PersonController {
public class PersonController extends CommonController {
@Autowired
private HttpServletRequest request;

View File

@@ -15,13 +15,15 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import de.jottyfan.camporganizer.module.camplist.CommonController;
/**
*
* @author jotty
*
*/
@RestController
public class DocumentController {
public class DocumentController extends CommonController {
@Autowired
private DocumentService service;

View File

@@ -8,13 +8,15 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import de.jottyfan.camporganizer.module.camplist.CommonController;
/**
*
* @author jotty
*
*/
@Controller
public class ICalController {
public class ICalController extends CommonController {
@Autowired
private IICalService service;

View File

@@ -11,13 +11,15 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import de.jottyfan.camporganizer.module.camplist.CommonController;
/**
*
* @author jotty
*
*/
@Controller
public class MigrationController {
public class MigrationController extends CommonController {
@Autowired
private MigrationService service;

View File

@@ -1,6 +1,5 @@
package de.jottyfan.camporganizer.module.registration;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
@@ -22,15 +21,11 @@ import de.jottyfan.camporganizer.module.camplist.CommonController;
@Controller
public class RegistrationController extends CommonController {
@Autowired
private HttpServletRequest request;
@Autowired
private RegistrationService service;
@GetMapping("/registration/{fkCamp}")
public String index(@PathVariable(name = "fkCamp", required = true) Integer fkCamp, Model model) {
super.setupSession(model, request);
if (service.campIsNotYetOver(fkCamp)) {
CampBean campBean = service.getCamp(fkCamp);
model.addAttribute("camp", campBean);
@@ -45,8 +40,8 @@ public class RegistrationController extends CommonController {
}
@PostMapping("/registration/register")
public String register(@Valid @ModelAttribute("bean") RegistrationBean bean, final BindingResult bindingResult, Model model) {
super.setupSession(model, request);
public String register(@Valid @ModelAttribute("bean") RegistrationBean bean, final BindingResult bindingResult,
Model model) {
if (bindingResult.hasErrors()) {
CampBean campBean = service.getCamp(bean.getFkCamp());
model.addAttribute("camp", campBean);
@@ -58,21 +53,18 @@ public class RegistrationController extends CommonController {
@GetMapping("/registration/cancel/{id}")
public String cancellation(@PathVariable Integer id, final Model model) {
super.setupSession(model, request);
model.addAttribute("bean", service.getBooking(id));
return "/registration/cancellation";
}
@GetMapping("/registration/remove/{id}")
public String remove(@PathVariable Integer id, final Model model) {
super.setupSession(model, request);
service.removeBooking(id);
return "redirect:/dashboard";
}
@GetMapping("/registration/toggleconsent/{id}")
public String toggleConsent(@PathVariable Integer id, final Model model) {
super.setupSession(model, request);
service.toggleConsent(id);
return "redirect:/dashboard";
}

View File

@@ -7,13 +7,15 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import de.jottyfan.camporganizer.module.camplist.CommonController;
/**
*
* @author jotty
*
*/
@Controller
public class RssController {
public class RssController extends CommonController {
@Autowired
private RssService service;

View File

@@ -1,23 +0,0 @@
package de.jottyfan.camporganizer.module.staticpages;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
/**
*
* @author jotty
*
*/
@Controller
public class AllgemeinesController {
/**
* load the allgemeines page
*
* @return the allgemeines page
*/
@GetMapping("/allgemeines")
public String getAllgemeines() {
return "/allgemeines";
}
}

View File

@@ -1,23 +0,0 @@
package de.jottyfan.camporganizer.module.staticpages;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
/**
*
* @author jotty
*
*/
@Controller
public class DatenschutzController {
/**
* load the datenschutz page
*
* @return the datenschutz page
*/
@GetMapping("/datenschutz")
public String getDatenschutz() {
return "/datenschutz";
}
}

View File

@@ -1,23 +0,0 @@
package de.jottyfan.camporganizer.module.staticpages;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
/**
*
* @author jotty
*
*/
@Controller
public class ImpressumController {
/**
* load the impressum page
*
* @return the impresum page
*/
@GetMapping("/impressum")
public String getImpressum() {
return "/impressum";
}
}

View File

@@ -1,18 +0,0 @@
package de.jottyfan.camporganizer.module.staticpages;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
/**
*
* @author jotty
*
*/
@Controller
public class IndexController {
@GetMapping("/")
public String getIndex() {
return "/index";
}
}

View File

@@ -1,23 +0,0 @@
package de.jottyfan.camporganizer.module.staticpages;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
/**
*
* @author jotty
*
*/
@Controller
public class KontaktController {
/**
* load the kontakt page
*
* @return the kontakt page
*/
@GetMapping("/kontakt")
public String getKontakt() {
return "/kontakt";
}
}

View File

@@ -1,24 +0,0 @@
package de.jottyfan.camporganizer.module.staticpages;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
/**
*
* @author jotty
*
*/
@Controller
public class ReportsController {
/**
* load the sub page
*
* @return the sub page
*/
@GetMapping("/reports/{subpage}")
public String getSubpage(@PathVariable("subpage") String subpage) {
return "/reports/" + subpage;
}
}

View File

@@ -0,0 +1,87 @@
package de.jottyfan.camporganizer.module.staticpages;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import de.jottyfan.camporganizer.module.camplist.CommonController;
/**
*
* @author jotty
*
*/
@Controller
public class StaticPagesController extends CommonController {
/**
* load the index page
*
* @return the index page
*/
@GetMapping("/")
public String getIndex() {
return "/index";
}
/**
* load the sub page
*
* @return the sub page
*/
@GetMapping("/reports/{subpage}")
public String getSubpage(@PathVariable("subpage") String subpage) {
return "/reports/" + subpage;
}
/**
* load the verein page
*
* @return the verein page
*/
@GetMapping("/verein")
public String getVerein() {
return "/verein";
}
/**
* load the kontakt page
*
* @return the kontakt page
*/
@GetMapping("/kontakt")
public String getKontakt() {
return "/kontakt";
}
/**
* load the allgemeines page
*
* @return the allgemeines page
*/
@GetMapping("/allgemeines")
public String getAllgemeines() {
return "/allgemeines";
}
/**
* load the datenschutz page
*
* @return the datenschutz page
*/
@GetMapping("/datenschutz")
public String getDatenschutz() {
return "/datenschutz";
}
/**
* load the impressum page
*
* @return the impresum page
*/
@GetMapping("/impressum")
public String getImpressum() {
return "/impressum";
}
}

View File

@@ -1,23 +0,0 @@
package de.jottyfan.camporganizer.module.staticpages;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
/**
*
* @author jotty
*
*/
@Controller
public class VereinController {
/**
* load the verein page
*
* @return the verein page
*/
@GetMapping("/verein")
public String getVerein() {
return "/verein";
}
}