new voucher system + jdoc

This commit is contained in:
_Bastler 2021-10-06 15:25:13 +02:00
parent 456332f24e
commit 442bdb4996
234 changed files with 4793 additions and 2737 deletions

View File

@ -15,25 +15,23 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
/** /**
* * The Class Application.
* @author _bastler@bstly.de
*
*/ */
@SpringBootApplication @SpringBootApplication
@EnableScheduling @EnableScheduling
public class Application extends SpringBootServletInitializer { public class Application extends SpringBootServletInitializer {
/** /**
* @param args * The main method.
*
* @param args the arguments
*/ */
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(Application.class, args); SpringApplication.run(Application.class, args);
} }
/* /*
* * @see org.springframework.boot.web.servlet.support.SpringBootServletInitializer#onStartup(javax.servlet.ServletContext)
* @see
* org.springframework.boot.web.servlet.support.SpringBootServletInitializer#
* onStartup(javax.servlet.ServletContext)
*/ */
@Override @Override
public void onStartup(ServletContext servletContext) throws ServletException { public void onStartup(ServletContext servletContext) throws ServletException {

View File

@ -12,9 +12,7 @@ import org.springframework.context.annotation.Configuration;
import com.querydsl.jpa.impl.JPAQueryFactory; import com.querydsl.jpa.impl.JPAQueryFactory;
/** /**
* * The Class CoreConfiguration.
* @author _bastler@bstly.de
*
*/ */
@Configuration @Configuration
public class CoreConfiguration { public class CoreConfiguration {
@ -22,6 +20,11 @@ public class CoreConfiguration {
@Autowired @Autowired
private EntityManager em; private EntityManager em;
/**
* Jpa query factory.
*
* @return the JPA query factory
*/
@Bean @Bean
public JPAQueryFactory jpaQueryFactory() { public JPAQueryFactory jpaQueryFactory() {
return new JPAQueryFactory(em); return new JPAQueryFactory(em);

View File

@ -25,9 +25,7 @@ import de.bstly.we.model.UserData;
import de.bstly.we.repository.PermissionRepository; import de.bstly.we.repository.PermissionRepository;
/** /**
* * The Class PermissionManager.
* @author _bastler@bstly.de
*
*/ */
@Component @Component
public class PermissionManager implements UserDataProvider { public class PermissionManager implements UserDataProvider {
@ -41,10 +39,11 @@ public class PermissionManager implements UserDataProvider {
DateTimeFormatter pretixOffsetDateTime = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssx"); DateTimeFormatter pretixOffsetDateTime = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssx");
/** /**
* Gets the.
* *
* @param target * @param target the target
* @param name * @param name the name
* @return * @return the list
*/ */
public List<Permission> get(Long target, String name) { public List<Permission> get(Long target, String name) {
if (target != null) { if (target != null) {
@ -55,9 +54,10 @@ public class PermissionManager implements UserDataProvider {
} }
/** /**
* Gets the all by target.
* *
* @param target * @param target the target
* @return * @return the all by target
*/ */
public List<Permission> getAllByTarget(Long target) { public List<Permission> getAllByTarget(Long target) {
if (target != null) { if (target != null) {
@ -67,9 +67,10 @@ public class PermissionManager implements UserDataProvider {
} }
/** /**
* Gets the not expires by target.
* *
* @param target * @param target the target
* @return * @return the not expires by target
*/ */
public List<Permission> getNotExpiresByTarget(Long target) { public List<Permission> getNotExpiresByTarget(Long target) {
if (target != null) { if (target != null) {
@ -81,9 +82,10 @@ public class PermissionManager implements UserDataProvider {
} }
/** /**
* Gets the not expires by name.
* *
* @param name * @param name the name
* @return * @return the not expires by name
*/ */
public List<Permission> getNotExpiresByName(String name) { public List<Permission> getNotExpiresByName(String name) {
if (name != null) { if (name != null) {
@ -95,9 +97,10 @@ public class PermissionManager implements UserDataProvider {
} }
/** /**
* Gets the not expires by target ignore start.
* *
* @param target * @param target the target
* @return * @return the not expires by target ignore start
*/ */
public List<Permission> getNotExpiresByTargetIgnoreStart(Long target) { public List<Permission> getNotExpiresByTargetIgnoreStart(Long target) {
if (target != null) { if (target != null) {
@ -108,9 +111,10 @@ public class PermissionManager implements UserDataProvider {
} }
/** /**
* Checks if is full user.
* *
* @param target * @param target the target
* @return * @return true, if is full user
*/ */
public boolean isFullUser(Long target) { public boolean isFullUser(Long target) {
return permissionRepository.exists(qPermission.target.eq(target) return permissionRepository.exists(qPermission.target.eq(target)
@ -119,10 +123,11 @@ public class PermissionManager implements UserDataProvider {
} }
/** /**
* Checks for permission.
* *
* @param target * @param target the target
* @param name * @param name the name
* @return * @return true, if successful
*/ */
public boolean hasPermission(Long target, String name) { public boolean hasPermission(Long target, String name) {
if (!Permissions.ROLE_ADMIN.equals(name) && hasPermission(target, Permissions.ROLE_ADMIN)) { if (!Permissions.ROLE_ADMIN.equals(name) && hasPermission(target, Permissions.ROLE_ADMIN)) {
@ -136,12 +141,14 @@ public class PermissionManager implements UserDataProvider {
} }
/** /**
* Creates the.
* *
* @param target * @param target the target
* @param name * @param name the name
* @param addon * @param addon the addon
* @param expires * @param starts the starts
* @return * @param expires the expires
* @return the permission
*/ */
public Permission create(Long target, String name, boolean addon, Instant starts, public Permission create(Long target, String name, boolean addon, Instant starts,
Instant expires) { Instant expires) {
@ -156,9 +163,10 @@ public class PermissionManager implements UserDataProvider {
} }
/** /**
* Update.
* *
* @param permission * @param permission the permission
* @return * @return the permission
*/ */
public Permission update(Permission permission) { public Permission update(Permission permission) {
Assert.isTrue( Assert.isTrue(
@ -175,10 +183,11 @@ public class PermissionManager implements UserDataProvider {
} }
/** /**
* Clone.
* *
* @param name * @param name the name
* @param clone * @param clone the clone
* @return * @return the list
*/ */
public List<Permission> clone(String name, String clone) { public List<Permission> clone(String name, String clone) {
List<Permission> permissions = Lists.newArrayList(); List<Permission> permissions = Lists.newArrayList();
@ -197,9 +206,10 @@ public class PermissionManager implements UserDataProvider {
} }
/** /**
* Delete.
* *
* @param target * @param target the target
* @param name * @param name the name
*/ */
public void delete(Long target, String name) { public void delete(Long target, String name) {
Assert.isTrue( Assert.isTrue(
@ -212,26 +222,30 @@ public class PermissionManager implements UserDataProvider {
} }
/** /**
* Delete all.
* *
* @param target * @param target the target
*/ */
public void deleteAll(Long target) { public void deleteAll(Long target) {
permissionRepository.deleteAll(permissionRepository.findAll(qPermission.target.eq(target))); permissionRepository.deleteAll(permissionRepository.findAll(qPermission.target.eq(target)));
} }
/** /**
* Delete all.
* *
* @param name * @param name the name
*/ */
public void deleteAll(String name) { public void deleteAll(String name) {
permissionRepository.deleteAll(permissionRepository.findAll(qPermission.name.eq(name))); permissionRepository.deleteAll(permissionRepository.findAll(qPermission.name.eq(name)));
} }
/** /**
* Apply item.
* *
* @param target * @param target the target
* @param item * @param item the item
* @param answers * @param answers the answers
* @param start the start
*/ */
public void applyItem(Long target, Integer item, JsonArray answers, Instant start) { public void applyItem(Long target, Integer item, JsonArray answers, Instant start) {
for (Permission permission : getForItem(target, item, answers, start)) { for (Permission permission : getForItem(target, item, answers, start)) {
@ -240,11 +254,13 @@ public class PermissionManager implements UserDataProvider {
} }
/** /**
* Gets the for item.
* *
* @param target * @param target the target
* @param item * @param item the item
* @param answers * @param answers the answers
* @return * @param start the start
* @return the for item
*/ */
public List<Permission> getForItem(Long target, Integer item, JsonArray answers, public List<Permission> getForItem(Long target, Integer item, JsonArray answers,
Instant start) { Instant start) {

View File

@ -21,9 +21,7 @@ import de.bstly.we.model.QPermissionMapping;
import de.bstly.we.repository.PermissionMappingRepository; import de.bstly.we.repository.PermissionMappingRepository;
/** /**
* * The Class PermissionMappingManager.
* @author _bastler@bstly.de
*
*/ */
@Component @Component
public class PermissionMappingManager { public class PermissionMappingManager {
@ -33,9 +31,10 @@ public class PermissionMappingManager {
private QPermissionMapping qPermissionMapping = QPermissionMapping.permissionMapping; private QPermissionMapping qPermissionMapping = QPermissionMapping.permissionMapping;
/** /**
* Gets the all by item.
* *
* @param item * @param item the item
* @return * @return the all by item
*/ */
public List<PermissionMapping> getAllByItem(Integer item) { public List<PermissionMapping> getAllByItem(Integer item) {
return Lists.newArrayList( return Lists.newArrayList(
@ -43,9 +42,10 @@ public class PermissionMappingManager {
} }
/** /**
* Gets the all by name.
* *
* @param name * @param name the name
* @return * @return the all by name
*/ */
public List<PermissionMapping> getAllByName(String name) { public List<PermissionMapping> getAllByName(String name) {
return Lists.newArrayList( return Lists.newArrayList(
@ -53,19 +53,21 @@ public class PermissionMappingManager {
} }
/** /**
* Exists.
* *
* @param item * @param item the item
* @return * @return true, if successful
*/ */
public boolean exists(Integer item) { public boolean exists(Integer item) {
return permissionMappingRepository.exists(qPermissionMapping.item.eq(item)); return permissionMappingRepository.exists(qPermissionMapping.item.eq(item));
} }
/** /**
* Exists.
* *
* @param item * @param item the item
* @param name * @param name the name
* @return * @return true, if successful
*/ */
public boolean exists(Integer item, String name) { public boolean exists(Integer item, String name) {
return permissionMappingRepository.exists( return permissionMappingRepository.exists(
@ -73,14 +75,18 @@ public class PermissionMappingManager {
} }
/** /**
* Creates the.
* *
* @param item * @param item the item
* @param names * @param names the names
* @param lifetime * @param lifetime the lifetime
* @param lifetimeUnit * @param lifetimeUnit the lifetime unit
* @param addon * @param lifetimeRound the lifetime round
* @param product * @param addon the addon
* @return * @param product the product
* @param startsQuestion the starts question
* @param expiresQuestion the expires question
* @return the permission mapping
*/ */
public PermissionMapping create(Integer item, Set<String> names, Long lifetime, public PermissionMapping create(Integer item, Set<String> names, Long lifetime,
ChronoUnit lifetimeUnit, boolean lifetimeRound, boolean addon, String product, ChronoUnit lifetimeUnit, boolean lifetimeRound, boolean addon, String product,
@ -103,18 +109,19 @@ public class PermissionMappingManager {
} }
/** /**
* Update.
* *
* @param permissionMapping * @param permissionMapping the permission mapping
* @return * @return the permission mapping
*/ */
public PermissionMapping update(PermissionMapping permissionMapping) { public PermissionMapping update(PermissionMapping permissionMapping) {
return permissionMappingRepository.save(permissionMapping); return permissionMappingRepository.save(permissionMapping);
} }
/** /**
* Delete.
* *
* @param item * @param id the id
* @param name
*/ */
public void delete(Long id) { public void delete(Long id) {
Assert.isTrue(permissionMappingRepository.existsById(id), Assert.isTrue(permissionMappingRepository.existsById(id),
@ -124,12 +131,13 @@ public class PermissionMappingManager {
} }
/** /**
* Gets the.
* *
* @param page * @param page the page
* @param size * @param size the size
* @param sortBy * @param sortBy the sort by
* @param descending * @param descending the descending
* @return * @return the page
*/ */
public Page<PermissionMapping> get(int page, int size, String sortBy, boolean descending) { public Page<PermissionMapping> get(int page, int size, String sortBy, boolean descending) {
Sort sort = descending ? Sort.by(sortBy).descending() : Sort.by(sortBy).ascending(); Sort sort = descending ? Sort.by(sortBy).descending() : Sort.by(sortBy).ascending();

View File

@ -4,8 +4,7 @@
package de.bstly.we.businesslogic; package de.bstly.we.businesslogic;
/** /**
* @author _bastler@bstly.de * The Interface Permissions.
*
*/ */
public interface Permissions { public interface Permissions {

View File

@ -4,8 +4,7 @@
package de.bstly.we.businesslogic; package de.bstly.we.businesslogic;
/** /**
* @author _bastler@bstly.de * The Enum PretixItemStatus.
*
*/ */
public enum PretixItemStatus { public enum PretixItemStatus {
ERROR, NOT_FOUND, PENDING, PAID, EXPIRED, CANCELED, REDEEMED ERROR, NOT_FOUND, PENDING, PAID, EXPIRED, CANCELED, REDEEMED

View File

@ -26,9 +26,7 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
/** /**
* * The Class PretixManager.
* @author _bastler@bstly.de
*
*/ */
@Component @Component
public class PretixManager implements SmartInitializingSingleton { public class PretixManager implements SmartInitializingSingleton {
@ -77,6 +75,9 @@ public class PretixManager implements SmartInitializingSingleton {
public static final String SYSTEM_PROPERTY_PRETIX_ORDER_TESTMODE = "pretix.order.testmode"; public static final String SYSTEM_PROPERTY_PRETIX_ORDER_TESTMODE = "pretix.order.testmode";
public static final String SYSTEM_PROPERTY_PRETIX_ORDER_SIMULATE = "pretix.order.simulate"; public static final String SYSTEM_PROPERTY_PRETIX_ORDER_SIMULATE = "pretix.order.simulate";
/**
* The Enum ITEM_STATUS.
*/
public enum ITEM_STATUS { public enum ITEM_STATUS {
ERROR, NOT_FOUND, PENDING, PAID, EXPIRED, CANCELED, REDEEMED ERROR, NOT_FOUND, PENDING, PAID, EXPIRED, CANCELED, REDEEMED
} }
@ -90,9 +91,9 @@ public class PretixManager implements SmartInitializingSingleton {
private int quotaAddons; private int quotaAddons;
protected WebClient webClient; protected WebClient webClient;
/* /*
* @see org.springframework.beans.factory.SmartInitializingSingleton# * @see org.springframework.beans.factory.SmartInitializingSingleton#afterSingletonsInstantiated()
* afterSingletonsInstantiated()
*/ */
@Override @Override
public void afterSingletonsInstantiated() { public void afterSingletonsInstantiated() {
@ -139,7 +140,7 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* * Builds the web client.
*/ */
public void buildWebClient() { public void buildWebClient() {
host = systemPropertyManager.get(SYSTEM_PROPERTY_PRETIX_HOST); host = systemPropertyManager.get(SYSTEM_PROPERTY_PRETIX_HOST);
@ -156,9 +157,10 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Gets the item status.
* *
* @param secret * @param secret the secret
* @return * @return the item status
*/ */
public ITEM_STATUS getItemStatus(String secret) { public ITEM_STATUS getItemStatus(String secret) {
try { try {
@ -189,9 +191,10 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Gets the check in item by secret.
* *
* @param secret * @param secret the secret
* @return * @return the check in item by secret
*/ */
public JsonObject getCheckInItemBySecret(String secret) { public JsonObject getCheckInItemBySecret(String secret) {
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>(); MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
@ -210,9 +213,10 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Gets the order.
* *
* @param code * @param code the code
* @return * @return the order
*/ */
public JsonObject getOrder(String code) { public JsonObject getOrder(String code) {
return request( return request(
@ -221,9 +225,10 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Gets the order by secret.
* *
* @param secret * @param secret the secret
* @return * @return the order by secret
*/ */
public JsonObject getOrderBySecret(String secret) { public JsonObject getOrderBySecret(String secret) {
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>(); MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
@ -245,9 +250,10 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Creates the order.
* *
* @param order * @param order the order
* @return * @return the json object
*/ */
public JsonObject createOrder(JsonObject order) { public JsonObject createOrder(JsonObject order) {
return request(String.format("/api/v1/organizers/%s/events/%s/orders/", organizer, event), return request(String.format("/api/v1/organizers/%s/events/%s/orders/", organizer, event),
@ -255,9 +261,11 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Extend order.
* *
* @param order * @param code the code
* @return * @param expire the expire
* @return the json object
*/ */
public JsonObject extendOrder(String code, JsonObject expire) { public JsonObject extendOrder(String code, JsonObject expire) {
return request(String.format("/api/v1/organizers/%s/events/%s/orders/%s/extend/", organizer, return request(String.format("/api/v1/organizers/%s/events/%s/orders/%s/extend/", organizer,
@ -265,8 +273,9 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Send email.
* *
* @param code * @param code the code
*/ */
public void sendEmail(String code) { public void sendEmail(String code) {
request(String.format("/api/v1/organizers/%s/events/%s/orders/%s/resend_link/", organizer, request(String.format("/api/v1/organizers/%s/events/%s/orders/%s/resend_link/", organizer,
@ -274,9 +283,10 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Gets the last payment date by secret.
* *
* @param secret * @param secret the secret
* @return * @return the last payment date by secret
*/ */
public Instant getLastPaymentDateBySecret(String secret) { public Instant getLastPaymentDateBySecret(String secret) {
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>(); MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
@ -296,9 +306,10 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Gets the last payment date for order.
* *
* @param secret * @param order the order
* @return * @return the last payment date for order
*/ */
public Instant getLastPaymentDateForOrder(String order) { public Instant getLastPaymentDateForOrder(String order) {
JsonArray paymentResults = request( JsonArray paymentResults = request(
@ -324,9 +335,10 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Gets the check in item by item.
* *
* @param secret * @param item the item
* @return * @return the check in item by item
*/ */
public JsonObject getCheckInItemByItem(Integer item) { public JsonObject getCheckInItemByItem(Integer item) {
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>(); MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
@ -345,9 +357,10 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Redeem item.
* *
* @param secret * @param secret the secret
* @return * @return the json object
*/ */
public JsonObject redeemItem(String secret) { public JsonObject redeemItem(String secret) {
if (getItemStatus(secret) == ITEM_STATUS.PAID) { if (getItemStatus(secret) == ITEM_STATUS.PAID) {
@ -358,9 +371,10 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Gets the check in positions.
* *
* @param idOrSecret * @param idOrSecret the id or secret
* @return * @return the check in positions
*/ */
public JsonObject getCheckInPositions(String idOrSecret) { public JsonObject getCheckInPositions(String idOrSecret) {
return request( return request(
@ -370,9 +384,10 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Redeem.
* *
* @param idOrSecret * @param idOrSecret the id or secret
* @return * @return the json object
*/ */
public JsonObject redeem(String idOrSecret) { public JsonObject redeem(String idOrSecret) {
return request(String.format( return request(String.format(
@ -381,25 +396,28 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Creates the registration voucher.
* *
* @return * @return the json object
*/ */
public JsonObject createRegistrationVoucher() { public JsonObject createRegistrationVoucher() {
return createVoucher(quotaRegistration); return createVoucher(quotaRegistration);
} }
/** /**
* Creates the add on voucher.
* *
* @return * @return the json object
*/ */
public JsonObject createAddOnVoucher() { public JsonObject createAddOnVoucher() {
return createVoucher(quotaAddons); return createVoucher(quotaAddons);
} }
/** /**
* Creates the voucher.
* *
* @param quotaId * @param quotaId the quota id
* @return * @return the json object
*/ */
public JsonObject createVoucher(int quotaId) { public JsonObject createVoucher(int quotaId) {
JsonObject voucher = new JsonObject(); JsonObject voucher = new JsonObject();
@ -411,9 +429,10 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Gets the item.
* *
* @param secret * @param item the item
* @return * @return the item
*/ */
public JsonObject getItem(Integer item) { public JsonObject getItem(Integer item) {
return request( return request(
@ -421,6 +440,12 @@ public class PretixManager implements SmartInitializingSingleton {
HttpMethod.GET).getAsJsonObject(); HttpMethod.GET).getAsJsonObject();
} }
/**
* Gets the variations.
*
* @param item the item
* @return the variations
*/
public JsonArray getVariations(Integer item) { public JsonArray getVariations(Integer item) {
return request(String.format("/api/v1/organizers/%s/events/%s/items/%s/variations/", return request(String.format("/api/v1/organizers/%s/events/%s/items/%s/variations/",
organizer, event, item), HttpMethod.GET).getAsJsonObject() organizer, event, item), HttpMethod.GET).getAsJsonObject()
@ -428,10 +453,11 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Update variation.
* *
* @param item * @param item the item
* @param variationId * @param variationId the variation id
* @param variation * @param variation the variation
*/ */
public void updateVariation(Integer item, Integer variationId, JsonObject variation) { public void updateVariation(Integer item, Integer variationId, JsonObject variation) {
request(String.format("/api/v1/organizers/%s/events/%s/items/%s/variations/%s/", organizer, request(String.format("/api/v1/organizers/%s/events/%s/items/%s/variations/%s/", organizer,
@ -439,9 +465,10 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Delete variation.
* *
* @param item * @param item the item
* @param variation * @param variation the variation
*/ */
public void deleteVariation(Integer item, Integer variation) { public void deleteVariation(Integer item, Integer variation) {
request(String.format("/api/v1/organizers/%s/events/%s/items/%s/variations/%s/", organizer, request(String.format("/api/v1/organizers/%s/events/%s/items/%s/variations/%s/", organizer,
@ -449,8 +476,9 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Delete variations.
* *
* @param item * @param item the item
*/ */
public void deleteVariations(Integer item) { public void deleteVariations(Integer item) {
for (JsonElement variationElement : getVariations(item)) { for (JsonElement variationElement : getVariations(item)) {
@ -460,21 +488,23 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Request.
* *
* @param path * @param path the path
* @param method * @param method the method
* @return * @return the json element
*/ */
public JsonElement request(String path, HttpMethod method) { public JsonElement request(String path, HttpMethod method) {
return request(path, method, null, new LinkedMultiValueMap<String, String>()); return request(path, method, null, new LinkedMultiValueMap<String, String>());
} }
/** /**
* Request.
* *
* @param path * @param path the path
* @param method * @param method the method
* @param queryParameters * @param queryParameters the query parameters
* @return * @return the json element
*/ */
public JsonElement request(String path, HttpMethod method, public JsonElement request(String path, HttpMethod method,
MultiValueMap<String, String> queryParameters) { MultiValueMap<String, String> queryParameters) {
@ -482,23 +512,25 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Request.
* *
* @param path * @param path the path
* @param method * @param method the method
* @param queryParameters * @param payload the payload
* @return * @return the json element
*/ */
public JsonElement request(String path, HttpMethod method, JsonElement payload) { public JsonElement request(String path, HttpMethod method, JsonElement payload) {
return request(path, method, payload, new LinkedMultiValueMap<String, String>()); return request(path, method, payload, new LinkedMultiValueMap<String, String>());
} }
/** /**
* Request.
* *
* @param path * @param path the path
* @param payload * @param method the method
* @param method * @param payload the payload
* @param queryParameters * @param queryParameters the query parameters
* @return * @return the json element
*/ */
public JsonElement request(String path, HttpMethod method, JsonElement payload, public JsonElement request(String path, HttpMethod method, JsonElement payload,
MultiValueMap<String, String> queryParameters) { MultiValueMap<String, String> queryParameters) {
@ -519,6 +551,8 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Gets the organizer.
*
* @return the organizer * @return the organizer
*/ */
public String getOrganizer() { public String getOrganizer() {
@ -526,6 +560,8 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Gets the event.
*
* @return the event * @return the event
*/ */
public String getEvent() { public String getEvent() {
@ -533,6 +569,8 @@ public class PretixManager implements SmartInitializingSingleton {
} }
/** /**
* Gets the checkinlist.
*
* @return the checkinlist * @return the checkinlist
*/ */
public String getCheckinlist() { public String getCheckinlist() {

View File

@ -18,9 +18,7 @@ import de.bstly.we.model.UserData;
import de.bstly.we.repository.QuotaRepository; import de.bstly.we.repository.QuotaRepository;
/** /**
* * The Class QuotaManager.
* @author _bastler@bstly.de
*
*/ */
@Component @Component
public class QuotaManager implements UserDataProvider { public class QuotaManager implements UserDataProvider {
@ -32,10 +30,11 @@ public class QuotaManager implements UserDataProvider {
private QQuota qQuota = QQuota.quota; private QQuota qQuota = QQuota.quota;
/** /**
* Gets the.
* *
* @param target * @param target the target
* @param name * @param name the name
* @return * @return the quota
*/ */
public Quota get(Long target, String name) { public Quota get(Long target, String name) {
if (target != null && name != null) { if (target != null && name != null) {
@ -46,18 +45,20 @@ public class QuotaManager implements UserDataProvider {
} }
/** /**
* Gets the all by name.
* *
* @param name * @param name the name
* @return * @return the all by name
*/ */
public List<Quota> getAllByName(String name) { public List<Quota> getAllByName(String name) {
return Lists.newArrayList(quotaRepository.findAll(qQuota.name.eq(name))); return Lists.newArrayList(quotaRepository.findAll(qQuota.name.eq(name)));
} }
/** /**
* Gets the all by target.
* *
* @param target * @param target the target
* @return * @return the all by target
*/ */
public List<Quota> getAllByTarget(Long target) { public List<Quota> getAllByTarget(Long target) {
if (target != null) { if (target != null) {
@ -67,9 +68,10 @@ public class QuotaManager implements UserDataProvider {
} }
/** /**
* Gets the not expires by target.
* *
* @param target * @param target the target
* @return * @return the not expires by target
*/ */
public List<Quota> getNotExpiresByTarget(Long target) { public List<Quota> getNotExpiresByTarget(Long target) {
if (target != null) { if (target != null) {
@ -80,10 +82,11 @@ public class QuotaManager implements UserDataProvider {
} }
/** /**
* Checks for quota.
* *
* @param target * @param target the target
* @param name * @param name the name
* @return * @return true, if successful
*/ */
public boolean hasQuota(Long target, String name) { public boolean hasQuota(Long target, String name) {
return target != null && quotaRepository return target != null && quotaRepository
@ -91,13 +94,14 @@ public class QuotaManager implements UserDataProvider {
} }
/** /**
* Creates the.
* *
* @param target * @param target the target
* @param name * @param name the name
* @param addon * @param value the value
* @param value * @param unit the unit
* @param unit * @param disposable the disposable
* @return * @return the quota
*/ */
public Quota create(Long target, String name, long value, String unit, boolean disposable) { public Quota create(Long target, String name, long value, String unit, boolean disposable) {
Quota newQuota = new Quota(); Quota newQuota = new Quota();
@ -111,9 +115,10 @@ public class QuotaManager implements UserDataProvider {
} }
/** /**
* Update.
* *
* @param quota * @param quota the quota
* @return * @return the quota
*/ */
public Quota update(Quota quota) { public Quota update(Quota quota) {
Assert.isTrue( Assert.isTrue(
@ -131,10 +136,12 @@ public class QuotaManager implements UserDataProvider {
} }
/** /**
* Clone.
* *
* @param name * @param name the name
* @param clone * @param clone the clone
* @return * @param value the value
* @return the list
*/ */
public List<Quota> clone(String name, String clone, long value) { public List<Quota> clone(String name, String clone, long value) {
List<Quota> quotas = Lists.newArrayList(); List<Quota> quotas = Lists.newArrayList();
@ -151,9 +158,10 @@ public class QuotaManager implements UserDataProvider {
} }
/** /**
* Delete.
* *
* @param target * @param target the target
* @param name * @param name the name
*/ */
public void delete(Long target, String name) { public void delete(Long target, String name) {
Assert.isTrue(quotaRepository.exists(qQuota.target.eq(target).and(qQuota.name.eq(name))), Assert.isTrue(quotaRepository.exists(qQuota.target.eq(target).and(qQuota.name.eq(name))),
@ -164,25 +172,28 @@ public class QuotaManager implements UserDataProvider {
} }
/** /**
* Delete all.
* *
* @param target * @param target the target
*/ */
public void deleteAll(Long target) { public void deleteAll(Long target) {
quotaRepository.deleteAll(quotaRepository.findAll(qQuota.target.eq(target))); quotaRepository.deleteAll(quotaRepository.findAll(qQuota.target.eq(target)));
} }
/** /**
* Delete all.
* *
* @param name * @param name the name
*/ */
public void deleteAll(String name) { public void deleteAll(String name) {
quotaRepository.deleteAll(quotaRepository.findAll(qQuota.name.eq(name))); quotaRepository.deleteAll(quotaRepository.findAll(qQuota.name.eq(name)));
} }
/** /**
* Apply item.
* *
* @param target * @param target the target
* @param item * @param item the item
*/ */
public void applyItem(Long target, Integer item) { public void applyItem(Long target, Integer item) {
for (QuotaMapping quotaMapping : quotaMappingManager.getAllByItem(item)) { for (QuotaMapping quotaMapping : quotaMappingManager.getAllByItem(item)) {

View File

@ -20,9 +20,7 @@ import de.bstly.we.model.QuotaMapping;
import de.bstly.we.repository.QuotaMappingRepository; import de.bstly.we.repository.QuotaMappingRepository;
/** /**
* * The Class QuotaMappingManager.
* @author _bastler@bstly.de
*
*/ */
@Component @Component
public class QuotaMappingManager { public class QuotaMappingManager {
@ -32,9 +30,10 @@ public class QuotaMappingManager {
private QQuotaMapping qQuotaMapping = QQuotaMapping.quotaMapping; private QQuotaMapping qQuotaMapping = QQuotaMapping.quotaMapping;
/** /**
* Gets the all by item.
* *
* @param item * @param item the item
* @return * @return the all by item
*/ */
public List<QuotaMapping> getAllByItem(Integer item) { public List<QuotaMapping> getAllByItem(Integer item) {
return Lists return Lists
@ -42,19 +41,21 @@ public class QuotaMappingManager {
} }
/** /**
* Exists.
* *
* @param item * @param item the item
* @return * @return true, if successful
*/ */
public boolean exists(Integer item) { public boolean exists(Integer item) {
return quotaMappingRepository.exists(qQuotaMapping.items.contains(item)); return quotaMappingRepository.exists(qQuotaMapping.items.contains(item));
} }
/** /**
* Exists.
* *
* @param item * @param item the item
* @param name * @param name the name
* @return * @return true, if successful
*/ */
public boolean exists(Integer item, String name) { public boolean exists(Integer item, String name) {
return quotaMappingRepository return quotaMappingRepository
@ -62,11 +63,16 @@ public class QuotaMappingManager {
} }
/** /**
* Creates the.
* *
* @param item * @param items the items
* @param quota * @param name the name
* @param lifetime * @param value the value
* @return * @param unit the unit
* @param append the append
* @param products the products
* @param disposable the disposable
* @return the quota mapping
*/ */
public QuotaMapping create(Set<Integer> items, String name, long value, String unit, public QuotaMapping create(Set<Integer> items, String name, long value, String unit,
boolean append, Set<String> products, boolean disposable) { boolean append, Set<String> products, boolean disposable) {
@ -86,9 +92,10 @@ public class QuotaMappingManager {
} }
/** /**
* Update.
* *
* @param quotaMapping * @param quotaMapping the quota mapping
* @return * @return the quota mapping
*/ */
public QuotaMapping update(QuotaMapping quotaMapping) { public QuotaMapping update(QuotaMapping quotaMapping) {
Assert.isTrue( Assert.isTrue(
@ -108,9 +115,9 @@ public class QuotaMappingManager {
} }
/** /**
* Delete.
* *
* @param item * @param id the id
* @param name
*/ */
public void delete(Long id) { public void delete(Long id) {
Assert.isTrue(quotaMappingRepository.existsById(id), Assert.isTrue(quotaMappingRepository.existsById(id),
@ -119,12 +126,13 @@ public class QuotaMappingManager {
} }
/** /**
* Gets the.
* *
* @param page * @param page the page
* @param size * @param size the size
* @param sortBy * @param sortBy the sort by
* @param descending * @param descending the descending
* @return * @return the page
*/ */
public Page<QuotaMapping> get(int page, int size, String sortBy, boolean descending) { public Page<QuotaMapping> get(int page, int size, String sortBy, boolean descending) {
Sort sort = descending ? Sort.by(sortBy).descending() : Sort.by(sortBy).ascending(); Sort sort = descending ? Sort.by(sortBy).descending() : Sort.by(sortBy).ascending();

View File

@ -4,12 +4,10 @@
package de.bstly.we.businesslogic; package de.bstly.we.businesslogic;
/** /**
* @author _bastler@bstly.de * The Interface Quotas.
*
*/ */
public interface Quotas { public interface Quotas {
public static final String REGISTRATION_VOUCHERS = "registration_vouchers";
public static final String ALIAS_CREATION = "alias_creation"; public static final String ALIAS_CREATION = "alias_creation";
} }

View File

@ -29,9 +29,7 @@ import de.bstly.we.model.User;
import de.bstly.we.model.UserStatus; import de.bstly.we.model.UserStatus;
/** /**
* * The Class Setup.
* @author _bastler@bstly.de
*
*/ */
@Component @Component
public class Setup implements SmartInitializingSingleton { public class Setup implements SmartInitializingSingleton {
@ -54,9 +52,9 @@ public class Setup implements SmartInitializingSingleton {
private Logger logger = LoggerFactory.getLogger(Setup.class); private Logger logger = LoggerFactory.getLogger(Setup.class);
/* /*
* @see org.springframework.beans.factory.SmartInitializingSingleton# * @see org.springframework.beans.factory.SmartInitializingSingleton#afterSingletonsInstantiated()
* afterSingletonsInstantiated()
*/ */
@Override @Override
public void afterSingletonsInstantiated() { public void afterSingletonsInstantiated() {

View File

@ -13,8 +13,7 @@ import de.bstly.we.model.SystemProfileField;
import de.bstly.we.repository.SystemProfileFieldRepository; import de.bstly.we.repository.SystemProfileFieldRepository;
/** /**
* @author _bastler@bstly.de * The Class SystemProfileFieldManager.
*
*/ */
@Component @Component
public class SystemProfileFieldManager { public class SystemProfileFieldManager {
@ -23,30 +22,33 @@ public class SystemProfileFieldManager {
private SystemProfileFieldRepository systemProfileFieldRepository; private SystemProfileFieldRepository systemProfileFieldRepository;
/** /**
* Save.
* *
* @param systemProfileField * @param systemProfileField the system profile field
* @return * @return the system profile field
*/ */
public SystemProfileField save(SystemProfileField systemProfileField) { public SystemProfileField save(SystemProfileField systemProfileField) {
return systemProfileFieldRepository.save(systemProfileField); return systemProfileFieldRepository.save(systemProfileField);
} }
/** /**
* Gets the.
* *
* @param name * @param name the name
* @return * @return the system profile field
*/ */
public SystemProfileField get(String name) { public SystemProfileField get(String name) {
return systemProfileFieldRepository.findById(name).orElse(null); return systemProfileFieldRepository.findById(name).orElse(null);
} }
/** /**
* Gets the.
* *
* @param page * @param page the page
* @param size * @param size the size
* @param sortBy * @param sortBy the sort by
* @param descending * @param descending the descending
* @return * @return the page
*/ */
public Page<SystemProfileField> get(int page, int size, String sortBy, boolean descending) { public Page<SystemProfileField> get(int page, int size, String sortBy, boolean descending) {
Sort sort = descending ? Sort.by(sortBy).descending() : Sort.by(sortBy).ascending(); Sort sort = descending ? Sort.by(sortBy).descending() : Sort.by(sortBy).ascending();
@ -54,8 +56,9 @@ public class SystemProfileFieldManager {
} }
/** /**
* Delete.
* *
* @param name * @param name the name
*/ */
public void delete(String name) { public void delete(String name) {
systemProfileFieldRepository.deleteById(name); systemProfileFieldRepository.deleteById(name);

View File

@ -11,9 +11,7 @@ import de.bstly.we.model.SystemProperty;
import de.bstly.we.repository.SystemPropertyRepository; import de.bstly.we.repository.SystemPropertyRepository;
/** /**
* * The Class SystemPropertyManager.
* @author _bastler@bstly.de
*
*/ */
@Component @Component
public class SystemPropertyManager { public class SystemPropertyManager {
@ -22,94 +20,104 @@ public class SystemPropertyManager {
private SystemPropertyRepository systemPropertyRepository; private SystemPropertyRepository systemPropertyRepository;
/** /**
* Checks for.
* *
* @param key * @param key the key
* @return * @return true, if successful
*/ */
public boolean has(String key) { public boolean has(String key) {
return systemPropertyRepository.existsById(key); return systemPropertyRepository.existsById(key);
} }
/** /**
* Gets the.
* *
* @param key * @param key the key
* @return * @return the string
*/ */
public String get(String key) { public String get(String key) {
return systemPropertyRepository.findById(key).orElse(new SystemProperty()).getValue(); return systemPropertyRepository.findById(key).orElse(new SystemProperty()).getValue();
} }
/** /**
* Gets the.
* *
* @param key * @param key the key
* @param defaultValue * @param defaultValue the default value
* @return * @return the string
*/ */
public String get(String key, String defaultValue) { public String get(String key, String defaultValue) {
return systemPropertyRepository.findById(key).orElse(new SystemProperty(key, defaultValue)).getValue(); return systemPropertyRepository.findById(key).orElse(new SystemProperty(key, defaultValue)).getValue();
} }
/** /**
* Gets the boolean.
* *
* @param key * @param key the key
* @return * @return the boolean
*/ */
public boolean getBoolean(String key) { public boolean getBoolean(String key) {
return getBoolean(key, false); return getBoolean(key, false);
} }
/** /**
* Gets the boolean.
* *
* @param key * @param key the key
* @param defaultValue * @param defaultValue the default value
* @return * @return the boolean
*/ */
public boolean getBoolean(String key, boolean defaultValue) { public boolean getBoolean(String key, boolean defaultValue) {
return Boolean.valueOf(get(key, String.valueOf(defaultValue))); return Boolean.valueOf(get(key, String.valueOf(defaultValue)));
} }
/** /**
* Gets the integer.
* *
* @param key * @param key the key
* @return * @return the integer
*/ */
public int getInteger(String key) { public int getInteger(String key) {
return getInteger(key, 0); return getInteger(key, 0);
} }
/** /**
* Gets the integer.
* *
* @param key * @param key the key
* @param defaultValue * @param defaultValue the default value
* @return * @return the integer
*/ */
public int getInteger(String key, int defaultValue) { public int getInteger(String key, int defaultValue) {
return Integer.valueOf(get(key, String.valueOf(defaultValue))); return Integer.valueOf(get(key, String.valueOf(defaultValue)));
} }
/** /**
* Gets the long.
* *
* @param key * @param key the key
* @return * @return the long
*/ */
public long getLong(String key) { public long getLong(String key) {
return getLong(key, 0L); return getLong(key, 0L);
} }
/** /**
* Gets the long.
* *
* @param key * @param key the key
* @param defaultValue * @param defaultValue the default value
* @return * @return the long
*/ */
public long getLong(String key, long defaultValue) { public long getLong(String key, long defaultValue) {
return Long.valueOf(get(key, String.valueOf(defaultValue))); return Long.valueOf(get(key, String.valueOf(defaultValue)));
} }
/** /**
* Adds the.
* *
* @param key * @param key the key
* @param value * @param value the value
*/ */
public void add(String key, String value) { public void add(String key, String value) {
Assert.isTrue(!systemPropertyRepository.existsById(key), Assert.isTrue(!systemPropertyRepository.existsById(key),
@ -118,9 +126,10 @@ public class SystemPropertyManager {
} }
/** /**
* Update.
* *
* @param key * @param key the key
* @param value * @param value the value
*/ */
public void update(String key, String value) { public void update(String key, String value) {
Assert.isTrue(systemPropertyRepository.existsById(key), Assert.isTrue(systemPropertyRepository.existsById(key),

View File

@ -20,8 +20,7 @@ import de.bstly.we.model.UserData;
import de.bstly.we.repository.UserAliasRepository; import de.bstly.we.repository.UserAliasRepository;
/** /**
* @author _bastler@bstly.de * The Class UserAliasManager.
*
*/ */
@Component @Component
public class UserAliasManager implements UserDataProvider { public class UserAliasManager implements UserDataProvider {
@ -33,18 +32,20 @@ public class UserAliasManager implements UserDataProvider {
private QUserAlias qUserAlias = QUserAlias.userAlias; private QUserAlias qUserAlias = QUserAlias.userAlias;
/** /**
* Gets the.
* *
* @param id * @param id the id
* @return * @return the user alias
*/ */
public UserAlias get(Long id) { public UserAlias get(Long id) {
return userAliasRepository.findById(id).orElse(null); return userAliasRepository.findById(id).orElse(null);
} }
/** /**
* Save.
* *
* @param userAlias * @param userAlias the user alias
* @return * @return the user alias
*/ */
public UserAlias save(UserAlias userAlias) { public UserAlias save(UserAlias userAlias) {
Assert.notNull(userAlias.getAlias(), "No alias defined!"); Assert.notNull(userAlias.getAlias(), "No alias defined!");
@ -54,26 +55,29 @@ public class UserAliasManager implements UserDataProvider {
} }
/** /**
* Gets the by alias.
* *
* @param alias * @param alias the alias
* @return * @return the by alias
*/ */
public UserAlias getByAlias(String alias) { public UserAlias getByAlias(String alias) {
return userAliasRepository.findOne(qUserAlias.alias.eq(alias)).orElse(null); return userAliasRepository.findOne(qUserAlias.alias.eq(alias)).orElse(null);
} }
/** /**
* Gets the all by target.
* *
* @param userId * @param userId the user id
* @return * @return the all by target
*/ */
public List<UserAlias> getAllByTarget(Long userId) { public List<UserAlias> getAllByTarget(Long userId) {
return Lists.newArrayList(userAliasRepository.findAll(qUserAlias.target.eq(userId))); return Lists.newArrayList(userAliasRepository.findAll(qUserAlias.target.eq(userId)));
} }
/** /**
* Delete.
* *
* @param id * @param id the id
*/ */
public void delete(Long id) { public void delete(Long id) {
UserAlias userAlias = get(id); UserAlias userAlias = get(id);
@ -83,12 +87,13 @@ public class UserAliasManager implements UserDataProvider {
} }
/** /**
* Gets the.
* *
* @param page * @param page the page
* @param size * @param size the size
* @param sortBy * @param sortBy the sort by
* @param descending * @param descending the descending
* @return * @return the page
*/ */
public Page<UserAlias> get(int page, int size, String sortBy, boolean descending) { public Page<UserAlias> get(int page, int size, String sortBy, boolean descending) {
Sort sort = descending ? Sort.by(sortBy).descending() : Sort.by(sortBy).ascending(); Sort sort = descending ? Sort.by(sortBy).descending() : Sort.by(sortBy).ascending();

View File

@ -32,8 +32,7 @@ import de.bstly.we.model.UserStatus;
import de.bstly.we.repository.UserRepository; import de.bstly.we.repository.UserRepository;
/** /**
* @author _bastler@bstly.de * The Class UserDataManager.
*
*/ */
@Component @Component
public class UserDataManager implements SmartInitializingSingleton { public class UserDataManager implements SmartInitializingSingleton {
@ -61,9 +60,9 @@ public class UserDataManager implements SmartInitializingSingleton {
private List<UserDataProvider> providers; private List<UserDataProvider> providers;
private Gson gson = new Gson(); private Gson gson = new Gson();
/* /*
* @see org.springframework.beans.factory.SmartInitializingSingleton# * @see org.springframework.beans.factory.SmartInitializingSingleton#afterSingletonsInstantiated()
* afterSingletonsInstantiated()
*/ */
@Override @Override
public void afterSingletonsInstantiated() { public void afterSingletonsInstantiated() {
@ -75,7 +74,7 @@ public class UserDataManager implements SmartInitializingSingleton {
} }
/** /**
* * Purge.
*/ */
@Scheduled(cron = "${we.bstly.userdata.cron:0 0 0 * * * }") @Scheduled(cron = "${we.bstly.userdata.cron:0 0 0 * * * }")
public void purge() { public void purge() {
@ -114,8 +113,10 @@ public class UserDataManager implements SmartInitializingSingleton {
} }
/** /**
* Purge.
* *
* @param username * @param user the user
* @param dry the dry
*/ */
public void purge(User user, boolean dry) { public void purge(User user, boolean dry) {
Long userId = user.getId(); Long userId = user.getId();
@ -161,9 +162,10 @@ public class UserDataManager implements SmartInitializingSingleton {
} }
/** /**
* Gets the.
* *
* @param userId * @param userId the user id
* @return * @return the map
*/ */
public Map<String, List<UserData>> get(Long userId) { public Map<String, List<UserData>> get(Long userId) {
Map<String, List<UserData>> userData = Maps.newHashMap(); Map<String, List<UserData>> userData = Maps.newHashMap();

View File

@ -8,28 +8,29 @@ import java.util.List;
import de.bstly.we.model.UserData; import de.bstly.we.model.UserData;
/** /**
* @author _bastler@bstly.de * The Interface UserDataProvider.
*
*/ */
public interface UserDataProvider { public interface UserDataProvider {
/** /**
* Gets the id.
* *
* @return * @return the id
*/ */
String getId(); String getId();
/** /**
* Gets the user data.
* *
* @param userId * @param userId the user id
* @return * @return the user data
*/ */
List<UserData> getUserData(Long userId); List<UserData> getUserData(Long userId);
/** /**
* Purge user data.
* *
* @param userId * @param userId the user id
* @return
*/ */
void purgeUserData(Long userId); void purgeUserData(Long userId);

View File

@ -30,8 +30,7 @@ import de.bstly.we.model.UserDomain;
import de.bstly.we.repository.UserDomainRepository; import de.bstly.we.repository.UserDomainRepository;
/** /**
* @author _bastler@bstly.de * The Class UserDomainManager.
*
*/ */
@Component @Component
public class UserDomainManager implements UserDataProvider { public class UserDomainManager implements UserDataProvider {
@ -47,7 +46,7 @@ public class UserDomainManager implements UserDataProvider {
private InitialDirContext dirContext; private InitialDirContext dirContext;
/** /**
* * Instantiates a new user domain manager.
*/ */
public UserDomainManager() { public UserDomainManager() {
Hashtable<String, String> env = new Hashtable<String, String>(); Hashtable<String, String> env = new Hashtable<String, String>();
@ -63,18 +62,20 @@ public class UserDomainManager implements UserDataProvider {
} }
/** /**
* Gets the.
* *
* @param id * @param id the id
* @return * @return the user domain
*/ */
public UserDomain get(Long id) { public UserDomain get(Long id) {
return userDomainRepository.findById(id).orElse(null); return userDomainRepository.findById(id).orElse(null);
} }
/** /**
* Save.
* *
* @param userDomain * @param userDomain the user domain
* @return * @return the user domain
*/ */
public UserDomain save(UserDomain userDomain) { public UserDomain save(UserDomain userDomain) {
Assert.notNull(userDomain.getDomain(), "No domain defined!"); Assert.notNull(userDomain.getDomain(), "No domain defined!");
@ -84,26 +85,29 @@ public class UserDomainManager implements UserDataProvider {
} }
/** /**
* Gets the by domain.
* *
* @param domain * @param domain the domain
* @return * @return the by domain
*/ */
public UserDomain getByDomain(String domain) { public UserDomain getByDomain(String domain) {
return userDomainRepository.findOne(qUserDomain.domain.eq(domain)).orElse(null); return userDomainRepository.findOne(qUserDomain.domain.eq(domain)).orElse(null);
} }
/** /**
* Gets the all by target.
* *
* @param userId * @param userId the user id
* @return * @return the all by target
*/ */
public List<UserDomain> getAllByTarget(Long userId) { public List<UserDomain> getAllByTarget(Long userId) {
return Lists.newArrayList(userDomainRepository.findAll(qUserDomain.target.eq(userId))); return Lists.newArrayList(userDomainRepository.findAll(qUserDomain.target.eq(userId)));
} }
/** /**
* Delete.
* *
* @param id * @param id the id
*/ */
public void delete(Long id) { public void delete(Long id) {
UserDomain userDomain = get(id); UserDomain userDomain = get(id);
@ -113,12 +117,13 @@ public class UserDomainManager implements UserDataProvider {
} }
/** /**
* Gets the.
* *
* @param page * @param page the page
* @param size * @param size the size
* @param sortBy * @param sortBy the sort by
* @param descending * @param descending the descending
* @return * @return the page
*/ */
public Page<UserDomain> get(int page, int size, String sortBy, boolean descending) { public Page<UserDomain> get(int page, int size, String sortBy, boolean descending) {
Sort sort = descending ? Sort.by(sortBy).descending() : Sort.by(sortBy).ascending(); Sort sort = descending ? Sort.by(sortBy).descending() : Sort.by(sortBy).ascending();
@ -126,7 +131,7 @@ public class UserDomainManager implements UserDataProvider {
} }
/** /**
* * Validate.
*/ */
@Scheduled(cron = "0 */15 * * * *") @Scheduled(cron = "0 */15 * * * *")
public void validate() { public void validate() {
@ -149,9 +154,11 @@ public class UserDomainManager implements UserDataProvider {
} }
/** /**
* Validate.
* *
* @param userDomain * @param userDomain the user domain
* @throws NamingException * @return true, if successful
* @throws NamingException the naming exception
*/ */
public boolean validate(UserDomain userDomain) throws NamingException { public boolean validate(UserDomain userDomain) throws NamingException {
Attributes attributes = dirContext.getAttributes("_bstly." + userDomain.getDomain(), Attributes attributes = dirContext.getAttributes("_bstly." + userDomain.getDomain(),

View File

@ -37,9 +37,7 @@ import de.bstly.we.model.UserStatus;
import de.bstly.we.repository.UserRepository; import de.bstly.we.repository.UserRepository;
/** /**
* * The Class UserManager.
* @author _bastler@bstly.de
*
*/ */
@Component @Component
public class UserManager implements UserDataProvider { public class UserManager implements UserDataProvider {
@ -63,34 +61,40 @@ public class UserManager implements UserDataProvider {
private String userEmailDomain; private String userEmailDomain;
/** /**
* @param id * Gets the.
* @return *
* @param id the id
* @return the user
*/ */
public User get(Long id) { public User get(Long id) {
return userRepository.findById(id).orElse(null); return userRepository.findById(id).orElse(null);
} }
/** /**
* Gets the by username.
* *
* @param username * @param username the username
* @return * @return the by username
*/ */
public User getByUsername(String username) { public User getByUsername(String username) {
return userRepository.findOne(qUser.username.equalsIgnoreCase(username)).orElse(null); return userRepository.findOne(qUser.username.equalsIgnoreCase(username)).orElse(null);
} }
/** /**
* Gets the by reset token.
* *
* @param resetToken * @param resetToken the reset token
* @return * @return the by reset token
*/ */
public User getByResetToken(String resetToken) { public User getByResetToken(String resetToken) {
return userRepository.findOne(qUser.resetToken.eq(resetToken)).orElse(null); return userRepository.findOne(qUser.resetToken.eq(resetToken)).orElse(null);
} }
/** /**
* @param id * Gets the password hash.
* @return *
* @param id the id
* @return the password hash
*/ */
public String getPasswordHash(Long id) { public String getPasswordHash(Long id) {
Assert.isTrue(userRepository.existsById(id), "User with id '" + id + "' not exists!"); Assert.isTrue(userRepository.existsById(id), "User with id '" + id + "' not exists!");
@ -98,9 +102,11 @@ public class UserManager implements UserDataProvider {
} }
/** /**
* Sets the password.
* *
* @param id * @param id the id
* @param passwordHash * @param password the password
* @return the user
*/ */
public User setPassword(Long id, String password) { public User setPassword(Long id, String password) {
Assert.isTrue(userRepository.existsById(id), "User with id '" + id + "' not exists!"); Assert.isTrue(userRepository.existsById(id), "User with id '" + id + "' not exists!");
@ -110,12 +116,12 @@ public class UserManager implements UserDataProvider {
} }
/** /**
* Creates the.
* *
* @param username * @param username the username
* @param email * @param password the password
* @param password * @param status the status
* @param publicKey * @return the user
* @return
*/ */
public User create(String username, String password, UserStatus status) { public User create(String username, String password, UserStatus status) {
Assert.isTrue(!userRepository.exists(qUser.username.equalsIgnoreCase(username)), Assert.isTrue(!userRepository.exists(qUser.username.equalsIgnoreCase(username)),
@ -134,12 +140,13 @@ public class UserManager implements UserDataProvider {
} }
/** /**
* Gets the.
* *
* @param page * @param page the page
* @param size * @param size the size
* @param sortBy * @param sortBy the sort by
* @param descending * @param descending the descending
* @return * @return the page
*/ */
public Page<User> get(int page, int size, String sortBy, boolean descending) { public Page<User> get(int page, int size, String sortBy, boolean descending) {
Sort sort = descending ? Sort.by(sortBy).descending() : Sort.by(sortBy).ascending(); Sort sort = descending ? Sort.by(sortBy).descending() : Sort.by(sortBy).ascending();
@ -147,8 +154,10 @@ public class UserManager implements UserDataProvider {
} }
/** /**
* @param user * Update.
* @return *
* @param user the user
* @return the user
*/ */
public User update(User user) { public User update(User user) {
Assert.isTrue(userRepository.existsById(user.getId()), Assert.isTrue(userRepository.existsById(user.getId()),
@ -168,8 +177,9 @@ public class UserManager implements UserDataProvider {
} }
/** /**
* Delete.
* *
* @param user * @param user the user
*/ */
public void delete(User user) { public void delete(User user) {
Assert.isTrue(userRepository.existsById(user.getId()), Assert.isTrue(userRepository.existsById(user.getId()),
@ -186,18 +196,20 @@ public class UserManager implements UserDataProvider {
} }
/** /**
* Gets the bstly email.
* *
* @param username * @param username the username
* @return * @return the bstly email
*/ */
public String getBstlyEmail(String username) { public String getBstlyEmail(String username) {
return username + "@" + userEmailDomain; return username + "@" + userEmailDomain;
} }
/** /**
* Write public key.
* *
* @param username * @param username the username
* @param publicKey * @param publicKey the public key
*/ */
public void writePublicKey(String username, String publicKey) { public void writePublicKey(String username, String publicKey) {
if (StringUtils.hasText(publicKey)) { if (StringUtils.hasText(publicKey)) {
@ -225,17 +237,20 @@ public class UserManager implements UserDataProvider {
} }
/** /**
* Gets the public key path.
* *
* @param username * @param username the username
* @return * @return the public key path
*/ */
public String getPublicKeyPath(String username) { public String getPublicKeyPath(String username) {
return userDataDirectory + username + File.separator + "public.key"; return userDataDirectory + username + File.separator + "public.key";
} }
/** /**
* @param user * Password reset.
* @param outputStream *
* @param user the user
* @param outputStream the output stream
*/ */
public void passwordReset(User user, ServletOutputStream outputStream) { public void passwordReset(User user, ServletOutputStream outputStream) {
String resetToken = RandomStringUtils.random(64, true, true); String resetToken = RandomStringUtils.random(64, true, true);
@ -278,8 +293,9 @@ public class UserManager implements UserDataProvider {
} }
/** /**
* Delete sessions for user.
* *
* @param user * @param user the user
*/ */
protected void deleteSessionsForUser(User user) { protected void deleteSessionsForUser(User user) {
Map<String, ? extends Session> usersSessions = sessionRepository Map<String, ? extends Session> usersSessions = sessionRepository

View File

@ -19,8 +19,7 @@ import de.bstly.we.model.Visibility;
import de.bstly.we.repository.UserProfileFieldRepository; import de.bstly.we.repository.UserProfileFieldRepository;
/** /**
* @author _bastler@bstly.de * The Class UserProfileFieldManager.
*
*/ */
@Component @Component
public class UserProfileFieldManager implements UserDataProvider { public class UserProfileFieldManager implements UserDataProvider {
@ -30,10 +29,11 @@ public class UserProfileFieldManager implements UserDataProvider {
private QUserProfileField qUserProfileField = QUserProfileField.userProfileField; private QUserProfileField qUserProfileField = QUserProfileField.userProfileField;
/** /**
* Gets the.
* *
* @param target * @param target the target
* @param name * @param name the name
* @return * @return the user profile field
*/ */
public UserProfileField get(Long target, String name) { public UserProfileField get(Long target, String name) {
return userProfileFieldRepository return userProfileFieldRepository
@ -42,9 +42,10 @@ public class UserProfileFieldManager implements UserDataProvider {
} }
/** /**
* Gets the all by target.
* *
* @param target * @param target the target
* @return * @return the all by target
*/ */
public List<UserProfileField> getAllByTarget(Long target) { public List<UserProfileField> getAllByTarget(Long target) {
return Lists.newArrayList(userProfileFieldRepository.findAll( return Lists.newArrayList(userProfileFieldRepository.findAll(
@ -52,9 +53,11 @@ public class UserProfileFieldManager implements UserDataProvider {
} }
/** /**
* Gets the by target filtered.
* *
* @param target * @param target the target
* @return * @param names the names
* @return the by target filtered
*/ */
public List<UserProfileField> getByTargetFiltered(Long target, List<String> names) { public List<UserProfileField> getByTargetFiltered(Long target, List<String> names) {
return Lists.newArrayList(userProfileFieldRepository.findAll( return Lists.newArrayList(userProfileFieldRepository.findAll(
@ -63,10 +66,11 @@ public class UserProfileFieldManager implements UserDataProvider {
} }
/** /**
* Gets the all by target and visibilities.
* *
* @param target * @param target the target
* @param visibilities * @param visibilities the visibilities
* @return * @return the all by target and visibilities
*/ */
public List<UserProfileField> getAllByTargetAndVisibilities(Long target, public List<UserProfileField> getAllByTargetAndVisibilities(Long target,
List<Visibility> visibilities) { List<Visibility> visibilities) {
@ -77,18 +81,20 @@ public class UserProfileFieldManager implements UserDataProvider {
} }
/** /**
* Save.
* *
* @param userProfileField * @param userProfileField the user profile field
* @return * @return the user profile field
*/ */
public UserProfileField save(UserProfileField userProfileField) { public UserProfileField save(UserProfileField userProfileField) {
return userProfileFieldRepository.save(userProfileField); return userProfileFieldRepository.save(userProfileField);
} }
/** /**
* Delete.
* *
* @param target * @param target the target
* @param name * @param name the name
*/ */
public void delete(Long target, String name) { public void delete(Long target, String name) {
Assert.isTrue( Assert.isTrue(
@ -102,8 +108,9 @@ public class UserProfileFieldManager implements UserDataProvider {
} }
/** /**
* Delete all.
* *
* @param target * @param target the target
*/ */
public void deleteAll(Long target) { public void deleteAll(Long target) {
userProfileFieldRepository userProfileFieldRepository

View File

@ -4,8 +4,7 @@
package de.bstly.we.businesslogic; package de.bstly.we.businesslogic;
/** /**
* @author _bastler@bstly.de * The Interface UserProfileFields.
*
*/ */
public interface UserProfileFields { public interface UserProfileFields {

View File

@ -23,8 +23,7 @@ import dev.samstevens.totp.recovery.RecoveryCodeGenerator;
import dev.samstevens.totp.secret.SecretGenerator; import dev.samstevens.totp.secret.SecretGenerator;
/** /**
* @author _bastler@bstly.de * The Class UserTotpManager.
*
*/ */
@Component @Component
public class UserTotpManager implements SecondFactorProvider<UserTotp> { public class UserTotpManager implements SecondFactorProvider<UserTotp> {
@ -51,21 +50,18 @@ public class UserTotpManager implements SecondFactorProvider<UserTotp> {
return "totp"; return "totp";
} }
/* /*
* @see * @see de.bstly.we.security.businesslogic.SecondFactorProvider#supports(java.lang.String)
* de.bstly.we.security.businesslogic.SecondFactorProvider#supports(java.lang.
* String)
*/ */
@Override @Override
public boolean supports(String provider) { public boolean supports(String provider) {
return getId().equals(provider); return getId().equals(provider);
} }
/* /*
* * @see de.bstly.we.security.businesslogic.SecondFactorProvider#isEnabled(java.lang.Long)
* @see
* de.bstly.we.security.businesslogic.SecondFactorProvider#isEnabled(java.lang.
* Long)
*/ */
@Override @Override
public boolean isEnabled(Long userId) { public boolean isEnabled(Long userId) {
@ -74,10 +70,7 @@ public class UserTotpManager implements SecondFactorProvider<UserTotp> {
} }
/* /*
* * @see de.bstly.we.security.businesslogic.SecondFactorProvider#validate(java.lang.Long, java.lang.String)
* @see
* de.bstly.we.security.businesslogic.SecondFactorProvider#validate(java.lang.
* Long, java.lang.String)
*/ */
@Override @Override
public boolean validate(Long userId, String code) { public boolean validate(Long userId, String code) {
@ -90,20 +83,18 @@ public class UserTotpManager implements SecondFactorProvider<UserTotp> {
return false; return false;
} }
/* /*
* @see * @see de.bstly.we.security.businesslogic.SecondFactorProvider#get(java.lang.Long)
* de.bstly.we.security.businesslogic.SecondFactorProvider#getForUser(java.lang.
* Long)
*/ */
@Override @Override
public UserTotp get(Long userId) { public UserTotp get(Long userId) {
return userTotpRepository.findOne(qUserTotp.target.eq(userId)).orElse(null); return userTotpRepository.findOne(qUserTotp.target.eq(userId)).orElse(null);
} }
/* /*
* @see * @see de.bstly.we.security.businesslogic.SecondFactorProvider#create(java.lang.Long)
* de.bstly.we.security.businesslogic.SecondFactorProvider#createByUser(java.
* lang.Long)
*/ */
@Override @Override
public UserTotp create(Long userId) { public UserTotp create(Long userId) {
@ -123,10 +114,9 @@ public class UserTotpManager implements SecondFactorProvider<UserTotp> {
return userTotpRepository.findOne(qUserTotp.target.eq(userId)).orElse(null); return userTotpRepository.findOne(qUserTotp.target.eq(userId)).orElse(null);
} }
/* /*
* @see * @see de.bstly.we.security.businesslogic.SecondFactorProvider#enable(java.lang.Long, java.lang.String)
* de.bstly.we.security.businesslogic.SecondFactorProvider#enableByUser(java.
* lang.Long, java.lang.String)
*/ */
@Override @Override
public boolean enable(Long userId, String code) { public boolean enable(Long userId, String code) {
@ -140,10 +130,9 @@ public class UserTotpManager implements SecondFactorProvider<UserTotp> {
return false; return false;
} }
/* /*
* @see * @see de.bstly.we.security.businesslogic.SecondFactorProvider#delete(java.lang.Long)
* de.bstly.we.security.businesslogic.SecondFactorProvider#deleteByUser(java.
* lang.Long)
*/ */
@Override @Override
public void delete(Long userId) { public void delete(Long userId) {

View File

@ -0,0 +1,161 @@
/**
*
*/
package de.bstly.we.businesslogic;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import com.beust.jcommander.internal.Lists;
import de.bstly.we.model.QVoucherMapping;
import de.bstly.we.model.Quota;
import de.bstly.we.model.VoucherMapping;
import de.bstly.we.repository.VoucherMappingRepository;
/**
* The Class VoucherMappingManager.
*/
@Component
public class VoucherMappingManager {
@Autowired
private VoucherMappingRepository voucherMappingRepository;
@Autowired
private QuotaManager quotaManager;
@Autowired
private PermissionManager permissionManager;
@Autowired
private PretixManager pretixManager;
private QVoucherMapping qVocherMapping = QVoucherMapping.voucherMapping;
/**
* Exists.
*
* @param name the name
* @return true, if successful
*/
public boolean exists(String name) {
return voucherMappingRepository.exists(qVocherMapping.name.eq(name));
}
/**
* Gets the.
*
* @param name the name
* @return the voucher mapping
*/
public VoucherMapping get(String name) {
return voucherMappingRepository.findOne(qVocherMapping.name.eq(name)).orElse(null);
}
/**
* Creates the.
*
* @param name the name
* @param voucher the voucher
* @param quota the quota
* @param isFree the is free
* @return the voucher mapping
*/
public VoucherMapping create(String name, int voucher, String quota, boolean isFree) {
Assert.isTrue(!exists(name), "QuotaMapping for voucher '"
+ voucher
+ "' with '"
+ name
+ "' already exists!");
VoucherMapping voucherMapping = new VoucherMapping();
voucherMapping.setName(name);
voucherMapping.setVoucher(voucher);
voucherMapping.setQuota(quota);
voucherMapping.setFree(isFree);
return voucherMappingRepository.save(voucherMapping);
}
/**
* Update.
*
* @param voucherMapping the voucher mapping
* @return the voucher mapping
*/
public VoucherMapping update(VoucherMapping voucherMapping) {
Assert.isTrue(
voucherMapping.getId() != null
&& voucherMappingRepository.existsById(voucherMapping.getId()),
"VoucherMapping '"
+ voucherMapping.getId()
+ "' does not exists!");
return voucherMappingRepository.save(voucherMapping);
}
/**
* Delete.
*
* @param id the id
*/
public void delete(Long id) {
Assert.isTrue(voucherMappingRepository.existsById(id), "VoucherMapping '"
+ id
+ "' does not exists!");
voucherMappingRepository.deleteById(id);
}
/**
* Gets the.
*
* @param page the page
* @param size the size
* @param sortBy the sort by
* @param descending the descending
* @return the page
*/
public Page<VoucherMapping> get(int page, int size, String sortBy, boolean descending) {
Sort sort = descending ? Sort.by(sortBy).descending() : Sort.by(sortBy).ascending();
return voucherMappingRepository.findAll(PageRequest.of(page, size, sort));
}
/**
* Gets the for user.
*
* @param userId the user id
* @return the for user
*/
public List<VoucherMapping> getForUser(Long userId) {
List<VoucherMapping> voucherMappings = Lists.newArrayList();
if (permissionManager.isFullUser(userId)) {
for (VoucherMapping voucherMapping : voucherMappingRepository.findAll()) {
if (voucherMapping.isFree()) {
voucherMappings.add(voucherMapping);
} else if (StringUtils.hasText(voucherMapping.getQuota())) {
Quota quota = quotaManager.get(userId, voucherMapping.getQuota());
if (quota != null && quota.getValue() >= 1) {
voucherMappings.add(voucherMapping);
}
}
}
}
return voucherMappings;
}
/**
* Creates the voucher.
*
* @param voucher the voucher
* @return the string
*/
public String createVoucher(int voucher) {
return pretixManager.createVoucher(voucher).get("code").getAsString();
}
}

View File

@ -20,8 +20,15 @@ import de.bstly.we.event.AbstractModelEventType;
import de.bstly.we.model.AbstractModel; import de.bstly.we.model.AbstractModel;
/** /**
* @author Lurkars * The listener interface for receiving abstractModelEvent events.
* The class that is interested in processing a abstractModelEvent
* event implements this interface, and the object created
* with that class is registered with a component using the
* component's <code>addAbstractModelEventListener<code> method. When
* the abstractModelEvent event occurs, that object's appropriate
* method is invoked.
* *
* @see AbstractModelEventEvent
*/ */
@Component @Component
public class AbstractModelEventListener { public class AbstractModelEventListener {
@ -29,36 +36,71 @@ public class AbstractModelEventListener {
@Autowired @Autowired
private ApplicationEventPublisher applicationEventPublisher; private ApplicationEventPublisher applicationEventPublisher;
/**
* Pre persist.
*
* @param model the model
*/
@PrePersist @PrePersist
private void prePersist(AbstractModel model) { private void prePersist(AbstractModel model) {
applicationEventPublisher.publishEvent(new AbstractModelEvent(AbstractModelEventType.PRE_PERSIST, model)); applicationEventPublisher.publishEvent(new AbstractModelEvent(AbstractModelEventType.PRE_PERSIST, model));
} }
/**
* Pre update.
*
* @param model the model
*/
@PreUpdate @PreUpdate
private void preUpdate(AbstractModel model) { private void preUpdate(AbstractModel model) {
applicationEventPublisher.publishEvent(new AbstractModelEvent(AbstractModelEventType.PRE_UPDATE, model)); applicationEventPublisher.publishEvent(new AbstractModelEvent(AbstractModelEventType.PRE_UPDATE, model));
} }
/**
* Pre remove.
*
* @param model the model
*/
@PreRemove @PreRemove
private void preRemove(AbstractModel model) { private void preRemove(AbstractModel model) {
applicationEventPublisher.publishEvent(new AbstractModelEvent(AbstractModelEventType.PRE_REMOVE, model)); applicationEventPublisher.publishEvent(new AbstractModelEvent(AbstractModelEventType.PRE_REMOVE, model));
} }
/**
* Post persist.
*
* @param model the model
*/
@PostPersist @PostPersist
private void postPersist(AbstractModel model) { private void postPersist(AbstractModel model) {
applicationEventPublisher.publishEvent(new AbstractModelEvent(AbstractModelEventType.POST_PERSIST, model)); applicationEventPublisher.publishEvent(new AbstractModelEvent(AbstractModelEventType.POST_PERSIST, model));
} }
/**
* Post update.
*
* @param model the model
*/
@PostUpdate @PostUpdate
private void postUpdate(AbstractModel model) { private void postUpdate(AbstractModel model) {
applicationEventPublisher.publishEvent(new AbstractModelEvent(AbstractModelEventType.POST_UPDATE, model)); applicationEventPublisher.publishEvent(new AbstractModelEvent(AbstractModelEventType.POST_UPDATE, model));
} }
/**
* Post remove.
*
* @param model the model
*/
@PostRemove @PostRemove
private void postRemove(AbstractModel model) { private void postRemove(AbstractModel model) {
applicationEventPublisher.publishEvent(new AbstractModelEvent(AbstractModelEventType.POST_REMOVE, model)); applicationEventPublisher.publishEvent(new AbstractModelEvent(AbstractModelEventType.POST_REMOVE, model));
} }
/**
* Post load.
*
* @param model the model
*/
@PostLoad @PostLoad
private void postLoad(AbstractModel model) { private void postLoad(AbstractModel model) {
applicationEventPublisher.publishEvent(new AbstractModelEvent(AbstractModelEventType.POST_LOAD, model)); applicationEventPublisher.publishEvent(new AbstractModelEvent(AbstractModelEventType.POST_LOAD, model));

View File

@ -12,48 +12,51 @@ import java.time.temporal.TemporalAmount;
import java.time.temporal.TemporalUnit; import java.time.temporal.TemporalUnit;
/** /**
* @author _bastler@bstly.de * The Class InstantHelper.
*
*/ */
public class InstantHelper { public class InstantHelper {
/** /**
* Plus.
* *
* @param instant * @param instant the instant
* @param amount * @param amount the amount
* @return * @return the instant
*/ */
public static Instant plus(Instant instant, TemporalAmount amount) { public static Instant plus(Instant instant, TemporalAmount amount) {
return ZonedDateTime.ofInstant(instant, ZoneOffset.UTC).plus(amount).toInstant(); return ZonedDateTime.ofInstant(instant, ZoneOffset.UTC).plus(amount).toInstant();
} }
/** /**
* Plus.
* *
* @param instant * @param instant the instant
* @param amountToAdd * @param amountToAdd the amount to add
* @param unit * @param unit the unit
* @return * @return the instant
*/ */
public static Instant plus(Instant instant, long amountToAdd, TemporalUnit unit) { public static Instant plus(Instant instant, long amountToAdd, TemporalUnit unit) {
return ZonedDateTime.ofInstant(instant, ZoneOffset.UTC).plus(amountToAdd, unit).toInstant(); return ZonedDateTime.ofInstant(instant, ZoneOffset.UTC).plus(amountToAdd, unit).toInstant();
} }
/** /**
* Minus.
* *
* @param instant * @param instant the instant
* @param amount * @param amount the amount
* @return * @return the instant
*/ */
public static Instant minus(Instant instant, TemporalAmount amount) { public static Instant minus(Instant instant, TemporalAmount amount) {
return ZonedDateTime.ofInstant(instant, ZoneOffset.UTC).minus(amount).toInstant(); return ZonedDateTime.ofInstant(instant, ZoneOffset.UTC).minus(amount).toInstant();
} }
/** /**
* Minus.
* *
* @param instant * @param instant the instant
* @param amountToAdd * @param amountToAdd the amount to add
* @param unit * @param unit the unit
* @return * @return the instant
*/ */
public static Instant minus(Instant instant, long amountToAdd, TemporalUnit unit) { public static Instant minus(Instant instant, long amountToAdd, TemporalUnit unit) {
return ZonedDateTime.ofInstant(instant, ZoneOffset.UTC).minus(amountToAdd, unit) return ZonedDateTime.ofInstant(instant, ZoneOffset.UTC).minus(amountToAdd, unit)
@ -61,10 +64,11 @@ public class InstantHelper {
} }
/** /**
* Truncate.
* *
* @param instant * @param instant the instant
* @param unit * @param unit the unit
* @return * @return the instant
*/ */
public static Instant truncate(Instant instant, TemporalUnit unit) { public static Instant truncate(Instant instant, TemporalUnit unit) {
if (ChronoUnit.YEARS.equals(unit)) { if (ChronoUnit.YEARS.equals(unit)) {

View File

@ -31,9 +31,7 @@ import de.bstly.we.security.businesslogic.SecondFactorRequestProvider;
import de.bstly.we.security.model.LocalUserDetails; import de.bstly.we.security.model.LocalUserDetails;
/** /**
* * The Class Authentication2FAController.
* @author _bastler@bstly.de
*
*/ */
@RestController @RestController
@RequestMapping("/auth/2fa") @RequestMapping("/auth/2fa")
@ -43,8 +41,9 @@ public class Authentication2FAController extends BaseController {
private SecondFactorProviderManager secondFactorProviderManager; private SecondFactorProviderManager secondFactorProviderManager;
/** /**
* Gets the pre authentication id.
* *
* @return * @return the pre authentication id
*/ */
protected Long getPreAuthenticationId() { protected Long getPreAuthenticationId() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication(); Authentication auth = SecurityContextHolder.getContext().getAuthentication();
@ -56,8 +55,9 @@ public class Authentication2FAController extends BaseController {
} }
/** /**
* Gets the enabled.
* *
* @return * @return the enabled
*/ */
@GetMapping @GetMapping
public List<SecondFactorProviderModel> getEnabled() { public List<SecondFactorProviderModel> getEnabled() {
@ -77,8 +77,9 @@ public class Authentication2FAController extends BaseController {
} }
/** /**
* Gets the available.
* *
* @return * @return the available
*/ */
@GetMapping("/available") @GetMapping("/available")
public List<SecondFactorProviderModel> getAvailable() { public List<SecondFactorProviderModel> getAvailable() {
@ -103,8 +104,9 @@ public class Authentication2FAController extends BaseController {
} }
/** /**
* Checks if is second factor enabled.
* *
* @return * @param providerId the provider id
*/ */
@PreAuthorize("authentication.authenticated") @PreAuthorize("authentication.authenticated")
@GetMapping("/{id}") @GetMapping("/{id}")
@ -121,7 +123,9 @@ public class Authentication2FAController extends BaseController {
} }
/** /**
* Request second factor mail.
* *
* @param providerId the provider id
*/ */
@PreAuthorize("hasRole('ROLE_PRE_AUTH_USER')") @PreAuthorize("hasRole('ROLE_PRE_AUTH_USER')")
@PostMapping("/{id}") @PostMapping("/{id}")
@ -146,8 +150,10 @@ public class Authentication2FAController extends BaseController {
} }
/** /**
* Creates the second factor.
* *
* @return * @param providerId the provider id
* @return the second factor
*/ */
@PreAuthorize("authentication.authenticated") @PreAuthorize("authentication.authenticated")
@PutMapping("/{id}") @PutMapping("/{id}")
@ -166,8 +172,10 @@ public class Authentication2FAController extends BaseController {
} }
/** /**
* Enable second factor.
* *
* @return * @param providerId the provider id
* @param token the token
*/ */
@PreAuthorize("authentication.authenticated") @PreAuthorize("authentication.authenticated")
@PatchMapping("/{id}") @PatchMapping("/{id}")
@ -185,7 +193,9 @@ public class Authentication2FAController extends BaseController {
} }
/** /**
* Removes the second factor mail.
* *
* @param providerId the provider id
*/ */
@PreAuthorize("authentication.authenticated") @PreAuthorize("authentication.authenticated")
@DeleteMapping("/{id}") @DeleteMapping("/{id}")

View File

@ -30,9 +30,7 @@ import de.bstly.we.controller.validation.PasswordModelValidator;
import de.bstly.we.model.User; import de.bstly.we.model.User;
/** /**
* * The Class AuthenticationController.
* @author _bastler@bstly.de
*
*/ */
@RestController @RestController
@RequestMapping("/auth") @RequestMapping("/auth")
@ -44,8 +42,9 @@ public class AuthenticationController extends BaseController {
private PasswordModelValidator passwordModelValidator; private PasswordModelValidator passwordModelValidator;
/** /**
* Me.
* *
* @return * @return the authentication
*/ */
@GetMapping("/me") @GetMapping("/me")
public Authentication me() { public Authentication me() {
@ -54,11 +53,12 @@ public class AuthenticationController extends BaseController {
} }
/** /**
* Password request.
* *
* @param username * @param username the username
* @param req * @param req the req
* @param resp * @param resp the resp
* @throws IOException * @throws IOException Signals that an I/O exception has occurred.
*/ */
@PreAuthorize("isAnonymous()") @PreAuthorize("isAnonymous()")
@PostMapping("/password/request") @PostMapping("/password/request")
@ -75,10 +75,11 @@ public class AuthenticationController extends BaseController {
} }
/** /**
* Password reset.
* *
* @param passwordResetModel * @param passwordResetModel the password reset model
* @param req * @param req the req
* @param resp * @param resp the resp
*/ */
@PreAuthorize("isAnonymous()") @PreAuthorize("isAnonymous()")
@PostMapping("/password/reset") @PostMapping("/password/reset")

View File

@ -9,15 +9,14 @@ import org.springframework.security.core.context.SecurityContextHolder;
import de.bstly.we.security.model.LocalUserDetails; import de.bstly.we.security.model.LocalUserDetails;
/** /**
* * The Class BaseController.
* @author _bastler@bstly.de
*
*/ */
public class BaseController { public class BaseController {
/** /**
* Gets the current user id.
* *
* @return * @return the current user id
*/ */
public Long getCurrentUserId() { public Long getCurrentUserId() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication(); Authentication auth = SecurityContextHolder.getContext().getAuthentication();

View File

@ -34,9 +34,7 @@ import de.bstly.we.controller.support.TokenSessionManager;
import de.bstly.we.model.User; import de.bstly.we.model.User;
/** /**
* * The Class ItemController.
* @author _bastler@bstly.de
*
*/ */
@RestController @RestController
@RequestMapping("/items") @RequestMapping("/items")
@ -50,7 +48,10 @@ public class ItemController extends BaseController {
private UserManager userManager; private UserManager userManager;
/** /**
* Gets the items.
* *
* @param session the session
* @return the items
*/ */
@GetMapping @GetMapping
public Set<ItemModel> getItems(HttpSession session) { public Set<ItemModel> getItems(HttpSession session) {
@ -77,8 +78,10 @@ public class ItemController extends BaseController {
} }
/** /**
* Adds the item.
* *
* @param secret * @param secret the secret
* @param session the session
*/ */
@PutMapping("") @PutMapping("")
public void addItem(@RequestBody String secret, HttpSession session) { public void addItem(@RequestBody String secret, HttpSession session) {
@ -94,8 +97,10 @@ public class ItemController extends BaseController {
} }
/** /**
* Removes the item.
* *
* @param secret * @param secret the secret
* @param session the session
*/ */
@DeleteMapping @DeleteMapping
public void removeItem(@RequestBody String secret, HttpSession session) { public void removeItem(@RequestBody String secret, HttpSession session) {
@ -103,8 +108,10 @@ public class ItemController extends BaseController {
} }
/** /**
* Redeem.
* *
* @return * @param session the session
* @return the item result model
*/ */
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@PostMapping @PostMapping
@ -121,9 +128,10 @@ public class ItemController extends BaseController {
} }
/** /**
* Redeem for user.
* *
* @param username * @param username the username
* @param session * @param session the session
*/ */
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@PostMapping("/{username}") @PostMapping("/{username}")

View File

@ -19,9 +19,7 @@ import de.bstly.we.controller.support.TokenSessionManager;
import de.bstly.we.model.Permission; import de.bstly.we.model.Permission;
/** /**
* * The Class PermissionController.
* @author _bastler@bstly.de
*
*/ */
@RestController @RestController
@RequestMapping("/permissions") @RequestMapping("/permissions")
@ -33,8 +31,9 @@ public class PermissionController extends BaseController {
private TokenSessionManager tokenSessionManager; private TokenSessionManager tokenSessionManager;
/** /**
* Gets the permissions.
* *
* @return * @return the permissions
*/ */
@GetMapping @GetMapping
public List<Permission> getPermissions() { public List<Permission> getPermissions() {
@ -46,8 +45,10 @@ public class PermissionController extends BaseController {
} }
/** /**
* Gets the new permissions.
* *
* @return * @param session the session
* @return the new permissions
*/ */
@GetMapping("/new") @GetMapping("/new")
public List<Permission> getNewPermissions(HttpSession session) { public List<Permission> getNewPermissions(HttpSession session) {
@ -66,8 +67,9 @@ public class PermissionController extends BaseController {
} }
/** /**
* Gets the all permissions.
* *
* @return * @return the all permissions
*/ */
@GetMapping("/all") @GetMapping("/all")
public List<Permission> getAllPermissions() { public List<Permission> getAllPermissions() {

View File

@ -24,9 +24,7 @@ import de.bstly.we.model.Permission;
import de.bstly.we.model.User; import de.bstly.we.model.User;
/** /**
* * The Class PermissionManagementController.
* @author _bastler@bstly.de
*
*/ */
@RestController @RestController
@RequestMapping("/permissions/manage") @RequestMapping("/permissions/manage")
@ -38,9 +36,10 @@ public class PermissionManagementController extends BaseController {
private UserManager userManager; private UserManager userManager;
/** /**
* Gets the permissions for user.
* *
* @param username * @param username the username
* @return * @return the permissions for user
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping("/{username}") @GetMapping("/{username}")
@ -55,9 +54,10 @@ public class PermissionManagementController extends BaseController {
} }
/** /**
* Gets the all permissions for user.
* *
* @param username * @param username the username
* @return * @return the all permissions for user
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping("/{username}/all") @GetMapping("/{username}/all")
@ -72,9 +72,10 @@ public class PermissionManagementController extends BaseController {
} }
/** /**
* Creates the permission.
* *
* @param permission * @param permission the permission
* @return * @return the permission
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping @PostMapping
@ -84,9 +85,10 @@ public class PermissionManagementController extends BaseController {
} }
/** /**
* Update permission.
* *
* @param permission * @param permission the permission
* @return * @return the permission
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PatchMapping @PatchMapping
@ -99,10 +101,11 @@ public class PermissionManagementController extends BaseController {
} }
/** /**
* Clone.
* *
* @param name * @param name the name
* @param clone * @param clone the clone
* @return * @return the list
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping("/{name}/clone/{clone}") @PostMapping("/{name}/clone/{clone}")
@ -116,8 +119,9 @@ public class PermissionManagementController extends BaseController {
} }
/** /**
* Delete permission.
* *
* @param permission * @param permission the permission
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@DeleteMapping @DeleteMapping
@ -131,8 +135,9 @@ public class PermissionManagementController extends BaseController {
} }
/** /**
* Delete all.
* *
* @param target * @param target the target
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@DeleteMapping("/{target}") @DeleteMapping("/{target}")
@ -141,8 +146,9 @@ public class PermissionManagementController extends BaseController {
} }
/** /**
* Delete all by name.
* *
* @param name * @param name the name
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@DeleteMapping("/byname/{name}") @DeleteMapping("/byname/{name}")

View File

@ -29,9 +29,7 @@ import de.bstly.we.controller.validation.PermissionMappingValidator;
import de.bstly.we.model.PermissionMapping; import de.bstly.we.model.PermissionMapping;
/** /**
* * The Class PermissionMappingController.
* @author _bastler@bstly.de
*
*/ */
@RestController @RestController
@RequestMapping("/permissions/mappings") @RequestMapping("/permissions/mappings")
@ -43,10 +41,11 @@ public class PermissionMappingController extends BaseController {
private PermissionMappingValidator permissionMappingValidator; private PermissionMappingValidator permissionMappingValidator;
/** /**
* Gets the permission mappings.
* *
* @param pageParameter * @param pageParameter the page parameter
* @param sizeParameter * @param sizeParameter the size parameter
* @return * @return the permission mappings
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping @GetMapping
@ -57,9 +56,10 @@ public class PermissionMappingController extends BaseController {
} }
/** /**
* Creates the.
* *
* @param permissionMapping * @param permissionMapping the permission mapping
* @return * @return the permission mapping
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping @PostMapping
@ -78,9 +78,10 @@ public class PermissionMappingController extends BaseController {
} }
/** /**
* Creates the list.
* *
* @param permissionMappings * @param permissionMappings the permission mappings
* @return * @return the list
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping("/list") @PostMapping("/list")
@ -104,9 +105,10 @@ public class PermissionMappingController extends BaseController {
} }
/** /**
* Update.
* *
* @param permissionMapping * @param permissionMapping the permission mapping
* @return * @return the permission mapping
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PatchMapping @PatchMapping
@ -120,9 +122,10 @@ public class PermissionMappingController extends BaseController {
} }
/** /**
* Update list.
* *
* @param permissionMappings * @param permissionMappings the permission mappings
* @return * @return the list
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PatchMapping("/list") @PatchMapping("/list")
@ -141,8 +144,9 @@ public class PermissionMappingController extends BaseController {
} }
/** /**
* Delete.
* *
* @param permissionMapping * @param permissionMapping the permission mapping
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@DeleteMapping @DeleteMapping

View File

@ -27,9 +27,7 @@ import de.bstly.we.controller.model.PretixRequest;
import de.bstly.we.controller.support.EntityResponseStatusException; import de.bstly.we.controller.support.EntityResponseStatusException;
/** /**
* * The Class PretixApiController.
* @author _bastler@bstly.de
*
*/ */
@RestController @RestController
@RequestMapping("/pretix") @RequestMapping("/pretix")
@ -40,11 +38,12 @@ public class PretixApiController extends BaseController {
private Gson gson = new Gson(); private Gson gson = new Gson();
/** /**
* Debug.
* *
* @param pretixRequest * @param pretixRequest the pretix request
* @return * @param response the response
* @throws IOException * @throws JsonIOException the json IO exception
* @throws JsonIOException * @throws IOException Signals that an I/O exception has occurred.
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping("/debug") @PostMapping("/debug")

View File

@ -20,9 +20,7 @@ import de.bstly.we.model.Quota;
import de.bstly.we.model.QuotaMapping; import de.bstly.we.model.QuotaMapping;
/** /**
* * The Class QuotaController.
* @author _bastler@bstly.de
*
*/ */
@RestController @RestController
@RequestMapping("/quotas") @RequestMapping("/quotas")
@ -34,8 +32,9 @@ public class QuotaController extends BaseController {
private TokenSessionManager tokenSessionManager; private TokenSessionManager tokenSessionManager;
/** /**
* Gets the quotas.
* *
* @return * @return the quotas
*/ */
@GetMapping @GetMapping
public List<Quota> getQuotas() { public List<Quota> getQuotas() {
@ -47,8 +46,10 @@ public class QuotaController extends BaseController {
} }
/** /**
* Gets the new quotas.
* *
* @return * @param session the session
* @return the new quotas
*/ */
@GetMapping("/new") @GetMapping("/new")
public List<Quota> getNewQuotas(HttpSession session) { public List<Quota> getNewQuotas(HttpSession session) {
@ -99,8 +100,9 @@ public class QuotaController extends BaseController {
} }
/** /**
* Gets the all quotas.
* *
* @return * @return the all quotas
*/ */
@GetMapping("/all") @GetMapping("/all")
public List<Quota> getAllQuotas() { public List<Quota> getAllQuotas() {

View File

@ -26,9 +26,7 @@ import de.bstly.we.model.Quota;
import de.bstly.we.model.User; import de.bstly.we.model.User;
/** /**
* * The Class QuotaManagementController.
* @author _bastler@bstly.de
*
*/ */
@RestController @RestController
@RequestMapping("/quotas/manage") @RequestMapping("/quotas/manage")
@ -40,9 +38,10 @@ public class QuotaManagementController extends BaseController {
private UserManager userManager; private UserManager userManager;
/** /**
* Gets the quotas for user.
* *
* @param username * @param username the username
* @return * @return the quotas for user
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping("/{username}") @GetMapping("/{username}")
@ -57,9 +56,10 @@ public class QuotaManagementController extends BaseController {
} }
/** /**
* Gets the all quotas for user.
* *
* @param username * @param username the username
* @return * @return the all quotas for user
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping("/{username}/all") @GetMapping("/{username}/all")
@ -74,9 +74,10 @@ public class QuotaManagementController extends BaseController {
} }
/** /**
* Gets the quotas by name.
* *
* @param name * @param name the name
* @return * @return the quotas by name
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping("/byname/{name}") @GetMapping("/byname/{name}")
@ -85,9 +86,10 @@ public class QuotaManagementController extends BaseController {
} }
/** /**
* Creates the quota.
* *
* @param quota * @param quota the quota
* @return * @return the quota
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping @PostMapping
@ -101,9 +103,10 @@ public class QuotaManagementController extends BaseController {
} }
/** /**
* Update quota.
* *
* @param quota * @param quota the quota
* @return * @return the quota
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PatchMapping @PatchMapping
@ -116,9 +119,10 @@ public class QuotaManagementController extends BaseController {
} }
/** /**
* Update quota list.
* *
* @param quotas * @param quotas the quotas
* @return * @return the list
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PatchMapping("/list") @PatchMapping("/list")
@ -137,10 +141,12 @@ public class QuotaManagementController extends BaseController {
} }
/** /**
* Clone.
* *
* @param name * @param name the name
* @param clone * @param clone the clone
* @return * @param value the value
* @return the list
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping("/{name}/clone/{clone}") @PostMapping("/{name}/clone/{clone}")
@ -154,8 +160,9 @@ public class QuotaManagementController extends BaseController {
} }
/** /**
* Delete quota.
* *
* @param quota * @param quota the quota
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@DeleteMapping @DeleteMapping
@ -168,8 +175,9 @@ public class QuotaManagementController extends BaseController {
} }
/** /**
* Delete all.
* *
* @param target * @param target the target
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@DeleteMapping("/{target}") @DeleteMapping("/{target}")
@ -178,8 +186,9 @@ public class QuotaManagementController extends BaseController {
} }
/** /**
* Delete all by name.
* *
* @param name * @param name the name
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@DeleteMapping("/byname/{name}") @DeleteMapping("/byname/{name}")

View File

@ -29,9 +29,7 @@ import de.bstly.we.controller.validation.QuotaMappingValidator;
import de.bstly.we.model.QuotaMapping; import de.bstly.we.model.QuotaMapping;
/** /**
* * The Class QuotaMappingController.
* @author _bastler@bstly.de
*
*/ */
@RestController @RestController
@RequestMapping("/quotas/mappings") @RequestMapping("/quotas/mappings")
@ -43,10 +41,11 @@ public class QuotaMappingController extends BaseController {
private QuotaMappingValidator quotaMappingValidator; private QuotaMappingValidator quotaMappingValidator;
/** /**
* Gets the quota mappings.
* *
* @param pageParameter * @param pageParameter the page parameter
* @param sizeParameter * @param sizeParameter the size parameter
* @return * @return the quota mappings
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping @GetMapping
@ -58,9 +57,10 @@ public class QuotaMappingController extends BaseController {
} }
/** /**
* Creates the.
* *
* @param userModel * @param quotaMapping the quota mapping
* @return * @return the quota mapping
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping @PostMapping
@ -80,9 +80,10 @@ public class QuotaMappingController extends BaseController {
} }
/** /**
* Creates the list.
* *
* @param userModel * @param quotaMappings the quota mappings
* @return * @return the list
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping("/list") @PostMapping("/list")
@ -106,9 +107,10 @@ public class QuotaMappingController extends BaseController {
} }
/** /**
* Update.
* *
* @param userModel * @param quotaMapping the quota mapping
* @return * @return the quota mapping
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PatchMapping @PatchMapping
@ -124,9 +126,9 @@ public class QuotaMappingController extends BaseController {
} }
/** /**
* Delete.
* *
* @param userModel * @param quotaMapping the quota mapping
* @return
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@DeleteMapping @DeleteMapping

View File

@ -26,9 +26,7 @@ import de.bstly.we.model.SystemProperty;
import de.bstly.we.repository.SystemPropertyRepository; import de.bstly.we.repository.SystemPropertyRepository;
/** /**
* * The Class SystemController.
* @author _bastler@bstly.de
*
*/ */
@RestController @RestController
@RequestMapping("/system") @RequestMapping("/system")
@ -40,7 +38,7 @@ public class SystemController extends BaseController {
private PretixManager pretixManager; private PretixManager pretixManager;
/** /**
* * Update pretix client.
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping("/pretix") @PostMapping("/pretix")
@ -49,10 +47,11 @@ public class SystemController extends BaseController {
} }
/** /**
* Gets the properties.
* *
* @param pageParameter * @param pageParameter the page parameter
* @param sizeParameter * @param sizeParameter the size parameter
* @return * @return the properties
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping("/properties") @GetMapping("/properties")
@ -65,9 +64,10 @@ public class SystemController extends BaseController {
} }
/** /**
* Gets the property.
* *
* @param key * @param key the key
* @return * @return the property
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping("/properties/{key}") @GetMapping("/properties/{key}")
@ -80,9 +80,10 @@ public class SystemController extends BaseController {
} }
/** /**
* Creates the or update.
* *
* @param systemProperty * @param systemProperty the system property
* @return * @return the system property
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping("/properties") @PostMapping("/properties")
@ -91,9 +92,9 @@ public class SystemController extends BaseController {
} }
/** /**
* Delete property.
* *
* @param key * @param key the key
* @return
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@DeleteMapping("/properties/{key}") @DeleteMapping("/properties/{key}")

View File

@ -26,8 +26,7 @@ import de.bstly.we.controller.support.EntityResponseStatusException;
import de.bstly.we.model.SystemProfileField; import de.bstly.we.model.SystemProfileField;
/** /**
* @author _bastler@bstly.de * The Class SystemProfileFieldController.
*
*/ */
@RestController @RestController
@RequestMapping("/profiles/system") @RequestMapping("/profiles/system")
@ -37,10 +36,11 @@ public class SystemProfileFieldController extends BaseController {
private SystemProfileFieldManager systemProfileFieldManager; private SystemProfileFieldManager systemProfileFieldManager;
/** /**
* Gets the.
* *
* @param pageParameter * @param pageParameter the page parameter
* @param sizeParameter * @param sizeParameter the size parameter
* @return * @return the page
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping @GetMapping
@ -51,9 +51,10 @@ public class SystemProfileFieldController extends BaseController {
} }
/** /**
* Gets the by name.
* *
* @param name * @param name the name
* @return * @return the by name
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping("/{name}") @GetMapping("/{name}")
@ -68,9 +69,10 @@ public class SystemProfileFieldController extends BaseController {
} }
/** /**
* Update.
* *
* @param systemProfileField * @param systemProfileField the system profile field
* @return * @return the system profile field
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping @PostMapping
@ -79,9 +81,10 @@ public class SystemProfileFieldController extends BaseController {
} }
/** /**
* Update list.
* *
* @param systemProfileField * @param systemProfileFields the system profile fields
* @return * @return the list
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping("/list") @PostMapping("/list")
@ -97,8 +100,9 @@ public class SystemProfileFieldController extends BaseController {
} }
/** /**
* Delete by name.
* *
* @param name * @param name the name
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@DeleteMapping("/{name}") @DeleteMapping("/{name}")

View File

@ -29,8 +29,7 @@ import de.bstly.we.model.Quota;
import de.bstly.we.model.UserAlias; import de.bstly.we.model.UserAlias;
/** /**
* @author _bastler@bstly.de * The Class UserAliasController.
*
*/ */
@RestController @RestController
@RequestMapping("/users/aliases") @RequestMapping("/users/aliases")
@ -46,9 +45,10 @@ public class UserAliasController extends BaseController {
private PermissionManager permissionManager; private PermissionManager permissionManager;
/** /**
* Creates the alias.
* *
* @param alias * @param userAlias the user alias
* @return * @return the user alias
*/ */
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@PostMapping @PostMapping
@ -78,9 +78,10 @@ public class UserAliasController extends BaseController {
} }
/** /**
* Update alias.
* *
* @param alias * @param userAlias the user alias
* @return * @return the user alias
*/ */
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@PatchMapping @PatchMapping
@ -105,8 +106,9 @@ public class UserAliasController extends BaseController {
} }
/** /**
* Gets the aliases.
* *
* @return * @return the aliases
*/ */
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@GetMapping @GetMapping
@ -115,8 +117,9 @@ public class UserAliasController extends BaseController {
} }
/** /**
* Delete alias.
* *
* @param id * @param id the id
*/ */
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@DeleteMapping("/{id}") @DeleteMapping("/{id}")

View File

@ -29,8 +29,7 @@ import de.bstly.we.model.User;
import de.bstly.we.model.UserAlias; import de.bstly.we.model.UserAlias;
/** /**
* @author _bastler@bstly.de * The Class UserAliasManagementController.
*
*/ */
@RestController @RestController
@RequestMapping("/users/aliases/manage") @RequestMapping("/users/aliases/manage")
@ -44,8 +43,11 @@ public class UserAliasManagementController extends BaseController {
private UserAliasValidator userAliasValidator; private UserAliasValidator userAliasValidator;
/** /**
* Gets the aliases.
* *
* @return * @param pageParameter the page parameter
* @param sizeParameter the size parameter
* @return the aliases
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping @GetMapping
@ -55,8 +57,10 @@ public class UserAliasManagementController extends BaseController {
} }
/** /**
* Gets the aliases for user.
* *
* @return * @param username the username
* @return the aliases for user
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping("/{username}") @GetMapping("/{username}")
@ -71,9 +75,10 @@ public class UserAliasManagementController extends BaseController {
} }
/** /**
* Creates the or update alias.
* *
* @param alias * @param userAlias the user alias
* @return * @return the user alias
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping @PostMapping
@ -89,8 +94,9 @@ public class UserAliasManagementController extends BaseController {
} }
/** /**
* Delete alias.
* *
* @param id * @param id the id
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@DeleteMapping("/{id}") @DeleteMapping("/{id}")

View File

@ -43,9 +43,7 @@ import de.bstly.we.model.Visibility;
import de.bstly.we.model.UserStatus; import de.bstly.we.model.UserStatus;
/** /**
* * The Class UserController.
* @author _bastler@bstly.de
*
*/ */
@RestController @RestController
@RequestMapping("/users") @RequestMapping("/users")
@ -73,8 +71,9 @@ public class UserController extends BaseController {
private PasswordEncoder passwordEncoder; private PasswordEncoder passwordEncoder;
/** /**
* Gets the.
* *
* @return * @return the user model
*/ */
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@GetMapping @GetMapping
@ -87,10 +86,11 @@ public class UserController extends BaseController {
} }
/** /**
* Check model.
* *
* @param userModel * @param userModel the user model
* @param session * @param session the session
* @return * @return the user model
*/ */
@PostMapping("/model") @PostMapping("/model")
public UserModel checkModel(@RequestBody UserModel userModel, HttpSession session) { public UserModel checkModel(@RequestBody UserModel userModel, HttpSession session) {
@ -105,10 +105,11 @@ public class UserController extends BaseController {
} }
/** /**
* Register.
* *
* @param userModel * @param userModel the user model
* @param session * @param session the session
* @return * @return the user model
*/ */
@PreAuthorize("isAnonymous()") @PreAuthorize("isAnonymous()")
@PostMapping @PostMapping
@ -197,8 +198,9 @@ public class UserController extends BaseController {
} }
/** /**
* Change password.
* *
* @param passwordModel * @param passwordModel the password model
*/ */
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@PatchMapping("/password") @PatchMapping("/password")
@ -223,8 +225,9 @@ public class UserController extends BaseController {
} }
/** /**
* Update.
* *
* @param userModel * @param userModel the user model
*/ */
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@PatchMapping @PatchMapping

View File

@ -28,8 +28,7 @@ import de.bstly.we.model.UserDomain;
import de.bstly.we.model.Visibility; import de.bstly.we.model.Visibility;
/** /**
* @author _bastler@bstly.de * The Class UserDomainController.
*
*/ */
@RestController @RestController
@RequestMapping("/users/domains") @RequestMapping("/users/domains")
@ -43,9 +42,10 @@ public class UserDomainController extends BaseController {
private PermissionManager permissionManager; private PermissionManager permissionManager;
/** /**
* Creates the domain.
* *
* @param userDomain * @param userDomain the user domain
* @return * @return the user domain
*/ */
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@PostMapping @PostMapping
@ -75,9 +75,10 @@ public class UserDomainController extends BaseController {
} }
/** /**
* Update domain.
* *
* @param userDomain * @param userDomain the user domain
* @return * @return the user domain
*/ */
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@PatchMapping @PatchMapping
@ -102,8 +103,9 @@ public class UserDomainController extends BaseController {
} }
/** /**
* Gets the domains.
* *
* @return * @return the domains
*/ */
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@GetMapping @GetMapping
@ -112,8 +114,9 @@ public class UserDomainController extends BaseController {
} }
/** /**
* Delete domain.
* *
* @param id * @param id the id
*/ */
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@DeleteMapping("/{id}") @DeleteMapping("/{id}")

View File

@ -33,8 +33,7 @@ import de.bstly.we.model.UserDomain;
import de.bstly.we.model.Visibility; import de.bstly.we.model.Visibility;
/** /**
* @author _bastler@bstly.de * The Class UserDomainManagementController.
*
*/ */
@RestController @RestController
@RequestMapping("/users/domains/manage") @RequestMapping("/users/domains/manage")
@ -48,8 +47,11 @@ public class UserDomainManagementController extends BaseController {
private UserDomainValidator userDomainValidator; private UserDomainValidator userDomainValidator;
/** /**
* Gets the domains.
* *
* @return * @param pageParameter the page parameter
* @param sizeParameter the size parameter
* @return the domains
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping @GetMapping
@ -59,8 +61,10 @@ public class UserDomainManagementController extends BaseController {
} }
/** /**
* Gets the domains for user.
* *
* @return * @param username the username
* @return the domains for user
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping("/{username}") @GetMapping("/{username}")
@ -75,9 +79,10 @@ public class UserDomainManagementController extends BaseController {
} }
/** /**
* Creates the or update domain.
* *
* @param alias * @param userDomain the user domain
* @return * @return the user domain
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping @PostMapping
@ -103,8 +108,9 @@ public class UserDomainManagementController extends BaseController {
} }
/** /**
* Delete domain.
* *
* @param id * @param id the id
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@DeleteMapping("/{id}") @DeleteMapping("/{id}")
@ -117,8 +123,9 @@ public class UserDomainManagementController extends BaseController {
} }
/** /**
* Validate.
* *
* @param id * @param id the id
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping("/validate/{id}") @PostMapping("/validate/{id}")

View File

@ -46,9 +46,7 @@ import de.bstly.we.model.UserStatus;
import de.bstly.we.model.Visibility; import de.bstly.we.model.Visibility;
/** /**
* * The Class UserManagementController.
* @author _bastler@bstly.de
*
*/ */
@RestController @RestController
@RequestMapping("/users/manage") @RequestMapping("/users/manage")
@ -72,10 +70,11 @@ public class UserManagementController extends BaseController {
private UserDataManager userDataManager; private UserDataManager userDataManager;
/** /**
* Gets the users.
* *
* @param pageParameter * @param pageParameter the page parameter
* @param sizeParameter * @param sizeParameter the size parameter
* @return * @return the users
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping @GetMapping
@ -85,9 +84,10 @@ public class UserManagementController extends BaseController {
} }
/** /**
* Gets the user by username.
* *
* @param username * @param username the username
* @return * @return the user by username
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping("/{username}") @GetMapping("/{username}")
@ -102,9 +102,10 @@ public class UserManagementController extends BaseController {
} }
/** /**
* Creates the.
* *
* @param userModel * @param userModel the user model
* @return * @return the user
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping @PostMapping
@ -180,9 +181,10 @@ public class UserManagementController extends BaseController {
} }
/** /**
* Update.
* *
* @param user * @param user the user
* @return * @return the user
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PatchMapping @PatchMapping
@ -191,8 +193,9 @@ public class UserManagementController extends BaseController {
} }
/** /**
* Delete user by username.
* *
* @param username * @param username the username
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@DeleteMapping("/{username}") @DeleteMapping("/{username}")
@ -207,7 +210,10 @@ public class UserManagementController extends BaseController {
} }
/** /**
* Purge.
* *
* @param username the username
* @param dry the dry
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping("/purge") @PostMapping("/purge")

View File

@ -37,8 +37,7 @@ import de.bstly.we.model.UserProfileField;
import de.bstly.we.model.Visibility; import de.bstly.we.model.Visibility;
/** /**
* @author _bastler@bstly.de * The Class UserProfileFieldController.
*
*/ */
@RestController @RestController
@RequestMapping("/profiles") @RequestMapping("/profiles")
@ -56,8 +55,10 @@ public class UserProfileFieldController extends BaseController {
private PermissionManager permissionManager; private PermissionManager permissionManager;
/** /**
* Gets the.
* *
* @return * @param filter the filter
* @return the list
*/ */
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@GetMapping @GetMapping
@ -71,8 +72,10 @@ public class UserProfileFieldController extends BaseController {
} }
/** /**
* Gets the field.
* *
* @return * @param name the name
* @return the field
*/ */
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@GetMapping("/field/{name}") @GetMapping("/field/{name}")
@ -87,8 +90,10 @@ public class UserProfileFieldController extends BaseController {
} }
/** /**
* Gets the for user.
* *
* @return * @param username the username
* @return the for user
*/ */
@GetMapping("/{username}") @GetMapping("/{username}")
public ProfileModel getForUser(@PathVariable("username") String username) { public ProfileModel getForUser(@PathVariable("username") String username) {
@ -170,8 +175,11 @@ public class UserProfileFieldController extends BaseController {
} }
/** /**
* Gets the field for user.
* *
* @return * @param username the username
* @param name the name
* @return the field for user
*/ */
@GetMapping("/{username}/field/{name}") @GetMapping("/{username}/field/{name}")
public UserProfileField getFieldForUser(@PathVariable("username") String username, public UserProfileField getFieldForUser(@PathVariable("username") String username,
@ -204,9 +212,10 @@ public class UserProfileFieldController extends BaseController {
} }
/** /**
* Creates the orupdate.
* *
* @param userProfileField * @param userProfileField the user profile field
* @return * @return the user profile field
*/ */
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@PostMapping @PostMapping
@ -257,8 +266,9 @@ public class UserProfileFieldController extends BaseController {
} }
/** /**
* Delete.
* *
* @param name * @param name the name
*/ */
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@DeleteMapping("/{name}") @DeleteMapping("/{name}")
@ -271,7 +281,7 @@ public class UserProfileFieldController extends BaseController {
} }
/** /**
* * Throttle forbidden.
*/ */
protected void throttleForbidden() { protected void throttleForbidden() {
try { try {

View File

@ -3,24 +3,28 @@
*/ */
package de.bstly.we.controller; package de.bstly.we.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.beust.jcommander.internal.Lists;
import de.bstly.we.businesslogic.PermissionManager; import de.bstly.we.businesslogic.PermissionManager;
import de.bstly.we.businesslogic.PretixManager;
import de.bstly.we.businesslogic.QuotaManager; import de.bstly.we.businesslogic.QuotaManager;
import de.bstly.we.businesslogic.Quotas; import de.bstly.we.businesslogic.VoucherMappingManager;
import de.bstly.we.controller.support.EntityResponseStatusException; import de.bstly.we.controller.support.EntityResponseStatusException;
import de.bstly.we.model.Quota; import de.bstly.we.model.Quota;
import de.bstly.we.model.VoucherMapping;
/** /**
* * The Class VoucherController.
* @author _bastler@bstly.de
*
*/ */
@RestController @RestController
@RequestMapping("/vouchers") @RequestMapping("/vouchers")
@ -29,47 +33,72 @@ public class VoucherController extends BaseController {
@Autowired @Autowired
private QuotaManager quotaManager; private QuotaManager quotaManager;
@Autowired @Autowired
private PretixManager pretixManager; private VoucherMappingManager voucherMappingManager;
@Autowired @Autowired
private PermissionManager permissionManager; private PermissionManager permissionManager;
/** /**
* Available.
* *
* @return * @return the list
*/ */
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@PostMapping("/registration") @GetMapping()
public String getRegistrationVoucher() { public List<String> available() {
Quota registrationVouchers = quotaManager.get(getCurrentUserId(),
Quotas.REGISTRATION_VOUCHERS);
if (registrationVouchers == null || registrationVouchers.getValue() < 1) {
throw new EntityResponseStatusException(HttpStatus.CONFLICT);
}
if (!permissionManager.isFullUser(getCurrentUserId())) { if (!permissionManager.isFullUser(getCurrentUserId())) {
throw new EntityResponseStatusException(HttpStatus.FORBIDDEN); throw new EntityResponseStatusException(HttpStatus.FORBIDDEN);
} }
String result = pretixManager.createRegistrationVoucher().get("code").getAsString(); List<String> available = Lists.newArrayList();
registrationVouchers.setValue(registrationVouchers.getValue() - 1); for (VoucherMapping voucherMapping : voucherMappingManager.getForUser(getCurrentUserId())) {
quotaManager.update(registrationVouchers); available.add(voucherMapping.getName());
}
return available;
}
/**
* Gets the voucher.
*
* @param name the name
* @return the voucher
*/
@PreAuthorize("isAuthenticated()")
@PostMapping("/{name}")
public String getVoucher(@PathVariable("name") String name) {
if (!permissionManager.isFullUser(getCurrentUserId())) {
throw new EntityResponseStatusException(HttpStatus.FORBIDDEN);
}
VoucherMapping voucherMapping = voucherMappingManager.get(name);
if (voucherMapping == null) {
throw new EntityResponseStatusException(HttpStatus.FORBIDDEN);
}
Quota quota = null;
if (!voucherMapping.isFree()) {
quota = quotaManager.get(getCurrentUserId(), voucherMapping.getQuota());
if (quota == null || quota.getValue() < 1) {
throw new EntityResponseStatusException(HttpStatus.CONFLICT);
}
}
String result = "";
try {
result = voucherMappingManager.createVoucher(voucherMapping.getVoucher());
} catch (Exception e) {
throw new EntityResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR);
}
if (quota != null) {
quota.setValue(quota.getValue() - 1);
quotaManager.update(quota);
}
return result; return result;
} }
/**
*
* @return
*/
@PreAuthorize("isAuthenticated()")
@PostMapping("/addon")
public String getAddonVoucher() {
if (!permissionManager.isFullUser(getCurrentUserId())) {
throw new EntityResponseStatusException(HttpStatus.FORBIDDEN);
}
return pretixManager.createAddOnVoucher().get("code").getAsString();
}
} }

View File

@ -0,0 +1,137 @@
/**
*
*/
package de.bstly.we.controller;
import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.google.common.collect.Lists;
import de.bstly.we.businesslogic.VoucherMappingManager;
import de.bstly.we.controller.support.EntityResponseStatusException;
import de.bstly.we.controller.support.RequestBodyErrors;
import de.bstly.we.controller.validation.VoucherMappingValidator;
import de.bstly.we.model.VoucherMapping;
/**
* The Class VoucherMappingController.
*/
@RestController
@RequestMapping("/vouchers/mappings")
public class VoucherMappingController extends BaseController {
@Autowired
private VoucherMappingManager voucherMappingManager;
@Autowired
private VoucherMappingValidator voucherMappingValidator;
/**
* Gets the voucher mappings.
*
* @param pageParameter the page parameter
* @param sizeParameter the size parameter
* @return the voucher mappings
*/
@PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping
public Page<VoucherMapping> getVoucherMappings(
@RequestParam("page") Optional<Integer> pageParameter,
@RequestParam("size") Optional<Integer> sizeParameter) {
return voucherMappingManager.get(pageParameter.orElse(0), sizeParameter.orElse(10), "name",
true);
}
/**
* Creates the.
*
* @param voucherMapping the voucher mapping
* @return the voucher mapping
*/
@PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping
public VoucherMapping create(@RequestBody VoucherMapping voucherMapping) {
Errors errors = new RequestBodyErrors(voucherMapping);
voucherMappingValidator.validate(voucherMapping, errors);
if (errors.hasErrors()) {
throw new EntityResponseStatusException(errors.getAllErrors(), HttpStatus.CONFLICT);
}
return voucherMappingManager.create(voucherMapping.getName(), voucherMapping.getVoucher(),
voucherMapping.getQuota(), voucherMapping.isFree());
}
/**
* Creates the list.
*
* @param voucherMappings the voucher mappings
* @return the list
*/
@PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping("/list")
public List<VoucherMapping> createList(@RequestBody List<VoucherMapping> voucherMappings) {
List<VoucherMapping> result = Lists.newArrayList();
for (VoucherMapping voucherMapping : voucherMappings) {
Errors errors = new RequestBodyErrors(voucherMapping);
voucherMappingValidator.validate(voucherMapping, errors);
if (errors.hasErrors()) {
throw new EntityResponseStatusException(errors.getAllErrors(), HttpStatus.CONFLICT);
}
result.add(voucherMappingManager.create(voucherMapping.getName(),
voucherMapping.getVoucher(), voucherMapping.getQuota(),
voucherMapping.isFree()));
}
return result;
}
/**
* Update.
*
* @param voucherMapping the voucher mapping
* @return the voucher mapping
*/
@PreAuthorize("hasRole('ROLE_ADMIN')")
@PatchMapping
public VoucherMapping update(@RequestBody VoucherMapping voucherMapping) {
Errors errors = new RequestBodyErrors(voucherMapping);
if (errors.hasErrors()) {
throw new EntityResponseStatusException(errors.getAllErrors(), HttpStatus.CONFLICT);
}
return voucherMappingManager.update(voucherMapping);
}
/**
* Delete.
*
* @param voucherMapping the voucher mapping
*/
@PreAuthorize("hasRole('ROLE_ADMIN')")
@DeleteMapping
public void delete(@RequestBody VoucherMapping voucherMapping) {
voucherMappingManager.delete(voucherMapping.getId());
}
}

View File

@ -22,8 +22,7 @@ import de.bstly.we.model.User;
import de.bstly.we.repository.UserRepository; import de.bstly.we.repository.UserRepository;
/** /**
* @author _bastler@bstly.de * The Class MigrationController.
*
*/ */
@RestController @RestController
@RequestMapping("/migration") @RequestMapping("/migration")
@ -35,7 +34,7 @@ public class MigrationController extends BaseController {
private FindByIndexNameSessionRepository<? extends Session> sessionRepository; private FindByIndexNameSessionRepository<? extends Session> sessionRepository;
/** /**
* * Delete all sessions.
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@DeleteMapping("/sessions") @DeleteMapping("/sessions")

View File

@ -6,8 +6,7 @@ package de.bstly.we.controller.model;
import java.util.Map; import java.util.Map;
/** /**
* @author _bastler@bstly.de * The Class ItemModel.
*
*/ */
public class ItemModel { public class ItemModel {
@ -15,6 +14,8 @@ public class ItemModel {
private String secret; private String secret;
/** /**
* Gets the name.
*
* @return the name * @return the name
*/ */
public Map<String, String> getName() { public Map<String, String> getName() {
@ -22,13 +23,17 @@ public class ItemModel {
} }
/** /**
* @param name the name to set * Sets the name.
*
* @param name the name
*/ */
public void setName(Map<String, String> name) { public void setName(Map<String, String> name) {
this.name = name; this.name = name;
} }
/** /**
* Gets the secret.
*
* @return the secret * @return the secret
*/ */
public String getSecret() { public String getSecret() {
@ -36,7 +41,9 @@ public class ItemModel {
} }
/** /**
* @param secret the secret to set * Sets the secret.
*
* @param secret the new secret
*/ */
public void setSecret(String secret) { public void setSecret(String secret) {
this.secret = secret; this.secret = secret;

View File

@ -9,8 +9,7 @@ import de.bstly.we.model.PermissionMapping;
import de.bstly.we.model.QuotaMapping; import de.bstly.we.model.QuotaMapping;
/** /**
* @author _bastler@bstly.de * The Class ItemResultModel.
*
*/ */
public class ItemResultModel { public class ItemResultModel {
@ -18,28 +17,36 @@ public class ItemResultModel {
private List<QuotaMapping> quotaMappings; private List<QuotaMapping> quotaMappings;
/** /**
* @return the permissionMappings * Gets the permission mappings.
*
* @return the permission mappings
*/ */
public List<PermissionMapping> getPermissionMappings() { public List<PermissionMapping> getPermissionMappings() {
return permissionMappings; return permissionMappings;
} }
/** /**
* @param permissionMappings the permissionMappings to set * Sets the permission mappings.
*
* @param permissionMappings the new permission mappings
*/ */
public void setPermissionMappings(List<PermissionMapping> permissionMappings) { public void setPermissionMappings(List<PermissionMapping> permissionMappings) {
this.permissionMappings = permissionMappings; this.permissionMappings = permissionMappings;
} }
/** /**
* @return the quotaMappings * Gets the quota mappings.
*
* @return the quota mappings
*/ */
public List<QuotaMapping> getQuotaMappings() { public List<QuotaMapping> getQuotaMappings() {
return quotaMappings; return quotaMappings;
} }
/** /**
* @param quotaMappings the quotaMappings to set * Sets the quota mappings.
*
* @param quotaMappings the new quota mappings
*/ */
public void setQuotaMappings(List<QuotaMapping> quotaMappings) { public void setQuotaMappings(List<QuotaMapping> quotaMappings) {
this.quotaMappings = quotaMappings; this.quotaMappings = quotaMappings;

View File

@ -4,9 +4,7 @@
package de.bstly.we.controller.model; package de.bstly.we.controller.model;
/** /**
* * The Class LoginModel.
* @author _bastler@bstly.de
*
*/ */
public class LoginModel { public class LoginModel {
@ -14,6 +12,8 @@ public class LoginModel {
private String password; private String password;
/** /**
* Gets the username.
*
* @return the username * @return the username
*/ */
public String getUsername() { public String getUsername() {
@ -21,13 +21,17 @@ public class LoginModel {
} }
/** /**
* @param username the username to set * Sets the username.
*
* @param username the new username
*/ */
public void setUsername(String username) { public void setUsername(String username) {
this.username = username; this.username = username;
} }
/** /**
* Gets the password.
*
* @return the password * @return the password
*/ */
public String getPassword() { public String getPassword() {
@ -35,7 +39,9 @@ public class LoginModel {
} }
/** /**
* @param password the password to set * Sets the password.
*
* @param password the new password
*/ */
public void setPassword(String password) { public void setPassword(String password) {
this.password = password; this.password = password;

View File

@ -6,8 +6,9 @@ package de.bstly.we.controller.model;
import java.util.List; import java.util.List;
/** /**
* @author _bastler@bstly.de * The Class PagesResult.
* *
* @param <T> the generic type
*/ */
public class PagesResult<T extends Object> { public class PagesResult<T extends Object> {
@ -18,6 +19,8 @@ public class PagesResult<T extends Object> {
private int totalPages; private int totalPages;
/** /**
* Gets the result.
*
* @return the result * @return the result
*/ */
public List<T> getResult() { public List<T> getResult() {
@ -25,13 +28,17 @@ public class PagesResult<T extends Object> {
} }
/** /**
* @param result the result to set * Sets the result.
*
* @param result the new result
*/ */
public void setResult(List<T> result) { public void setResult(List<T> result) {
this.result = result; this.result = result;
} }
/** /**
* Gets the size.
*
* @return the size * @return the size
*/ */
public int getSize() { public int getSize() {
@ -39,13 +46,17 @@ public class PagesResult<T extends Object> {
} }
/** /**
* @param size the size to set * Sets the size.
*
* @param size the new size
*/ */
public void setSize(int size) { public void setSize(int size) {
this.size = size; this.size = size;
} }
/** /**
* Gets the page.
*
* @return the page * @return the page
*/ */
public int getPage() { public int getPage() {
@ -53,35 +64,45 @@ public class PagesResult<T extends Object> {
} }
/** /**
* @param page the page to set * Sets the page.
*
* @param page the new page
*/ */
public void setPage(int page) { public void setPage(int page) {
this.page = page; this.page = page;
} }
/** /**
* @return the totalElements * Gets the total elements.
*
* @return the total elements
*/ */
public int getTotalElements() { public int getTotalElements() {
return totalElements; return totalElements;
} }
/** /**
* @param totalElements the totalElements to set * Sets the total elements.
*
* @param totalElements the new total elements
*/ */
public void setTotalElements(int totalElements) { public void setTotalElements(int totalElements) {
this.totalElements = totalElements; this.totalElements = totalElements;
} }
/** /**
* @return the totalPages * Gets the total pages.
*
* @return the total pages
*/ */
public int getTotalPages() { public int getTotalPages() {
return totalPages; return totalPages;
} }
/** /**
* @param totalPages the totalPages to set * Sets the total pages.
*
* @param totalPages the new total pages
*/ */
public void setTotalPages(int totalPages) { public void setTotalPages(int totalPages) {
this.totalPages = totalPages; this.totalPages = totalPages;

View File

@ -4,9 +4,7 @@
package de.bstly.we.controller.model; package de.bstly.we.controller.model;
/** /**
* * The Class PasswordModel.
* @author _bastler@bstly.de
*
*/ */
public class PasswordModel { public class PasswordModel {
@ -15,6 +13,8 @@ public class PasswordModel {
private String password2; private String password2;
/** /**
* Gets the old.
*
* @return the old * @return the old
*/ */
public String getOld() { public String getOld() {
@ -22,13 +22,17 @@ public class PasswordModel {
} }
/** /**
* @param old the old to set * Sets the old.
*
* @param old the new old
*/ */
public void setOld(String old) { public void setOld(String old) {
this.old = old; this.old = old;
} }
/** /**
* Gets the password.
*
* @return the password * @return the password
*/ */
public String getPassword() { public String getPassword() {
@ -36,21 +40,27 @@ public class PasswordModel {
} }
/** /**
* @param password the password to set * Sets the password.
*
* @param password the new password
*/ */
public void setPassword(String password) { public void setPassword(String password) {
this.password = password; this.password = password;
} }
/** /**
* @return the password2 * Gets the password 2.
*
* @return the password 2
*/ */
public String getPassword2() { public String getPassword2() {
return password2; return password2;
} }
/** /**
* @param password2 the password2 to set * Sets the password 2.
*
* @param password2 the new password 2
*/ */
public void setPassword2(String password2) { public void setPassword2(String password2) {
this.password2 = password2; this.password2 = password2;

View File

@ -4,14 +4,15 @@
package de.bstly.we.controller.model; package de.bstly.we.controller.model;
/** /**
* @author _bastler@bstly.de * The Class PasswordResetModel.
*
*/ */
public class PasswordResetModel extends PasswordModel { public class PasswordResetModel extends PasswordModel {
private String token; private String token;
/** /**
* Gets the token.
*
* @return the token * @return the token
*/ */
public String getToken() { public String getToken() {
@ -19,7 +20,9 @@ public class PasswordResetModel extends PasswordModel {
} }
/** /**
* @param token the token to set * Sets the token.
*
* @param token the new token
*/ */
public void setToken(String token) { public void setToken(String token) {
this.token = token; this.token = token;

View File

@ -8,9 +8,7 @@ import java.util.Map;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
/** /**
* * The Class PretixRequest.
* @author _bastler@bstly.de
*
*/ */
public class PretixRequest { public class PretixRequest {
@ -20,6 +18,8 @@ public class PretixRequest {
private Object payload; private Object payload;
/** /**
* Gets the path.
*
* @return the path * @return the path
*/ */
public String getPath() { public String getPath() {
@ -27,13 +27,17 @@ public class PretixRequest {
} }
/** /**
* @param path the path to set * Sets the path.
*
* @param path the new path
*/ */
public void setPath(String path) { public void setPath(String path) {
this.path = path; this.path = path;
} }
/** /**
* Gets the method.
*
* @return the method * @return the method
*/ */
public HttpMethod getMethod() { public HttpMethod getMethod() {
@ -41,27 +45,35 @@ public class PretixRequest {
} }
/** /**
* @param method the method to set * Sets the method.
*
* @param method the new method
*/ */
public void setMethod(HttpMethod method) { public void setMethod(HttpMethod method) {
this.method = method; this.method = method;
} }
/** /**
* @return the queryParameters * Gets the query parameters.
*
* @return the query parameters
*/ */
public Map<String, String> getQueryParameters() { public Map<String, String> getQueryParameters() {
return queryParameters; return queryParameters;
} }
/** /**
* @param queryParameters the queryParameters to set * Sets the query parameters.
*
* @param queryParameters the query parameters
*/ */
public void setQueryParameters(Map<String, String> queryParameters) { public void setQueryParameters(Map<String, String> queryParameters) {
this.queryParameters = queryParameters; this.queryParameters = queryParameters;
} }
/** /**
* Gets the payload.
*
* @return the payload * @return the payload
*/ */
public Object getPayload() { public Object getPayload() {
@ -69,7 +81,9 @@ public class PretixRequest {
} }
/** /**
* @param payload the payload to set * Sets the payload.
*
* @param payload the new payload
*/ */
public void setPayload(Object payload) { public void setPayload(Object payload) {
this.payload = payload; this.payload = payload;

View File

@ -8,8 +8,7 @@ import java.util.List;
import de.bstly.we.model.UserProfileField; import de.bstly.we.model.UserProfileField;
/** /**
* @author _bastler@bstly.de * The Class ProfileModel.
*
*/ */
public class ProfileModel { public class ProfileModel {
@ -18,6 +17,8 @@ public class ProfileModel {
private List<UserProfileField> profileFields; private List<UserProfileField> profileFields;
/** /**
* Gets the username.
*
* @return the username * @return the username
*/ */
public String getUsername() { public String getUsername() {
@ -25,13 +26,17 @@ public class ProfileModel {
} }
/** /**
* @param username the username to set * Sets the username.
*
* @param username the new username
*/ */
public void setUsername(String username) { public void setUsername(String username) {
this.username = username; this.username = username;
} }
/** /**
* Gets the aliases.
*
* @return the aliases * @return the aliases
*/ */
public List<String> getAliases() { public List<String> getAliases() {
@ -39,21 +44,27 @@ public class ProfileModel {
} }
/** /**
* @param aliases the aliases to set * Sets the aliases.
*
* @param aliases the new aliases
*/ */
public void setAliases(List<String> aliases) { public void setAliases(List<String> aliases) {
this.aliases = aliases; this.aliases = aliases;
} }
/** /**
* @return the profileFields * Gets the profile fields.
*
* @return the profile fields
*/ */
public List<UserProfileField> getProfileFields() { public List<UserProfileField> getProfileFields() {
return profileFields; return profileFields;
} }
/** /**
* @param profileFields the profileFields to set * Sets the profile fields.
*
* @param profileFields the new profile fields
*/ */
public void setProfileFields(List<UserProfileField> profileFields) { public void setProfileFields(List<UserProfileField> profileFields) {
this.profileFields = profileFields; this.profileFields = profileFields;

View File

@ -4,8 +4,7 @@
package de.bstly.we.controller.model; package de.bstly.we.controller.model;
/** /**
* @author _bastler@bstly.de * The Class SecondFactorProviderModel.
*
*/ */
public class SecondFactorProviderModel { public class SecondFactorProviderModel {
@ -13,8 +12,10 @@ public class SecondFactorProviderModel {
private boolean request; private boolean request;
/** /**
* @param provider * Instantiates a new second factor provider model.
* @param request *
* @param id the id
* @param request the request
*/ */
public SecondFactorProviderModel(String id, boolean request) { public SecondFactorProviderModel(String id, boolean request) {
super(); super();
@ -23,6 +24,8 @@ public class SecondFactorProviderModel {
} }
/** /**
* Gets the id.
*
* @return the id * @return the id
*/ */
public String getId() { public String getId() {
@ -30,21 +33,27 @@ public class SecondFactorProviderModel {
} }
/** /**
* @param id the id to set * Sets the id.
*
* @param id the new id
*/ */
public void setId(String id) { public void setId(String id) {
this.id = id; this.id = id;
} }
/** /**
* @return the request * Checks if is request.
*
* @return true, if is request
*/ */
public boolean isRequest() { public boolean isRequest() {
return request; return request;
} }
/** /**
* @param request the request to set * Sets the request.
*
* @param request the new request
*/ */
public void setRequest(boolean request) { public void setRequest(boolean request) {
this.request = request; this.request = request;

View File

@ -13,9 +13,7 @@ import de.bstly.we.model.UserProfileField;
import de.bstly.we.model.UserStatus; import de.bstly.we.model.UserStatus;
/** /**
* * The Class UserModel.
* @author _bastler@bstly.de
*
*/ */
public class UserModel extends PasswordModel { public class UserModel extends PasswordModel {
@ -29,6 +27,8 @@ public class UserModel extends PasswordModel {
private List<UserProfileField> profileFields; private List<UserProfileField> profileFields;
/** /**
* Gets the username.
*
* @return the username * @return the username
*/ */
public String getUsername() { public String getUsername() {
@ -36,13 +36,17 @@ public class UserModel extends PasswordModel {
} }
/** /**
* @param username the username to set * Sets the username.
*
* @param username the new username
*/ */
public void setUsername(String username) { public void setUsername(String username) {
this.username = username; this.username = username;
} }
/** /**
* Gets the permissions.
*
* @return the permissions * @return the permissions
*/ */
public List<Permission> getPermissions() { public List<Permission> getPermissions() {
@ -50,27 +54,35 @@ public class UserModel extends PasswordModel {
} }
/** /**
* @param permissions the permissions to set * Sets the permissions.
*
* @param permissions the new permissions
*/ */
public void setPermissions(List<Permission> permissions) { public void setPermissions(List<Permission> permissions) {
this.permissions = permissions; this.permissions = permissions;
} }
/** /**
* @return the permissionMappings * Gets the permission mappings.
*
* @return the permission mappings
*/ */
public List<PermissionMapping> getPermissionMappings() { public List<PermissionMapping> getPermissionMappings() {
return permissionMappings; return permissionMappings;
} }
/** /**
* @param permissionMappings the permissionMappings to set * Sets the permission mappings.
*
* @param permissionMappings the new permission mappings
*/ */
public void setPermissionMappings(List<PermissionMapping> permissionMappings) { public void setPermissionMappings(List<PermissionMapping> permissionMappings) {
this.permissionMappings = permissionMappings; this.permissionMappings = permissionMappings;
} }
/** /**
* Gets the quotas.
*
* @return the quotas * @return the quotas
*/ */
public List<Quota> getQuotas() { public List<Quota> getQuotas() {
@ -78,27 +90,35 @@ public class UserModel extends PasswordModel {
} }
/** /**
* @param quotas the quotas to set * Sets the quotas.
*
* @param quotas the new quotas
*/ */
public void setQuotas(List<Quota> quotas) { public void setQuotas(List<Quota> quotas) {
this.quotas = quotas; this.quotas = quotas;
} }
/** /**
* @return the quotaMappings * Gets the quota mappings.
*
* @return the quota mappings
*/ */
public List<QuotaMapping> getQuotaMappings() { public List<QuotaMapping> getQuotaMappings() {
return quotaMappings; return quotaMappings;
} }
/** /**
* @param quotaMappings the quotaMappings to set * Sets the quota mappings.
*
* @param quotaMappings the new quota mappings
*/ */
public void setQuotaMappings(List<QuotaMapping> quotaMappings) { public void setQuotaMappings(List<QuotaMapping> quotaMappings) {
this.quotaMappings = quotaMappings; this.quotaMappings = quotaMappings;
} }
/** /**
* Gets the status.
*
* @return the status * @return the status
*/ */
public UserStatus getStatus() { public UserStatus getStatus() {
@ -106,13 +126,17 @@ public class UserModel extends PasswordModel {
} }
/** /**
* @param status the status to set * Sets the status.
*
* @param status the new status
*/ */
public void setStatus(UserStatus status) { public void setStatus(UserStatus status) {
this.status = status; this.status = status;
} }
/** /**
* Gets the token.
*
* @return the token * @return the token
*/ */
public String getToken() { public String getToken() {
@ -120,21 +144,27 @@ public class UserModel extends PasswordModel {
} }
/** /**
* @param token the token to set * Sets the token.
*
* @param token the new token
*/ */
public void setToken(String token) { public void setToken(String token) {
this.token = token; this.token = token;
} }
/** /**
* @return the profileFields * Gets the profile fields.
*
* @return the profile fields
*/ */
public List<UserProfileField> getProfileFields() { public List<UserProfileField> getProfileFields() {
return profileFields; return profileFields;
} }
/** /**
* @param profileFields the profileFields to set * Sets the profile fields.
*
* @param profileFields the new profile fields
*/ */
public void setProfileFields(List<UserProfileField> profileFields) { public void setProfileFields(List<UserProfileField> profileFields) {
this.profileFields = profileFields; this.profileFields = profileFields;

View File

@ -11,18 +11,17 @@ import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
/** /**
* * The Class ControllerExceptionHandler.
* @author _bastler@bstly.de
*
*/ */
@ControllerAdvice @ControllerAdvice
public class ControllerExceptionHandler extends ResponseEntityExceptionHandler { public class ControllerExceptionHandler extends ResponseEntityExceptionHandler {
/** /**
* Handle response entity status exception.
* *
* @param exception * @param exception the exception
* @param request * @param request the request
* @return * @return the response entity
*/ */
@ExceptionHandler(value = { EntityResponseStatusException.class }) @ExceptionHandler(value = { EntityResponseStatusException.class })
protected ResponseEntity<Object> handleResponseEntityStatusException(RuntimeException exception, protected ResponseEntity<Object> handleResponseEntityStatusException(RuntimeException exception,

View File

@ -11,9 +11,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
* * The Class EntityResponseStatusException.
* @author _bastler@bstly.de
*
*/ */
public class EntityResponseStatusException extends NestedRuntimeException { public class EntityResponseStatusException extends NestedRuntimeException {
@ -28,27 +26,30 @@ public class EntityResponseStatusException extends NestedRuntimeException {
private final Object body; private final Object body;
/** /**
* Instantiates a new entity response status exception.
* *
* @param status * @param status the status
*/ */
public EntityResponseStatusException(HttpStatus status) { public EntityResponseStatusException(HttpStatus status) {
this(null, status); this(null, status);
} }
/** /**
* Instantiates a new entity response status exception.
* *
* @param body * @param body the body
* @param status * @param status the status
*/ */
public EntityResponseStatusException(@Nullable Object body, HttpStatus status) { public EntityResponseStatusException(@Nullable Object body, HttpStatus status) {
this(body, status, null); this(body, status, null);
} }
/** /**
* Instantiates a new entity response status exception.
* *
* @param body * @param body the body
* @param status * @param status the status
* @param cause * @param cause the cause
*/ */
public EntityResponseStatusException(@Nullable Object body, HttpStatus status, @Nullable Throwable cause) { public EntityResponseStatusException(@Nullable Object body, HttpStatus status, @Nullable Throwable cause) {
super(null, cause); super(null, cause);
@ -58,25 +59,26 @@ public class EntityResponseStatusException extends NestedRuntimeException {
} }
/** /**
* Gets the status.
* *
* @return * @return the status
*/ */
public HttpStatus getStatus() { public HttpStatus getStatus() {
return this.status; return this.status;
} }
/** /**
* Gets the body.
* *
* @return * @return the body
*/ */
@Nullable @Nullable
public Object getBody() { public Object getBody() {
return this.body; return this.body;
} }
/** /*
* * @see org.springframework.core.NestedRuntimeException#getMessage()
* @return
*/ */
@Override @Override
public String getMessage() { public String getMessage() {

View File

@ -22,18 +22,16 @@ import com.google.gson.Gson;
import com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
/** /**
* @author _bastler@bstly.de * The Class JsonStringBodyControllerAdvice.
*
*/ */
@ControllerAdvice @ControllerAdvice
public class JsonStringBodyControllerAdvice implements RequestBodyAdvice, ResponseBodyAdvice<String> { public class JsonStringBodyControllerAdvice implements RequestBodyAdvice, ResponseBodyAdvice<String> {
private Gson gson = new Gson(); private Gson gson = new Gson();
/* /*
* @see org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice# * @see org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice#supports(org.springframework.core.MethodParameter, java.lang.reflect.Type, java.lang.Class)
* supports(org.springframework.core.MethodParameter, java.lang.reflect.Type,
* java.lang.Class)
*/ */
@Override @Override
public boolean supports(MethodParameter methodParameter, Type targetType, public boolean supports(MethodParameter methodParameter, Type targetType,
@ -42,10 +40,7 @@ public class JsonStringBodyControllerAdvice implements RequestBodyAdvice, Respon
} }
/* /*
* @see org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice# * @see org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice#beforeBodyRead(org.springframework.http.HttpInputMessage, org.springframework.core.MethodParameter, java.lang.reflect.Type, java.lang.Class)
* beforeBodyRead(org.springframework.http.HttpInputMessage,
* org.springframework.core.MethodParameter, java.lang.reflect.Type,
* java.lang.Class)
*/ */
@Override @Override
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType,
@ -53,11 +48,9 @@ public class JsonStringBodyControllerAdvice implements RequestBodyAdvice, Respon
return inputMessage; return inputMessage;
} }
/* /*
* @see org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice# * @see org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice#afterBodyRead(java.lang.Object, org.springframework.http.HttpInputMessage, org.springframework.core.MethodParameter, java.lang.reflect.Type, java.lang.Class)
* afterBodyRead(java.lang.Object, org.springframework.http.HttpInputMessage,
* org.springframework.core.MethodParameter, java.lang.reflect.Type,
* java.lang.Class)
*/ */
@Override @Override
public Object afterBodyRead(Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, public Object afterBodyRead(Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType,
@ -66,11 +59,9 @@ public class JsonStringBodyControllerAdvice implements RequestBodyAdvice, Respon
return body; return body;
} }
/* /*
* @see org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice# * @see org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice#handleEmptyBody(java.lang.Object, org.springframework.http.HttpInputMessage, org.springframework.core.MethodParameter, java.lang.reflect.Type, java.lang.Class)
* handleEmptyBody(java.lang.Object, org.springframework.http.HttpInputMessage,
* org.springframework.core.MethodParameter, java.lang.reflect.Type,
* java.lang.Class)
*/ */
@Override @Override
public Object handleEmptyBody(Object body, HttpInputMessage inputMessage, MethodParameter parameter, public Object handleEmptyBody(Object body, HttpInputMessage inputMessage, MethodParameter parameter,
@ -78,23 +69,18 @@ public class JsonStringBodyControllerAdvice implements RequestBodyAdvice, Respon
return body; return body;
} }
/* /*
* @see * @see org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice#supports(org.springframework.core.MethodParameter, java.lang.Class)
* org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice#
* supports(org.springframework.core.MethodParameter, java.lang.Class)
*/ */
@Override @Override
public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) { public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {
return converterType == StringHttpMessageConverter.class; return converterType == StringHttpMessageConverter.class;
} }
/* /*
* @see * @see org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice#beforeBodyWrite(java.lang.Object, org.springframework.core.MethodParameter, org.springframework.http.MediaType, java.lang.Class, org.springframework.http.server.ServerHttpRequest, org.springframework.http.server.ServerHttpResponse)
* org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice#
* beforeBodyWrite(java.lang.Object, org.springframework.core.MethodParameter,
* org.springframework.http.MediaType, java.lang.Class,
* org.springframework.http.server.ServerHttpRequest,
* org.springframework.http.server.ServerHttpResponse)
*/ */
@Override @Override
public String beforeBodyWrite(String body, MethodParameter returnType, MediaType selectedContentType, public String beforeBodyWrite(String body, MethodParameter returnType, MediaType selectedContentType,

View File

@ -7,9 +7,7 @@ import org.springframework.lang.Nullable;
import org.springframework.validation.AbstractBindingResult; import org.springframework.validation.AbstractBindingResult;
/** /**
* * The Class RequestBodyErrors.
* @author _bastler@bstly.de
*
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class RequestBodyErrors extends AbstractBindingResult { public class RequestBodyErrors extends AbstractBindingResult {
@ -18,9 +16,9 @@ public class RequestBodyErrors extends AbstractBindingResult {
private final Object target; private final Object target;
/** /**
* Instantiates a new request body errors.
* *
* @param target * @param target the target
* @param objectName
*/ */
public RequestBodyErrors(@Nullable Object target) { public RequestBodyErrors(@Nullable Object target) {
super("request-body"); super("request-body");
@ -35,10 +33,9 @@ public class RequestBodyErrors extends AbstractBindingResult {
return target; return target;
} }
/* /*
* @see * @see org.springframework.validation.AbstractBindingResult#getActualFieldValue(java.lang.String)
* org.springframework.validation.AbstractBindingResult#getActualFieldValue(java
* .lang.String)
*/ */
@Override @Override
protected Object getActualFieldValue(String field) { protected Object getActualFieldValue(String field) {

View File

@ -32,9 +32,7 @@ import de.bstly.we.security.model.LocalUserDetails;
import de.bstly.we.security.token.LocalAnonymousAuthenticationToken; import de.bstly.we.security.token.LocalAnonymousAuthenticationToken;
/** /**
* * The Class TokenSessionManager.
* @author _bastler@bstly.de
*
*/ */
@Component @Component
public class TokenSessionManager { public class TokenSessionManager {
@ -53,10 +51,11 @@ public class TokenSessionManager {
private PretixManager pretixManager; private PretixManager pretixManager;
/** /**
* Gets the permission mappings for token.
* *
* @param userId * @param userId the user id
* @param token * @param token the token
* @return * @return the permission mappings for token
*/ */
public List<PermissionMapping> getPermissionMappingsForToken(Long userId, String token) { public List<PermissionMapping> getPermissionMappingsForToken(Long userId, String token) {
List<PermissionMapping> permissionMappings = Lists.newArrayList(); List<PermissionMapping> permissionMappings = Lists.newArrayList();
@ -76,10 +75,11 @@ public class TokenSessionManager {
} }
/** /**
* Gets the permissions for token.
* *
* @param userId * @param userId the user id
* @param token * @param token the token
* @return * @return the permissions for token
*/ */
public List<Permission> getPermissionsForToken(Long userId, String token) { public List<Permission> getPermissionsForToken(Long userId, String token) {
List<Permission> permissions = Lists.newArrayList(); List<Permission> permissions = Lists.newArrayList();
@ -109,10 +109,11 @@ public class TokenSessionManager {
} }
/** /**
* Gets the quota mappings for token.
* *
* @param userId * @param userId the user id
* @param token * @param token the token
* @return * @return the quota mappings for token
*/ */
public List<QuotaMapping> getQuotaMappingsForToken(Long userId, String token) { public List<QuotaMapping> getQuotaMappingsForToken(Long userId, String token) {
List<QuotaMapping> quotaMappings = Lists.newArrayList(); List<QuotaMapping> quotaMappings = Lists.newArrayList();
@ -132,10 +133,11 @@ public class TokenSessionManager {
} }
/** /**
* Apply tokens.
* *
* @param userId * @param userId the user id
* @param tokens * @param tokens the tokens
* @return * @return the item result model
*/ */
public ItemResultModel applyTokens(Long userId, Set<String> tokens) { public ItemResultModel applyTokens(Long userId, Set<String> tokens) {
ItemResultModel itemResultModel = new ItemResultModel(); ItemResultModel itemResultModel = new ItemResultModel();
@ -173,9 +175,10 @@ public class TokenSessionManager {
} }
/** /**
* Gets the token from session.
* *
* @param session * @param session the session
* @return * @return the token from session
*/ */
public Set<String> getTokenFromSession(HttpSession session) { public Set<String> getTokenFromSession(HttpSession session) {
@ -195,9 +198,10 @@ public class TokenSessionManager {
} }
/** /**
* Adds the token to session.
* *
* @param secret * @param secret the secret
* @return * @param session the session
*/ */
public void addTokenToSession(String secret, HttpSession session) { public void addTokenToSession(String secret, HttpSession session) {
@ -220,9 +224,10 @@ public class TokenSessionManager {
} }
/** /**
* Removes the token from session.
* *
* @param secret * @param secret the secret
* @return * @param session the session
*/ */
public void removeTokenFromSession(String secret, HttpSession session) { public void removeTokenFromSession(String secret, HttpSession session) {
String tokens = ""; String tokens = "";
@ -245,19 +250,20 @@ public class TokenSessionManager {
} }
/** /**
* Removes the tokens from session.
* *
* @param secret * @param session the session
* @return
*/ */
public void removeTokensFromSession(HttpSession session) { public void removeTokensFromSession(HttpSession session) {
session.setAttribute(HTTP_SESSION_ATTRIBUTE_TOKENS, null); session.setAttribute(HTTP_SESSION_ATTRIBUTE_TOKENS, null);
} }
/** /**
* Creates the new auth.
* *
* @param auth * @param auth the auth
* @param details * @param details the details
* @return * @return the authentication
*/ */
protected Authentication createNewAuth(Authentication auth, LocalUserDetails details) { protected Authentication createNewAuth(Authentication auth, LocalUserDetails details) {
Authentication newAuth = null; Authentication newAuth = null;

View File

@ -24,9 +24,7 @@ import de.bstly.we.businesslogic.SystemPropertyManager;
import de.bstly.we.controller.model.PasswordModel; import de.bstly.we.controller.model.PasswordModel;
/** /**
* * The Class PasswordModelValidator.
* @author _bastler@bstly.de
*
*/ */
@Component @Component
public class PasswordModelValidator implements Validator { public class PasswordModelValidator implements Validator {
@ -48,10 +46,9 @@ public class PasswordModelValidator implements Validator {
return clazz.isAssignableFrom(PasswordModel.class); return clazz.isAssignableFrom(PasswordModel.class);
} }
/* /*
* * @see org.springframework.validation.Validator#validate(java.lang.Object, org.springframework.validation.Errors)
* @see org.springframework.validation.Validator#validate(java.lang.Object,
* org.springframework.validation.Errors)
*/ */
@Override @Override
public void validate(Object target, Errors errors) { public void validate(Object target, Errors errors) {

View File

@ -12,9 +12,7 @@ import de.bstly.we.businesslogic.PermissionMappingManager;
import de.bstly.we.model.PermissionMapping; import de.bstly.we.model.PermissionMapping;
/** /**
* * The Class PermissionMappingValidator.
* @author _bastler@bstly.de
*
*/ */
@Component @Component
public class PermissionMappingValidator implements Validator { public class PermissionMappingValidator implements Validator {

View File

@ -12,9 +12,7 @@ import de.bstly.we.businesslogic.QuotaMappingManager;
import de.bstly.we.model.QuotaMapping; import de.bstly.we.model.QuotaMapping;
/** /**
* * The Class QuotaMappingValidator.
* @author _bastler@bstly.de
*
*/ */
@Component @Component
public class QuotaMappingValidator implements Validator { public class QuotaMappingValidator implements Validator {

View File

@ -12,8 +12,7 @@ import org.springframework.validation.Validator;
import de.bstly.we.model.UserAlias; import de.bstly.we.model.UserAlias;
/** /**
* @author _bastler@bstly.de * The Class UserAliasValidator.
*
*/ */
@Component @Component
public class UserAliasValidator implements Validator { public class UserAliasValidator implements Validator {

View File

@ -14,8 +14,7 @@ import de.bstly.we.businesslogic.UserDomainManager;
import de.bstly.we.model.UserDomain; import de.bstly.we.model.UserDomain;
/** /**
* @author _bastler@bstly.de * The Class UserDomainValidator.
*
*/ */
@Component @Component
public class UserDomainValidator implements Validator { public class UserDomainValidator implements Validator {

View File

@ -15,9 +15,7 @@ import de.bstly.we.businesslogic.UserManager;
import de.bstly.we.controller.model.UserModel; import de.bstly.we.controller.model.UserModel;
/** /**
* * The Class UserModelValidator.
* @author _bastler@bstly.de
*
*/ */
@Component @Component
public class UserModelValidator implements Validator { public class UserModelValidator implements Validator {
@ -59,10 +57,11 @@ public class UserModelValidator implements Validator {
} }
/** /**
* Validate username.
* *
* @param username * @param username the username
* @param field * @param field the field
* @param errors * @param errors the errors
*/ */
public void validateUsername(String username, String field, Errors errors) { public void validateUsername(String username, String field, Errors errors) {
for (String systemUsername : systemPropertyManager.get(RESERVED_USERNAMES, "").split(",")) { for (String systemUsername : systemPropertyManager.get(RESERVED_USERNAMES, "").split(",")) {

View File

@ -26,8 +26,7 @@ import de.bstly.we.model.UserProfileField;
import de.bstly.we.repository.UserProfileFieldRepository; import de.bstly.we.repository.UserProfileFieldRepository;
/** /**
* @author _bastler@bstly.de * The Class UserProfileFieldValidator.
*
*/ */
@Component @Component
public class UserProfileFieldValidator implements Validator { public class UserProfileFieldValidator implements Validator {

View File

@ -0,0 +1,56 @@
/**
*
*/
package de.bstly.we.controller.validation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
import de.bstly.we.businesslogic.VoucherMappingManager;
import de.bstly.we.model.VoucherMapping;
/**
* The Class VoucherMappingValidator.
*/
@Component
public class VoucherMappingValidator implements Validator {
@Autowired
private VoucherMappingManager voucherMappingManager;
/*
* @see org.springframework.validation.Validator#supports(java.lang.Class)
*/
@Override
public boolean supports(Class<?> clazz) {
return clazz.isAssignableFrom(VoucherMapping.class);
}
/*
*
* @see org.springframework.validation.Validator#validate(java.lang.Object,
* org.springframework.validation.Errors)
*/
@Override
public void validate(Object target, Errors errors) {
VoucherMapping voucherMapping = (VoucherMapping) target;
if (!StringUtils.hasText(voucherMapping.getName())) {
errors.rejectValue("name", "REQUIRED");
} else {
VoucherMapping other = voucherMappingManager.get(voucherMapping.getName());
if (other != null && !other.getId().equals(voucherMapping.getId())) {
errors.rejectValue("name", "ALREADY_EXISTS");
}
}
if (voucherMapping.getVoucher() <= 0) {
errors.rejectValue("value", "TOO_SHORT");
}
}
}

View File

@ -8,8 +8,7 @@ import org.springframework.context.ApplicationEvent;
import de.bstly.we.model.AbstractModel; import de.bstly.we.model.AbstractModel;
/** /**
* @author Lurkars * The Class AbstractModelEvent.
*
*/ */
public class AbstractModelEvent extends ApplicationEvent { public class AbstractModelEvent extends ApplicationEvent {
@ -22,9 +21,10 @@ public class AbstractModelEvent extends ApplicationEvent {
private AbstractModel model; private AbstractModel model;
/** /**
* Instantiates a new abstract model event.
* *
* @param type * @param type the type
* @param model * @param model the model
*/ */
public AbstractModelEvent(AbstractModelEventType type, AbstractModel model) { public AbstractModelEvent(AbstractModelEventType type, AbstractModel model) {
super(model); super(model);
@ -33,6 +33,8 @@ public class AbstractModelEvent extends ApplicationEvent {
} }
/** /**
* Gets the type.
*
* @return the type * @return the type
*/ */
public AbstractModelEventType getType() { public AbstractModelEventType getType() {
@ -40,13 +42,17 @@ public class AbstractModelEvent extends ApplicationEvent {
} }
/** /**
* @param type the type to set * Sets the type.
*
* @param type the new type
*/ */
public void setType(AbstractModelEventType type) { public void setType(AbstractModelEventType type) {
this.type = type; this.type = type;
} }
/** /**
* Gets the model.
*
* @return the model * @return the model
*/ */
public AbstractModel getModel() { public AbstractModel getModel() {
@ -54,7 +60,9 @@ public class AbstractModelEvent extends ApplicationEvent {
} }
/** /**
* @param model the model to set * Sets the model.
*
* @param model the new model
*/ */
public void setModel(AbstractModel model) { public void setModel(AbstractModel model) {
this.model = model; this.model = model;

View File

@ -4,8 +4,7 @@
package de.bstly.we.event; package de.bstly.we.event;
/** /**
* @author Lurkars * The Enum AbstractModelEventType.
*
*/ */
public enum AbstractModelEventType { public enum AbstractModelEventType {

View File

@ -4,8 +4,7 @@
package de.bstly.we.model; package de.bstly.we.model;
/** /**
* @author Lurkars * The Interface AbstractModel.
*
*/ */
public interface AbstractModel { public interface AbstractModel {

View File

@ -13,9 +13,7 @@ import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
/** /**
* * The Class Permission.
* @author _bastler@bstly.de
*
*/ */
@Entity @Entity
@Table(name = "permissions") @Table(name = "permissions")
@ -37,6 +35,8 @@ public class Permission implements UserData {
private Instant expires; private Instant expires;
/** /**
* Gets the id.
*
* @return the id * @return the id
*/ */
public Long getId() { public Long getId() {
@ -44,13 +44,17 @@ public class Permission implements UserData {
} }
/** /**
* @param id the id to set * Sets the id.
*
* @param id the new id
*/ */
public void setId(Long id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
/** /**
* Gets the name.
*
* @return the name * @return the name
*/ */
public String getName() { public String getName() {
@ -58,13 +62,17 @@ public class Permission implements UserData {
} }
/** /**
* @param name the name to set * Sets the name.
*
* @param name the new name
*/ */
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
/** /**
* Gets the target.
*
* @return the target * @return the target
*/ */
public Long getTarget() { public Long getTarget() {
@ -72,27 +80,35 @@ public class Permission implements UserData {
} }
/** /**
* @param target the target to set * Sets the target.
*
* @param target the new target
*/ */
public void setTarget(Long target) { public void setTarget(Long target) {
this.target = target; this.target = target;
} }
/** /**
* @return the addon * Checks if is addon.
*
* @return true, if is addon
*/ */
public boolean isAddon() { public boolean isAddon() {
return addon; return addon;
} }
/** /**
* @param addon the addon to set * Sets the addon.
*
* @param addon the new addon
*/ */
public void setAddon(boolean addon) { public void setAddon(boolean addon) {
this.addon = addon; this.addon = addon;
} }
/** /**
* Gets the starts.
*
* @return the starts * @return the starts
*/ */
public Instant getStarts() { public Instant getStarts() {
@ -100,13 +116,17 @@ public class Permission implements UserData {
} }
/** /**
* @param starts the starts to set * Sets the starts.
*
* @param starts the new starts
*/ */
public void setStarts(Instant starts) { public void setStarts(Instant starts) {
this.starts = starts; this.starts = starts;
} }
/** /**
* Gets the expires.
*
* @return the expires * @return the expires
*/ */
public Instant getExpires() { public Instant getExpires() {
@ -114,7 +134,9 @@ public class Permission implements UserData {
} }
/** /**
* @param expires the expires to set * Sets the expires.
*
* @param expires the new expires
*/ */
public void setExpires(Instant expires) { public void setExpires(Instant expires) {
this.expires = expires; this.expires = expires;

View File

@ -22,9 +22,7 @@ import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption; import org.hibernate.annotations.LazyCollectionOption;
/** /**
* * The Class PermissionMapping.
* @author _bastler@bstly.de
*
*/ */
@Entity @Entity
@Table(name = "permission_mappings") @Table(name = "permission_mappings")
@ -59,6 +57,8 @@ public class PermissionMapping {
private String expiresQuestion; private String expiresQuestion;
/** /**
* Gets the id.
*
* @return the id * @return the id
*/ */
public Long getId() { public Long getId() {
@ -66,13 +66,17 @@ public class PermissionMapping {
} }
/** /**
* @param id the id to set * Sets the id.
*
* @param id the new id
*/ */
public void setId(Long id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
/** /**
* Gets the product.
*
* @return the product * @return the product
*/ */
public String getProduct() { public String getProduct() {
@ -80,13 +84,17 @@ public class PermissionMapping {
} }
/** /**
* @param product the product to set * Sets the product.
*
* @param product the new product
*/ */
public void setProduct(String product) { public void setProduct(String product) {
this.product = product; this.product = product;
} }
/** /**
* Gets the item.
*
* @return the item * @return the item
*/ */
public Integer getItem() { public Integer getItem() {
@ -94,13 +102,17 @@ public class PermissionMapping {
} }
/** /**
* @param item the item to set * Sets the item.
*
* @param item the new item
*/ */
public void setItem(Integer item) { public void setItem(Integer item) {
this.item = item; this.item = item;
} }
/** /**
* Gets the names.
*
* @return the names * @return the names
*/ */
public Set<String> getNames() { public Set<String> getNames() {
@ -108,27 +120,35 @@ public class PermissionMapping {
} }
/** /**
* @param names the names to set * Sets the names.
*
* @param names the new names
*/ */
public void setNames(Set<String> names) { public void setNames(Set<String> names) {
this.names = names; this.names = names;
} }
/** /**
* @return the addon * Checks if is addon.
*
* @return true, if is addon
*/ */
public boolean isAddon() { public boolean isAddon() {
return addon; return addon;
} }
/** /**
* @param addon the addon to set * Sets the addon.
*
* @param addon the new addon
*/ */
public void setAddon(boolean addon) { public void setAddon(boolean addon) {
this.addon = addon; this.addon = addon;
} }
/** /**
* Gets the lifetime.
*
* @return the lifetime * @return the lifetime
*/ */
public Long getLifetime() { public Long getLifetime() {
@ -136,75 +156,103 @@ public class PermissionMapping {
} }
/** /**
* @param lifetime the lifetime to set * Sets the lifetime.
*
* @param lifetime the new lifetime
*/ */
public void setLifetime(Long lifetime) { public void setLifetime(Long lifetime) {
this.lifetime = lifetime; this.lifetime = lifetime;
} }
/** /**
* @return the lifetimeUnit * Gets the lifetime unit.
*
* @return the lifetime unit
*/ */
public ChronoUnit getLifetimeUnit() { public ChronoUnit getLifetimeUnit() {
return lifetimeUnit; return lifetimeUnit;
} }
/** /**
* @param lifetimeUnit the lifetimeUnit to set * Sets the lifetime unit.
*
* @param lifetimeUnit the new lifetime unit
*/ */
public void setLifetimeUnit(ChronoUnit lifetimeUnit) { public void setLifetimeUnit(ChronoUnit lifetimeUnit) {
this.lifetimeUnit = lifetimeUnit; this.lifetimeUnit = lifetimeUnit;
} }
/** /**
* @return the lifetimeRound * Checks if is lifetime round.
*
* @return true, if is lifetime round
*/ */
public boolean isLifetimeRound() { public boolean isLifetimeRound() {
return lifetimeRound; return lifetimeRound;
} }
/** /**
* @param lifetimeRound the lifetimeRound to set * Sets the lifetime round.
*
* @param lifetimeRound the new lifetime round
*/ */
public void setLifetimeRound(boolean lifetimeRound) { public void setLifetimeRound(boolean lifetimeRound) {
this.lifetimeRound = lifetimeRound; this.lifetimeRound = lifetimeRound;
} }
/** /**
* @return the startsQuestion * Gets the starts question.
*
* @return the starts question
*/ */
public String getStartsQuestion() { public String getStartsQuestion() {
return startsQuestion; return startsQuestion;
} }
/** /**
* @param startsQuestion the startsQuestion to set * Sets the starts question.
*
* @param startsQuestion the new starts question
*/ */
public void setStartsQuestion(String startsQuestion) { public void setStartsQuestion(String startsQuestion) {
this.startsQuestion = startsQuestion; this.startsQuestion = startsQuestion;
} }
/** /**
* @return the expiresQuestion * Gets the expires question.
*
* @return the expires question
*/ */
public String getExpiresQuestion() { public String getExpiresQuestion() {
return expiresQuestion; return expiresQuestion;
} }
/** /**
* @param expiresQuestion the expiresQuestion to set * Sets the expires question.
*
* @param expiresQuestion the new expires question
*/ */
public void setExpiresQuestion(String expiresQuestion) { public void setExpiresQuestion(String expiresQuestion) {
this.expiresQuestion = expiresQuestion; this.expiresQuestion = expiresQuestion;
} }
/**
* The Class ChronoUnitConverter.
*/
@Converter @Converter
public static class ChronoUnitConverter implements AttributeConverter<ChronoUnit, String> { public static class ChronoUnitConverter implements AttributeConverter<ChronoUnit, String> {
/*
* @see javax.persistence.AttributeConverter#convertToDatabaseColumn(java.lang.Object)
*/
@Override @Override
public String convertToDatabaseColumn(ChronoUnit chronoUnit) { public String convertToDatabaseColumn(ChronoUnit chronoUnit) {
return chronoUnit.name(); return chronoUnit.name();
} }
/*
* @see javax.persistence.AttributeConverter#convertToEntityAttribute(java.lang.Object)
*/
@Override @Override
public ChronoUnit convertToEntityAttribute(String value) { public ChronoUnit convertToEntityAttribute(String value) {
return ChronoUnit.valueOf(value); return ChronoUnit.valueOf(value);

View File

@ -11,9 +11,7 @@ import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
/** /**
* * The Class PersistentLogin.
* @author _bastler@bstly.de
*
*/ */
@Entity @Entity
@Table(name = "persistent_logins") @Table(name = "persistent_logins")
@ -30,6 +28,8 @@ public class PersistentLogin {
private Instant last_used; private Instant last_used;
/** /**
* Gets the username.
*
* @return the username * @return the username
*/ */
public String getUsername() { public String getUsername() {
@ -37,13 +37,17 @@ public class PersistentLogin {
} }
/** /**
* @param username the username to set * Sets the username.
*
* @param username the new username
*/ */
public void setUsername(String username) { public void setUsername(String username) {
this.username = username; this.username = username;
} }
/** /**
* Gets the series.
*
* @return the series * @return the series
*/ */
public String getSeries() { public String getSeries() {
@ -51,13 +55,17 @@ public class PersistentLogin {
} }
/** /**
* @param series the series to set * Sets the series.
*
* @param series the new series
*/ */
public void setSeries(String series) { public void setSeries(String series) {
this.series = series; this.series = series;
} }
/** /**
* Gets the token.
*
* @return the token * @return the token
*/ */
public String getToken() { public String getToken() {
@ -65,21 +73,27 @@ public class PersistentLogin {
} }
/** /**
* @param token the token to set * Sets the token.
*
* @param token the new token
*/ */
public void setToken(String token) { public void setToken(String token) {
this.token = token; this.token = token;
} }
/** /**
* @return the last_used * Gets the last used.
*
* @return the last used
*/ */
public Instant getLast_used() { public Instant getLast_used() {
return last_used; return last_used;
} }
/** /**
* @param last_used the last_used to set * Sets the last used.
*
* @param last_used the new last used
*/ */
public void setLast_used(Instant last_used) { public void setLast_used(Instant last_used) {
this.last_used = last_used; this.last_used = last_used;

View File

@ -4,8 +4,7 @@
package de.bstly.we.model; package de.bstly.we.model;
/** /**
* @author _bastler@bstly.de * The Enum ProfileFieldType.
*
*/ */
public enum ProfileFieldType { public enum ProfileFieldType {

View File

@ -11,8 +11,7 @@ import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
/** /**
* @author _bastler@bstly.de * The Class Quota.
*
*/ */
@Entity @Entity
@Table(name = "quotas") @Table(name = "quotas")
@ -34,6 +33,8 @@ public class Quota implements UserData {
private boolean disposable; private boolean disposable;
/** /**
* Gets the id.
*
* @return the id * @return the id
*/ */
public Long getId() { public Long getId() {
@ -41,13 +42,17 @@ public class Quota implements UserData {
} }
/** /**
* @param id the id to set * Sets the id.
*
* @param id the new id
*/ */
public void setId(Long id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
/** /**
* Gets the target.
*
* @return the target * @return the target
*/ */
public Long getTarget() { public Long getTarget() {
@ -55,13 +60,17 @@ public class Quota implements UserData {
} }
/** /**
* @param target the target to set * Sets the target.
*
* @param target the new target
*/ */
public void setTarget(Long target) { public void setTarget(Long target) {
this.target = target; this.target = target;
} }
/** /**
* Gets the name.
*
* @return the name * @return the name
*/ */
public String getName() { public String getName() {
@ -69,13 +78,17 @@ public class Quota implements UserData {
} }
/** /**
* @param name the name to set * Sets the name.
*
* @param name the new name
*/ */
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
/** /**
* Gets the value.
*
* @return the value * @return the value
*/ */
public long getValue() { public long getValue() {
@ -83,13 +96,17 @@ public class Quota implements UserData {
} }
/** /**
* @param value the value to set * Sets the value.
*
* @param value the new value
*/ */
public void setValue(long value) { public void setValue(long value) {
this.value = value; this.value = value;
} }
/** /**
* Gets the unit.
*
* @return the unit * @return the unit
*/ */
public String getUnit() { public String getUnit() {
@ -97,21 +114,27 @@ public class Quota implements UserData {
} }
/** /**
* @param unit the unit to set * Sets the unit.
*
* @param unit the new unit
*/ */
public void setUnit(String unit) { public void setUnit(String unit) {
this.unit = unit; this.unit = unit;
} }
/** /**
* @return the disposable * Checks if is disposable.
*
* @return true, if is disposable
*/ */
public boolean isDisposable() { public boolean isDisposable() {
return disposable; return disposable;
} }
/** /**
* @param disposable the disposable to set * Sets the disposable.
*
* @param disposable the new disposable
*/ */
public void setDisposable(boolean disposable) { public void setDisposable(boolean disposable) {
this.disposable = disposable; this.disposable = disposable;

View File

@ -18,9 +18,7 @@ import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption; import org.hibernate.annotations.LazyCollectionOption;
/** /**
* * The Class QuotaMapping.
* @author _bastler@bstly.de
*
*/ */
@Entity @Entity
@Table(name = "quota_mappings") @Table(name = "quota_mappings")
@ -50,6 +48,8 @@ public class QuotaMapping {
private boolean disposable; private boolean disposable;
/** /**
* Gets the id.
*
* @return the id * @return the id
*/ */
public Long getId() { public Long getId() {
@ -57,13 +57,17 @@ public class QuotaMapping {
} }
/** /**
* @param id the id to set * Sets the id.
*
* @param id the new id
*/ */
public void setId(Long id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
/** /**
* Gets the products.
*
* @return the products * @return the products
*/ */
public Set<String> getProducts() { public Set<String> getProducts() {
@ -71,13 +75,17 @@ public class QuotaMapping {
} }
/** /**
* @param products the products to set * Sets the products.
*
* @param products the new products
*/ */
public void setProducts(Set<String> products) { public void setProducts(Set<String> products) {
this.products = products; this.products = products;
} }
/** /**
* Gets the items.
*
* @return the items * @return the items
*/ */
public Set<Integer> getItems() { public Set<Integer> getItems() {
@ -85,13 +93,17 @@ public class QuotaMapping {
} }
/** /**
* @param items the items to set * Sets the items.
*
* @param items the new items
*/ */
public void setItems(Set<Integer> items) { public void setItems(Set<Integer> items) {
this.items = items; this.items = items;
} }
/** /**
* Gets the name.
*
* @return the name * @return the name
*/ */
public String getName() { public String getName() {
@ -99,13 +111,17 @@ public class QuotaMapping {
} }
/** /**
* @param name the name to set * Sets the name.
*
* @param name the new name
*/ */
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
/** /**
* Gets the value.
*
* @return the value * @return the value
*/ */
public long getValue() { public long getValue() {
@ -113,13 +129,17 @@ public class QuotaMapping {
} }
/** /**
* @param value the value to set * Sets the value.
*
* @param value the new value
*/ */
public void setValue(long value) { public void setValue(long value) {
this.value = value; this.value = value;
} }
/** /**
* Gets the unit.
*
* @return the unit * @return the unit
*/ */
public String getUnit() { public String getUnit() {
@ -127,35 +147,45 @@ public class QuotaMapping {
} }
/** /**
* @param unit the unit to set * Sets the unit.
*
* @param unit the new unit
*/ */
public void setUnit(String unit) { public void setUnit(String unit) {
this.unit = unit; this.unit = unit;
} }
/** /**
* @return the append * Checks if is append.
*
* @return true, if is append
*/ */
public boolean isAppend() { public boolean isAppend() {
return append; return append;
} }
/** /**
* @param append the append to set * Sets the append.
*
* @param append the new append
*/ */
public void setAppend(boolean append) { public void setAppend(boolean append) {
this.append = append; this.append = append;
} }
/** /**
* @return the disposable * Checks if is disposable.
*
* @return true, if is disposable
*/ */
public boolean isDisposable() { public boolean isDisposable() {
return disposable; return disposable;
} }
/** /**
* @param disposable the disposable to set * Sets the disposable.
*
* @param disposable the new disposable
*/ */
public void setDisposable(boolean disposable) { public void setDisposable(boolean disposable) {
this.disposable = disposable; this.disposable = disposable;

View File

@ -4,8 +4,7 @@
package de.bstly.we.model; package de.bstly.we.model;
/** /**
* @author _bastler@bstly.de * The Interface SecondFactor.
*
*/ */
public interface SecondFactor extends UserData { public interface SecondFactor extends UserData {

View File

@ -9,8 +9,7 @@ import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
/** /**
* @author _bastler@bstly.de * The Class SystemProfileField.
*
*/ */
@Entity @Entity
@Table(name = "system_profile_fields") @Table(name = "system_profile_fields")
@ -25,6 +24,8 @@ public class SystemProfileField {
private boolean uniqueValue; private boolean uniqueValue;
/** /**
* Gets the name.
*
* @return the name * @return the name
*/ */
public String getName() { public String getName() {
@ -32,13 +33,17 @@ public class SystemProfileField {
} }
/** /**
* @param name the name to set * Sets the name.
*
* @param name the new name
*/ */
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
/** /**
* Gets the type.
*
* @return the type * @return the type
*/ */
public ProfileFieldType getType() { public ProfileFieldType getType() {
@ -46,21 +51,27 @@ public class SystemProfileField {
} }
/** /**
* @param type the type to set * Sets the type.
*
* @param type the new type
*/ */
public void setType(ProfileFieldType type) { public void setType(ProfileFieldType type) {
this.type = type; this.type = type;
} }
/** /**
* @return the uniqueValue * Checks if is unique value.
*
* @return true, if is unique value
*/ */
public boolean isUniqueValue() { public boolean isUniqueValue() {
return uniqueValue; return uniqueValue;
} }
/** /**
* @param uniqueValue the uniqueValue to set * Sets the unique value.
*
* @param uniqueValue the new unique value
*/ */
public void setUniqueValue(boolean uniqueValue) { public void setUniqueValue(boolean uniqueValue) {
this.uniqueValue = uniqueValue; this.uniqueValue = uniqueValue;

View File

@ -10,9 +10,7 @@ import javax.persistence.Lob;
import javax.persistence.Table; import javax.persistence.Table;
/** /**
* * The Class SystemProperty.
* @author _bastler@bstly.de
*
*/ */
@Entity @Entity
@Table(name = "system_properties") @Table(name = "system_properties")
@ -26,15 +24,17 @@ public class SystemProperty {
private String value; private String value;
/** /**
* * Instantiates a new system property.
*/ */
public SystemProperty() { public SystemProperty() {
super(); super();
} }
/** /**
* @param key * Instantiates a new system property.
* @param value *
* @param key the key
* @param value the value
*/ */
public SystemProperty(String key, String value) { public SystemProperty(String key, String value) {
super(); super();
@ -43,6 +43,8 @@ public class SystemProperty {
} }
/** /**
* Gets the key.
*
* @return the key * @return the key
*/ */
public String getKey() { public String getKey() {
@ -50,13 +52,17 @@ public class SystemProperty {
} }
/** /**
* @param key the key to set * Sets the key.
*
* @param key the new key
*/ */
public void setKey(String key) { public void setKey(String key) {
this.key = key; this.key = key;
} }
/** /**
* Gets the value.
*
* @return the value * @return the value
*/ */
public String getValue() { public String getValue() {
@ -64,7 +70,9 @@ public class SystemProperty {
} }
/** /**
* @param value the value to set * Sets the value.
*
* @param value the new value
*/ */
public void setValue(String value) { public void setValue(String value) {
this.value = value; this.value = value;

View File

@ -14,9 +14,7 @@ import javax.persistence.UniqueConstraint;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
/** /**
* * The Class User.
* @author _bastler@bstly.de
*
*/ */
@Entity @Entity
@Table(name = "users", uniqueConstraints = @UniqueConstraint(columnNames = { "username" })) @Table(name = "users", uniqueConstraints = @UniqueConstraint(columnNames = { "username" }))
@ -43,6 +41,8 @@ public class User implements UserData {
private String resetToken; private String resetToken;
/** /**
* Gets the id.
*
* @return the id * @return the id
*/ */
public Long getId() { public Long getId() {
@ -50,13 +50,17 @@ public class User implements UserData {
} }
/** /**
* @param id the id to set * Sets the id.
*
* @param id the new id
*/ */
public void setId(Long id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
/** /**
* Gets the username.
*
* @return the username * @return the username
*/ */
public String getUsername() { public String getUsername() {
@ -64,55 +68,71 @@ public class User implements UserData {
} }
/** /**
* @param username the username to set * Sets the username.
*
* @param username the new username
*/ */
public void setUsername(String username) { public void setUsername(String username) {
this.username = username; this.username = username;
} }
/** /**
* @return the passwordHash * Gets the password hash.
*
* @return the password hash
*/ */
public String getPasswordHash() { public String getPasswordHash() {
return passwordHash; return passwordHash;
} }
/** /**
* @param passwordHash the passwordHash to set * Sets the password hash.
*
* @param passwordHash the new password hash
*/ */
public void setPasswordHash(String passwordHash) { public void setPasswordHash(String passwordHash) {
this.passwordHash = passwordHash; this.passwordHash = passwordHash;
} }
/** /**
* @return the disabled * Checks if is disabled.
*
* @return true, if is disabled
*/ */
public boolean isDisabled() { public boolean isDisabled() {
return disabled; return disabled;
} }
/** /**
* @param disabled the disabled to set * Sets the disabled.
*
* @param disabled the new disabled
*/ */
public void setDisabled(boolean disabled) { public void setDisabled(boolean disabled) {
this.disabled = disabled; this.disabled = disabled;
} }
/** /**
* @return the locked * Checks if is locked.
*
* @return true, if is locked
*/ */
public boolean isLocked() { public boolean isLocked() {
return locked; return locked;
} }
/** /**
* @param locked the locked to set * Sets the locked.
*
* @param locked the new locked
*/ */
public void setLocked(boolean locked) { public void setLocked(boolean locked) {
this.locked = locked; this.locked = locked;
} }
/** /**
* Gets the status.
*
* @return the status * @return the status
*/ */
public UserStatus getStatus() { public UserStatus getStatus() {
@ -120,13 +140,17 @@ public class User implements UserData {
} }
/** /**
* @param status the status to set * Sets the status.
*
* @param status the new status
*/ */
public void setStatus(UserStatus status) { public void setStatus(UserStatus status) {
this.status = status; this.status = status;
} }
/** /**
* Gets the secret.
*
* @return the secret * @return the secret
*/ */
public String getSecret() { public String getSecret() {
@ -134,21 +158,27 @@ public class User implements UserData {
} }
/** /**
* @param secret the secret to set * Sets the secret.
*
* @param secret the new secret
*/ */
public void setSecret(String secret) { public void setSecret(String secret) {
this.secret = secret; this.secret = secret;
} }
/** /**
* @return the resetToken * Gets the reset token.
*
* @return the reset token
*/ */
public String getResetToken() { public String getResetToken() {
return resetToken; return resetToken;
} }
/** /**
* @param resetToken the resetToken to set * Sets the reset token.
*
* @param resetToken the new reset token
*/ */
public void setResetToken(String resetToken) { public void setResetToken(String resetToken) {
this.resetToken = resetToken; this.resetToken = resetToken;

View File

@ -12,8 +12,7 @@ import javax.persistence.Table;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
/** /**
* @author _bastler@bstly.de * The Class UserAlias.
*
*/ */
@Entity @Entity
@Table(name = "aliases", uniqueConstraints = @UniqueConstraint(columnNames = { "alias" })) @Table(name = "aliases", uniqueConstraints = @UniqueConstraint(columnNames = { "alias" }))
@ -31,6 +30,8 @@ public class UserAlias implements UserData {
private Visibility visibility = Visibility.PROTECTED; private Visibility visibility = Visibility.PROTECTED;
/** /**
* Gets the id.
*
* @return the id * @return the id
*/ */
public Long getId() { public Long getId() {
@ -38,13 +39,17 @@ public class UserAlias implements UserData {
} }
/** /**
* @param id the id to set * Sets the id.
*
* @param id the new id
*/ */
public void setId(Long id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
/** /**
* Gets the target.
*
* @return the target * @return the target
*/ */
public Long getTarget() { public Long getTarget() {
@ -52,13 +57,17 @@ public class UserAlias implements UserData {
} }
/** /**
* @param target the target to set * Sets the target.
*
* @param target the new target
*/ */
public void setTarget(Long target) { public void setTarget(Long target) {
this.target = target; this.target = target;
} }
/** /**
* Gets the alias.
*
* @return the alias * @return the alias
*/ */
public String getAlias() { public String getAlias() {
@ -66,13 +75,17 @@ public class UserAlias implements UserData {
} }
/** /**
* @param alias the alias to set * Sets the alias.
*
* @param alias the new alias
*/ */
public void setAlias(String alias) { public void setAlias(String alias) {
this.alias = alias; this.alias = alias;
} }
/** /**
* Gets the visibility.
*
* @return the visibility * @return the visibility
*/ */
public Visibility getVisibility() { public Visibility getVisibility() {
@ -80,7 +93,9 @@ public class UserAlias implements UserData {
} }
/** /**
* @param visibility the visibility to set * Sets the visibility.
*
* @param visibility the new visibility
*/ */
public void setVisibility(Visibility visibility) { public void setVisibility(Visibility visibility) {
this.visibility = visibility; this.visibility = visibility;

View File

@ -4,8 +4,7 @@
package de.bstly.we.model; package de.bstly.we.model;
/** /**
* @author _bastler@bstly.de * The Interface UserData.
*
*/ */
public interface UserData { public interface UserData {

View File

@ -12,8 +12,7 @@ import javax.persistence.Table;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
/** /**
* @author _bastler@bstly.de * The Class UserDomain.
*
*/ */
@Entity @Entity
@Table(name = "domains", uniqueConstraints = @UniqueConstraint(columnNames = { "domain" })) @Table(name = "domains", uniqueConstraints = @UniqueConstraint(columnNames = { "domain" }))
@ -35,6 +34,8 @@ public class UserDomain implements UserData {
private boolean validated; private boolean validated;
/** /**
* Gets the id.
*
* @return the id * @return the id
*/ */
public Long getId() { public Long getId() {
@ -42,13 +43,17 @@ public class UserDomain implements UserData {
} }
/** /**
* @param id the id to set * Sets the id.
*
* @param id the new id
*/ */
public void setId(Long id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
/** /**
* Gets the target.
*
* @return the target * @return the target
*/ */
public Long getTarget() { public Long getTarget() {
@ -56,13 +61,17 @@ public class UserDomain implements UserData {
} }
/** /**
* @param target the target to set * Sets the target.
*
* @param target the new target
*/ */
public void setTarget(Long target) { public void setTarget(Long target) {
this.target = target; this.target = target;
} }
/** /**
* Gets the domain.
*
* @return the domain * @return the domain
*/ */
public String getDomain() { public String getDomain() {
@ -70,13 +79,17 @@ public class UserDomain implements UserData {
} }
/** /**
* @param domain the domain to set * Sets the domain.
*
* @param domain the new domain
*/ */
public void setDomain(String domain) { public void setDomain(String domain) {
this.domain = domain; this.domain = domain;
} }
/** /**
* Gets the visibility.
*
* @return the visibility * @return the visibility
*/ */
public Visibility getVisibility() { public Visibility getVisibility() {
@ -84,13 +97,17 @@ public class UserDomain implements UserData {
} }
/** /**
* @param visibility the visibility to set * Sets the visibility.
*
* @param visibility the new visibility
*/ */
public void setVisibility(Visibility visibility) { public void setVisibility(Visibility visibility) {
this.visibility = visibility; this.visibility = visibility;
} }
/** /**
* Gets the secret.
*
* @return the secret * @return the secret
*/ */
public String getSecret() { public String getSecret() {
@ -98,21 +115,27 @@ public class UserDomain implements UserData {
} }
/** /**
* @param secret the secret to set * Sets the secret.
*
* @param secret the new secret
*/ */
public void setSecret(String secret) { public void setSecret(String secret) {
this.secret = secret; this.secret = secret;
} }
/** /**
* @return the validated * Checks if is validated.
*
* @return true, if is validated
*/ */
public boolean isValidated() { public boolean isValidated() {
return validated; return validated;
} }
/** /**
* @param validated the validated to set * Sets the validated.
*
* @param validated the new validated
*/ */
public void setValidated(boolean validated) { public void setValidated(boolean validated) {
this.validated = validated; this.validated = validated;

View File

@ -16,8 +16,7 @@ import javax.persistence.UniqueConstraint;
import de.bstly.we.model.UserProfileField.UserProfileFieldId; import de.bstly.we.model.UserProfileField.UserProfileFieldId;
/** /**
* @author _bastler@bstly.de * The Class UserProfileField.
*
*/ */
@Entity @Entity
@IdClass(UserProfileFieldId.class) @IdClass(UserProfileFieldId.class)
@ -44,6 +43,8 @@ public class UserProfileField implements UserData {
private Integer index = 0; private Integer index = 0;
/** /**
* Gets the name.
*
* @return the name * @return the name
*/ */
public String getName() { public String getName() {
@ -51,13 +52,17 @@ public class UserProfileField implements UserData {
} }
/** /**
* @param name the name to set * Sets the name.
*
* @param name the new name
*/ */
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
/** /**
* Gets the target.
*
* @return the target * @return the target
*/ */
public Long getTarget() { public Long getTarget() {
@ -65,13 +70,17 @@ public class UserProfileField implements UserData {
} }
/** /**
* @param target the target to set * Sets the target.
*
* @param target the new target
*/ */
public void setTarget(Long target) { public void setTarget(Long target) {
this.target = target; this.target = target;
} }
/** /**
* Gets the value.
*
* @return the value * @return the value
*/ */
public String getValue() { public String getValue() {
@ -79,13 +88,17 @@ public class UserProfileField implements UserData {
} }
/** /**
* @param value the value to set * Sets the value.
*
* @param value the new value
*/ */
public void setValue(String value) { public void setValue(String value) {
this.value = value; this.value = value;
} }
/** /**
* Gets the blob.
*
* @return the blob * @return the blob
*/ */
public String getBlob() { public String getBlob() {
@ -93,13 +106,17 @@ public class UserProfileField implements UserData {
} }
/** /**
* @param blob the blob to set * Sets the blob.
*
* @param blob the new blob
*/ */
public void setBlob(String blob) { public void setBlob(String blob) {
this.blob = blob; this.blob = blob;
} }
/** /**
* Gets the type.
*
* @return the type * @return the type
*/ */
public ProfileFieldType getType() { public ProfileFieldType getType() {
@ -107,13 +124,17 @@ public class UserProfileField implements UserData {
} }
/** /**
* @param type the type to set * Sets the type.
*
* @param type the new type
*/ */
public void setType(ProfileFieldType type) { public void setType(ProfileFieldType type) {
this.type = type; this.type = type;
} }
/** /**
* Gets the visibility.
*
* @return the visibility * @return the visibility
*/ */
public Visibility getVisibility() { public Visibility getVisibility() {
@ -121,13 +142,17 @@ public class UserProfileField implements UserData {
} }
/** /**
* @param visibility the visibility to set * Sets the visibility.
*
* @param visibility the new visibility
*/ */
public void setVisibility(Visibility visibility) { public void setVisibility(Visibility visibility) {
this.visibility = visibility; this.visibility = visibility;
} }
/** /**
* Gets the index.
*
* @return the index * @return the index
*/ */
public Integer getIndex() { public Integer getIndex() {
@ -135,16 +160,16 @@ public class UserProfileField implements UserData {
} }
/** /**
* @param index the index to set * Sets the index.
*
* @param index the new index
*/ */
public void setIndex(Integer index) { public void setIndex(Integer index) {
this.index = index; this.index = index;
} }
/** /**
* * The Class UserProfileFieldId.
* @author _bastler@bstly.de
*
*/ */
public static class UserProfileFieldId implements Serializable { public static class UserProfileFieldId implements Serializable {
@ -156,6 +181,8 @@ public class UserProfileField implements UserData {
private String name; private String name;
/** /**
* Gets the target.
*
* @return the target * @return the target
*/ */
public Long getTarget() { public Long getTarget() {
@ -163,13 +190,17 @@ public class UserProfileField implements UserData {
} }
/** /**
* @param target the target to set * Sets the target.
*
* @param target the new target
*/ */
public void setTarget(Long target) { public void setTarget(Long target) {
this.target = target; this.target = target;
} }
/** /**
* Gets the name.
*
* @return the name * @return the name
*/ */
public String getName() { public String getName() {
@ -177,7 +208,9 @@ public class UserProfileField implements UserData {
} }
/** /**
* @param name the name to set * Sets the name.
*
* @param name the new name
*/ */
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;

View File

@ -4,8 +4,7 @@
package de.bstly.we.model; package de.bstly.we.model;
/** /**
* @author _bastler@bstly.de * The Enum UserStatus.
*
*/ */
public enum UserStatus { public enum UserStatus {

View File

@ -19,8 +19,7 @@ import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption; import org.hibernate.annotations.LazyCollectionOption;
/** /**
* @author _bastler@bstly.de * The Class UserTotp.
*
*/ */
@Entity @Entity
@Table(name = "user_totps", uniqueConstraints = @UniqueConstraint(columnNames = { "target" })) @Table(name = "user_totps", uniqueConstraints = @UniqueConstraint(columnNames = { "target" }))
@ -42,6 +41,8 @@ public class UserTotp implements SecondFactor {
private List<String> recoveryCodes; private List<String> recoveryCodes;
/** /**
* Gets the id.
*
* @return the id * @return the id
*/ */
public Long getId() { public Long getId() {
@ -49,13 +50,17 @@ public class UserTotp implements SecondFactor {
} }
/** /**
* @param id the id to set * Sets the id.
*
* @param id the new id
*/ */
public void setId(Long id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
/** /**
* Gets the target.
*
* @return the target * @return the target
*/ */
public Long getTarget() { public Long getTarget() {
@ -63,27 +68,35 @@ public class UserTotp implements SecondFactor {
} }
/** /**
* @param target the target to set * Sets the target.
*
* @param target the new target
*/ */
public void setTarget(Long target) { public void setTarget(Long target) {
this.target = target; this.target = target;
} }
/** /**
* @return the enabled * Checks if is enabled.
*
* @return true, if is enabled
*/ */
public boolean isEnabled() { public boolean isEnabled() {
return enabled; return enabled;
} }
/** /**
* @param enabled the enabled to set * Sets the enabled.
*
* @param enabled the new enabled
*/ */
public void setEnabled(boolean enabled) { public void setEnabled(boolean enabled) {
this.enabled = enabled; this.enabled = enabled;
} }
/** /**
* Gets the secret.
*
* @return the secret * @return the secret
*/ */
public String getSecret() { public String getSecret() {
@ -91,35 +104,45 @@ public class UserTotp implements SecondFactor {
} }
/** /**
* @param secret the secret to set * Sets the secret.
*
* @param secret the new secret
*/ */
public void setSecret(String secret) { public void setSecret(String secret) {
this.secret = secret; this.secret = secret;
} }
/** /**
* @return the qrData * Gets the qr data.
*
* @return the qr data
*/ */
public String getQrData() { public String getQrData() {
return qrData; return qrData;
} }
/** /**
* @param qrData the qrData to set * Sets the qr data.
*
* @param qrData the new qr data
*/ */
public void setQrData(String qrData) { public void setQrData(String qrData) {
this.qrData = qrData; this.qrData = qrData;
} }
/** /**
* @return the recoveryCodes * Gets the recovery codes.
*
* @return the recovery codes
*/ */
public List<String> getRecoveryCodes() { public List<String> getRecoveryCodes() {
return recoveryCodes; return recoveryCodes;
} }
/** /**
* @param recoveryCodes the recoveryCodes to set * Sets the recovery codes.
*
* @param recoveryCodes the new recovery codes
*/ */
public void setRecoveryCodes(List<String> recoveryCodes) { public void setRecoveryCodes(List<String> recoveryCodes) {
this.recoveryCodes = recoveryCodes; this.recoveryCodes = recoveryCodes;

View File

@ -4,8 +4,7 @@
package de.bstly.we.model; package de.bstly.we.model;
/** /**
* @author _bastler@bstly.de * The Enum Visibility.
*
*/ */
public enum Visibility { public enum Visibility {

View File

@ -0,0 +1,123 @@
/**
*
*/
package de.bstly.we.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* The Class VoucherMapping.
*/
@Entity
@Table(name = "voucher_mappings")
public class VoucherMapping {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", updatable = false)
private Long id;
@Column(name = "name", nullable = false)
private String name;
@Column(name = "quota", nullable = true)
private String quota;
@Column(name = "voucher", nullable = false)
private int voucher;
@Column(name = "free", columnDefinition = "boolean default false")
private boolean free;
/**
* Gets the id.
*
* @return the id
*/
public Long getId() {
return id;
}
/**
* Sets the id.
*
* @param id the new id
*/
public void setId(Long id) {
this.id = id;
}
/**
* Gets the name.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Sets the name.
*
* @param name the new name
*/
public void setName(String name) {
this.name = name;
}
/**
* Gets the quota.
*
* @return the quota
*/
public String getQuota() {
return quota;
}
/**
* Sets the quota.
*
* @param quota the new quota
*/
public void setQuota(String quota) {
this.quota = quota;
}
/**
* Gets the voucher.
*
* @return the voucher
*/
public int getVoucher() {
return voucher;
}
/**
* Sets the voucher.
*
* @param voucher the new voucher
*/
public void setVoucher(int voucher) {
this.voucher = voucher;
}
/**
* Checks if is free.
*
* @return true, if is free
*/
public boolean isFree() {
return free;
}
/**
* Sets the free.
*
* @param free the new free
*/
public void setFree(boolean free) {
this.free = free;
}
}

View File

@ -10,9 +10,7 @@ import org.springframework.stereotype.Repository;
import de.bstly.we.model.PermissionMapping; import de.bstly.we.model.PermissionMapping;
/** /**
* * The Interface PermissionMappingRepository.
* @author _bastler@bstly.de
*
*/ */
@Repository @Repository
public interface PermissionMappingRepository public interface PermissionMappingRepository

View File

@ -10,9 +10,7 @@ import org.springframework.stereotype.Repository;
import de.bstly.we.model.Permission; import de.bstly.we.model.Permission;
/** /**
* * The Interface PermissionRepository.
* @author _bastler@bstly.de
*
*/ */
@Repository @Repository
public interface PermissionRepository public interface PermissionRepository

View File

@ -10,9 +10,7 @@ import org.springframework.stereotype.Repository;
import de.bstly.we.model.QuotaMapping; import de.bstly.we.model.QuotaMapping;
/** /**
* * The Interface QuotaMappingRepository.
* @author _bastler@bstly.de
*
*/ */
@Repository @Repository
public interface QuotaMappingRepository public interface QuotaMappingRepository

View File

@ -10,9 +10,7 @@ import org.springframework.stereotype.Repository;
import de.bstly.we.model.Quota; import de.bstly.we.model.Quota;
/** /**
* * The Interface QuotaRepository.
* @author _bastler@bstly.de
*
*/ */
@Repository @Repository
public interface QuotaRepository extends JpaRepository<Quota, Long>, QuerydslPredicateExecutor<Quota> { public interface QuotaRepository extends JpaRepository<Quota, Long>, QuerydslPredicateExecutor<Quota> {

View File

@ -10,9 +10,7 @@ import org.springframework.stereotype.Repository;
import de.bstly.we.model.SystemProfileField; import de.bstly.we.model.SystemProfileField;
/** /**
* * The Interface SystemProfileFieldRepository.
* @author _bastler@bstly.de
*
*/ */
@Repository @Repository
public interface SystemProfileFieldRepository extends JpaRepository<SystemProfileField, String>, public interface SystemProfileFieldRepository extends JpaRepository<SystemProfileField, String>,

View File

@ -10,9 +10,7 @@ import org.springframework.stereotype.Repository;
import de.bstly.we.model.SystemProperty; import de.bstly.we.model.SystemProperty;
/** /**
* * The Interface SystemPropertyRepository.
* @author _bastler@bstly.de
*
*/ */
@Repository @Repository
public interface SystemPropertyRepository public interface SystemPropertyRepository

View File

@ -10,9 +10,7 @@ import org.springframework.stereotype.Repository;
import de.bstly.we.model.UserAlias; import de.bstly.we.model.UserAlias;
/** /**
* * The Interface UserAliasRepository.
* @author _bastler@bstly.de
*
*/ */
@Repository @Repository
public interface UserAliasRepository public interface UserAliasRepository

View File

@ -10,9 +10,7 @@ import org.springframework.stereotype.Repository;
import de.bstly.we.model.UserDomain; import de.bstly.we.model.UserDomain;
/** /**
* * The Interface UserDomainRepository.
* @author _bastler@bstly.de
*
*/ */
@Repository @Repository
public interface UserDomainRepository public interface UserDomainRepository

View File

@ -11,9 +11,7 @@ import de.bstly.we.model.UserProfileField;
import de.bstly.we.model.UserProfileField.UserProfileFieldId; import de.bstly.we.model.UserProfileField.UserProfileFieldId;
/** /**
* * The Interface UserProfileFieldRepository.
* @author _bastler@bstly.de
*
*/ */
@Repository @Repository
public interface UserProfileFieldRepository public interface UserProfileFieldRepository

Some files were not shown because too many files have changed in this diff Show More