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;
/**
*
* @author _bastler@bstly.de
*
* The Class Application.
*/
@SpringBootApplication
@EnableScheduling
public class Application extends SpringBootServletInitializer {
/**
* @param args
* The main method.
*
* @param args the arguments
*/
public static void main(String[] 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
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;
/**
*
* @author _bastler@bstly.de
*
* The Class CoreConfiguration.
*/
@Configuration
public class CoreConfiguration {
@ -22,6 +20,11 @@ public class CoreConfiguration {
@Autowired
private EntityManager em;
/**
* Jpa query factory.
*
* @return the JPA query factory
*/
@Bean
public JPAQueryFactory jpaQueryFactory() {
return new JPAQueryFactory(em);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -18,9 +18,7 @@ import de.bstly.we.model.UserData;
import de.bstly.we.repository.QuotaRepository;
/**
*
* @author _bastler@bstly.de
*
* The Class QuotaManager.
*/
@Component
public class QuotaManager implements UserDataProvider {
@ -32,10 +30,11 @@ public class QuotaManager implements UserDataProvider {
private QQuota qQuota = QQuota.quota;
/**
* Gets the.
*
* @param target
* @param name
* @return
* @param target the target
* @param name the name
* @return the quota
*/
public Quota get(Long target, String name) {
if (target != null && name != null) {
@ -46,18 +45,20 @@ public class QuotaManager implements UserDataProvider {
}
/**
* Gets the all by name.
*
* @param name
* @return
* @param name the name
* @return the all by name
*/
public List<Quota> getAllByName(String name) {
return Lists.newArrayList(quotaRepository.findAll(qQuota.name.eq(name)));
}
/**
* Gets the all by target.
*
* @param target
* @return
* @param target the target
* @return the all by target
*/
public List<Quota> getAllByTarget(Long target) {
if (target != null) {
@ -67,9 +68,10 @@ public class QuotaManager implements UserDataProvider {
}
/**
* Gets the not expires by target.
*
* @param target
* @return
* @param target the target
* @return the not expires by target
*/
public List<Quota> getNotExpiresByTarget(Long target) {
if (target != null) {
@ -80,10 +82,11 @@ public class QuotaManager implements UserDataProvider {
}
/**
* Checks for quota.
*
* @param target
* @param name
* @return
* @param target the target
* @param name the name
* @return true, if successful
*/
public boolean hasQuota(Long target, String name) {
return target != null && quotaRepository
@ -91,13 +94,14 @@ public class QuotaManager implements UserDataProvider {
}
/**
* Creates the.
*
* @param target
* @param name
* @param addon
* @param value
* @param unit
* @return
* @param target the target
* @param name the name
* @param value the value
* @param unit the unit
* @param disposable the disposable
* @return the quota
*/
public Quota create(Long target, String name, long value, String unit, boolean disposable) {
Quota newQuota = new Quota();
@ -111,9 +115,10 @@ public class QuotaManager implements UserDataProvider {
}
/**
* Update.
*
* @param quota
* @return
* @param quota the quota
* @return the quota
*/
public Quota update(Quota quota) {
Assert.isTrue(
@ -131,10 +136,12 @@ public class QuotaManager implements UserDataProvider {
}
/**
* Clone.
*
* @param name
* @param clone
* @return
* @param name the name
* @param clone the clone
* @param value the value
* @return the list
*/
public List<Quota> clone(String name, String clone, long value) {
List<Quota> quotas = Lists.newArrayList();
@ -151,9 +158,10 @@ public class QuotaManager implements UserDataProvider {
}
/**
* Delete.
*
* @param target
* @param name
* @param target the target
* @param name the name
*/
public void delete(Long target, String 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) {
quotaRepository.deleteAll(quotaRepository.findAll(qQuota.target.eq(target)));
}
/**
* Delete all.
*
* @param name
* @param name the name
*/
public void deleteAll(String name) {
quotaRepository.deleteAll(quotaRepository.findAll(qQuota.name.eq(name)));
}
/**
* Apply item.
*
* @param target
* @param item
* @param target the target
* @param item the item
*/
public void applyItem(Long target, Integer 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;
/**
*
* @author _bastler@bstly.de
*
* The Class QuotaMappingManager.
*/
@Component
public class QuotaMappingManager {
@ -32,9 +30,10 @@ public class QuotaMappingManager {
private QQuotaMapping qQuotaMapping = QQuotaMapping.quotaMapping;
/**
* Gets the all by item.
*
* @param item
* @return
* @param item the item
* @return the all by item
*/
public List<QuotaMapping> getAllByItem(Integer item) {
return Lists
@ -42,19 +41,21 @@ public class QuotaMappingManager {
}
/**
* Exists.
*
* @param item
* @return
* @param item the item
* @return true, if successful
*/
public boolean exists(Integer item) {
return quotaMappingRepository.exists(qQuotaMapping.items.contains(item));
}
/**
* Exists.
*
* @param item
* @param name
* @return
* @param item the item
* @param name the name
* @return true, if successful
*/
public boolean exists(Integer item, String name) {
return quotaMappingRepository
@ -62,11 +63,16 @@ public class QuotaMappingManager {
}
/**
* Creates the.
*
* @param item
* @param quota
* @param lifetime
* @return
* @param items the items
* @param name the name
* @param value the value
* @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,
boolean append, Set<String> products, boolean disposable) {
@ -86,9 +92,10 @@ public class QuotaMappingManager {
}
/**
* Update.
*
* @param quotaMapping
* @return
* @param quotaMapping the quota mapping
* @return the quota mapping
*/
public QuotaMapping update(QuotaMapping quotaMapping) {
Assert.isTrue(
@ -108,9 +115,9 @@ public class QuotaMappingManager {
}
/**
* Delete.
*
* @param item
* @param name
* @param id the id
*/
public void delete(Long id) {
Assert.isTrue(quotaMappingRepository.existsById(id),
@ -119,12 +126,13 @@ public class QuotaMappingManager {
}
/**
* Gets the.
*
* @param page
* @param size
* @param sortBy
* @param descending
* @return
* @param page the page
* @param size the size
* @param sortBy the sort by
* @param descending the descending
* @return the page
*/
public Page<QuotaMapping> get(int page, int size, String sortBy, boolean descending) {
Sort sort = descending ? Sort.by(sortBy).descending() : Sort.by(sortBy).ascending();

View File

@ -4,12 +4,10 @@
package de.bstly.we.businesslogic;
/**
* @author _bastler@bstly.de
*
* The Interface Quotas.
*/
public interface Quotas {
public static final String REGISTRATION_VOUCHERS = "registration_vouchers";
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;
/**
*
* @author _bastler@bstly.de
*
* The Class Setup.
*/
@Component
public class Setup implements SmartInitializingSingleton {
@ -54,9 +52,9 @@ public class Setup implements SmartInitializingSingleton {
private Logger logger = LoggerFactory.getLogger(Setup.class);
/*
* @see org.springframework.beans.factory.SmartInitializingSingleton#
* afterSingletonsInstantiated()
* @see org.springframework.beans.factory.SmartInitializingSingleton#afterSingletonsInstantiated()
*/
@Override
public void afterSingletonsInstantiated() {

View File

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

View File

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

View File

@ -20,8 +20,7 @@ import de.bstly.we.model.UserData;
import de.bstly.we.repository.UserAliasRepository;
/**
* @author _bastler@bstly.de
*
* The Class UserAliasManager.
*/
@Component
public class UserAliasManager implements UserDataProvider {
@ -33,18 +32,20 @@ public class UserAliasManager implements UserDataProvider {
private QUserAlias qUserAlias = QUserAlias.userAlias;
/**
* Gets the.
*
* @param id
* @return
* @param id the id
* @return the user alias
*/
public UserAlias get(Long id) {
return userAliasRepository.findById(id).orElse(null);
}
/**
* Save.
*
* @param userAlias
* @return
* @param userAlias the user alias
* @return the user alias
*/
public UserAlias save(UserAlias userAlias) {
Assert.notNull(userAlias.getAlias(), "No alias defined!");
@ -54,26 +55,29 @@ public class UserAliasManager implements UserDataProvider {
}
/**
* Gets the by alias.
*
* @param alias
* @return
* @param alias the alias
* @return the by alias
*/
public UserAlias getByAlias(String alias) {
return userAliasRepository.findOne(qUserAlias.alias.eq(alias)).orElse(null);
}
/**
* Gets the all by target.
*
* @param userId
* @return
* @param userId the user id
* @return the all by target
*/
public List<UserAlias> getAllByTarget(Long userId) {
return Lists.newArrayList(userAliasRepository.findAll(qUserAlias.target.eq(userId)));
}
/**
* Delete.
*
* @param id
* @param id the id
*/
public void delete(Long id) {
UserAlias userAlias = get(id);
@ -83,12 +87,13 @@ public class UserAliasManager implements UserDataProvider {
}
/**
* Gets the.
*
* @param page
* @param size
* @param sortBy
* @param descending
* @return
* @param page the page
* @param size the size
* @param sortBy the sort by
* @param descending the descending
* @return the page
*/
public Page<UserAlias> get(int page, int size, String sortBy, boolean descending) {
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;
/**
* @author _bastler@bstly.de
*
* The Class UserDataManager.
*/
@Component
public class UserDataManager implements SmartInitializingSingleton {
@ -61,9 +60,9 @@ public class UserDataManager implements SmartInitializingSingleton {
private List<UserDataProvider> providers;
private Gson gson = new Gson();
/*
* @see org.springframework.beans.factory.SmartInitializingSingleton#
* afterSingletonsInstantiated()
* @see org.springframework.beans.factory.SmartInitializingSingleton#afterSingletonsInstantiated()
*/
@Override
public void afterSingletonsInstantiated() {
@ -75,7 +74,7 @@ public class UserDataManager implements SmartInitializingSingleton {
}
/**
*
* Purge.
*/
@Scheduled(cron = "${we.bstly.userdata.cron:0 0 0 * * * }")
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) {
Long userId = user.getId();
@ -161,9 +162,10 @@ public class UserDataManager implements SmartInitializingSingleton {
}
/**
* Gets the.
*
* @param userId
* @return
* @param userId the user id
* @return the map
*/
public Map<String, List<UserData>> get(Long userId) {
Map<String, List<UserData>> userData = Maps.newHashMap();

View File

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

View File

@ -30,8 +30,7 @@ import de.bstly.we.model.UserDomain;
import de.bstly.we.repository.UserDomainRepository;
/**
* @author _bastler@bstly.de
*
* The Class UserDomainManager.
*/
@Component
public class UserDomainManager implements UserDataProvider {
@ -47,7 +46,7 @@ public class UserDomainManager implements UserDataProvider {
private InitialDirContext dirContext;
/**
*
* Instantiates a new user domain manager.
*/
public UserDomainManager() {
Hashtable<String, String> env = new Hashtable<String, String>();
@ -63,18 +62,20 @@ public class UserDomainManager implements UserDataProvider {
}
/**
* Gets the.
*
* @param id
* @return
* @param id the id
* @return the user domain
*/
public UserDomain get(Long id) {
return userDomainRepository.findById(id).orElse(null);
}
/**
* Save.
*
* @param userDomain
* @return
* @param userDomain the user domain
* @return the user domain
*/
public UserDomain save(UserDomain userDomain) {
Assert.notNull(userDomain.getDomain(), "No domain defined!");
@ -84,26 +85,29 @@ public class UserDomainManager implements UserDataProvider {
}
/**
* Gets the by domain.
*
* @param domain
* @return
* @param domain the domain
* @return the by domain
*/
public UserDomain getByDomain(String domain) {
return userDomainRepository.findOne(qUserDomain.domain.eq(domain)).orElse(null);
}
/**
* Gets the all by target.
*
* @param userId
* @return
* @param userId the user id
* @return the all by target
*/
public List<UserDomain> getAllByTarget(Long userId) {
return Lists.newArrayList(userDomainRepository.findAll(qUserDomain.target.eq(userId)));
}
/**
* Delete.
*
* @param id
* @param id the id
*/
public void delete(Long id) {
UserDomain userDomain = get(id);
@ -113,12 +117,13 @@ public class UserDomainManager implements UserDataProvider {
}
/**
* Gets the.
*
* @param page
* @param size
* @param sortBy
* @param descending
* @return
* @param page the page
* @param size the size
* @param sortBy the sort by
* @param descending the descending
* @return the page
*/
public Page<UserDomain> get(int page, int size, String sortBy, boolean descending) {
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 * * * *")
public void validate() {
@ -149,9 +154,11 @@ public class UserDomainManager implements UserDataProvider {
}
/**
* Validate.
*
* @param userDomain
* @throws NamingException
* @param userDomain the user domain
* @return true, if successful
* @throws NamingException the naming exception
*/
public boolean validate(UserDomain userDomain) throws NamingException {
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;
/**
*
* @author _bastler@bstly.de
*
* The Class UserManager.
*/
@Component
public class UserManager implements UserDataProvider {
@ -63,34 +61,40 @@ public class UserManager implements UserDataProvider {
private String userEmailDomain;
/**
* @param id
* @return
* Gets the.
*
* @param id the id
* @return the user
*/
public User get(Long id) {
return userRepository.findById(id).orElse(null);
}
/**
* Gets the by username.
*
* @param username
* @return
* @param username the username
* @return the by username
*/
public User getByUsername(String username) {
return userRepository.findOne(qUser.username.equalsIgnoreCase(username)).orElse(null);
}
/**
* Gets the by reset token.
*
* @param resetToken
* @return
* @param resetToken the reset token
* @return the by reset token
*/
public User getByResetToken(String resetToken) {
return userRepository.findOne(qUser.resetToken.eq(resetToken)).orElse(null);
}
/**
* @param id
* @return
* Gets the password hash.
*
* @param id the id
* @return the password hash
*/
public String getPasswordHash(Long id) {
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 passwordHash
* @param id the id
* @param password the password
* @return the user
*/
public User setPassword(Long id, String password) {
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 email
* @param password
* @param publicKey
* @return
* @param username the username
* @param password the password
* @param status the status
* @return the user
*/
public User create(String username, String password, UserStatus status) {
Assert.isTrue(!userRepository.exists(qUser.username.equalsIgnoreCase(username)),
@ -134,12 +140,13 @@ public class UserManager implements UserDataProvider {
}
/**
* Gets the.
*
* @param page
* @param size
* @param sortBy
* @param descending
* @return
* @param page the page
* @param size the size
* @param sortBy the sort by
* @param descending the descending
* @return the page
*/
public Page<User> get(int page, int size, String sortBy, boolean descending) {
Sort sort = descending ? Sort.by(sortBy).descending() : Sort.by(sortBy).ascending();
@ -147,8 +154,10 @@ public class UserManager implements UserDataProvider {
}
/**
* @param user
* @return
* Update.
*
* @param user the user
* @return the user
*/
public User update(User user) {
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) {
Assert.isTrue(userRepository.existsById(user.getId()),
@ -186,18 +196,20 @@ public class UserManager implements UserDataProvider {
}
/**
* Gets the bstly email.
*
* @param username
* @return
* @param username the username
* @return the bstly email
*/
public String getBstlyEmail(String username) {
return username + "@" + userEmailDomain;
}
/**
* Write public key.
*
* @param username
* @param publicKey
* @param username the username
* @param publicKey the public key
*/
public void writePublicKey(String username, String publicKey) {
if (StringUtils.hasText(publicKey)) {
@ -225,17 +237,20 @@ public class UserManager implements UserDataProvider {
}
/**
* Gets the public key path.
*
* @param username
* @return
* @param username the username
* @return the public key path
*/
public String getPublicKeyPath(String username) {
return userDataDirectory + username + File.separator + "public.key";
}
/**
* @param user
* @param outputStream
* Password reset.
*
* @param user the user
* @param outputStream the output stream
*/
public void passwordReset(User user, ServletOutputStream outputStream) {
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) {
Map<String, ? extends Session> usersSessions = sessionRepository

View File

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

View File

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

View File

@ -23,8 +23,7 @@ import dev.samstevens.totp.recovery.RecoveryCodeGenerator;
import dev.samstevens.totp.secret.SecretGenerator;
/**
* @author _bastler@bstly.de
*
* The Class UserTotpManager.
*/
@Component
public class UserTotpManager implements SecondFactorProvider<UserTotp> {
@ -51,21 +50,18 @@ public class UserTotpManager implements SecondFactorProvider<UserTotp> {
return "totp";
}
/*
* @see
* de.bstly.we.security.businesslogic.SecondFactorProvider#supports(java.lang.
* String)
* @see de.bstly.we.security.businesslogic.SecondFactorProvider#supports(java.lang.String)
*/
@Override
public boolean supports(String 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
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
public boolean validate(Long userId, String code) {
@ -90,20 +83,18 @@ public class UserTotpManager implements SecondFactorProvider<UserTotp> {
return false;
}
/*
* @see
* de.bstly.we.security.businesslogic.SecondFactorProvider#getForUser(java.lang.
* Long)
* @see de.bstly.we.security.businesslogic.SecondFactorProvider#get(java.lang.Long)
*/
@Override
public UserTotp get(Long userId) {
return userTotpRepository.findOne(qUserTotp.target.eq(userId)).orElse(null);
}
/*
* @see
* de.bstly.we.security.businesslogic.SecondFactorProvider#createByUser(java.
* lang.Long)
* @see de.bstly.we.security.businesslogic.SecondFactorProvider#create(java.lang.Long)
*/
@Override
public UserTotp create(Long userId) {
@ -123,10 +114,9 @@ public class UserTotpManager implements SecondFactorProvider<UserTotp> {
return userTotpRepository.findOne(qUserTotp.target.eq(userId)).orElse(null);
}
/*
* @see
* de.bstly.we.security.businesslogic.SecondFactorProvider#enableByUser(java.
* lang.Long, java.lang.String)
* @see de.bstly.we.security.businesslogic.SecondFactorProvider#enable(java.lang.Long, java.lang.String)
*/
@Override
public boolean enable(Long userId, String code) {
@ -140,10 +130,9 @@ public class UserTotpManager implements SecondFactorProvider<UserTotp> {
return false;
}
/*
* @see
* de.bstly.we.security.businesslogic.SecondFactorProvider#deleteByUser(java.
* lang.Long)
* @see de.bstly.we.security.businesslogic.SecondFactorProvider#delete(java.lang.Long)
*/
@Override
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;
/**
* @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
public class AbstractModelEventListener {
@ -29,36 +36,71 @@ public class AbstractModelEventListener {
@Autowired
private ApplicationEventPublisher applicationEventPublisher;
/**
* Pre persist.
*
* @param model the model
*/
@PrePersist
private void prePersist(AbstractModel model) {
applicationEventPublisher.publishEvent(new AbstractModelEvent(AbstractModelEventType.PRE_PERSIST, model));
}
/**
* Pre update.
*
* @param model the model
*/
@PreUpdate
private void preUpdate(AbstractModel model) {
applicationEventPublisher.publishEvent(new AbstractModelEvent(AbstractModelEventType.PRE_UPDATE, model));
}
/**
* Pre remove.
*
* @param model the model
*/
@PreRemove
private void preRemove(AbstractModel model) {
applicationEventPublisher.publishEvent(new AbstractModelEvent(AbstractModelEventType.PRE_REMOVE, model));
}
/**
* Post persist.
*
* @param model the model
*/
@PostPersist
private void postPersist(AbstractModel model) {
applicationEventPublisher.publishEvent(new AbstractModelEvent(AbstractModelEventType.POST_PERSIST, model));
}
/**
* Post update.
*
* @param model the model
*/
@PostUpdate
private void postUpdate(AbstractModel model) {
applicationEventPublisher.publishEvent(new AbstractModelEvent(AbstractModelEventType.POST_UPDATE, model));
}
/**
* Post remove.
*
* @param model the model
*/
@PostRemove
private void postRemove(AbstractModel model) {
applicationEventPublisher.publishEvent(new AbstractModelEvent(AbstractModelEventType.POST_REMOVE, model));
}
/**
* Post load.
*
* @param model the model
*/
@PostLoad
private void postLoad(AbstractModel 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;
/**
* @author _bastler@bstly.de
*
* The Class InstantHelper.
*/
public class InstantHelper {
/**
* Plus.
*
* @param instant
* @param amount
* @return
* @param instant the instant
* @param amount the amount
* @return the instant
*/
public static Instant plus(Instant instant, TemporalAmount amount) {
return ZonedDateTime.ofInstant(instant, ZoneOffset.UTC).plus(amount).toInstant();
}
/**
* Plus.
*
* @param instant
* @param amountToAdd
* @param unit
* @return
* @param instant the instant
* @param amountToAdd the amount to add
* @param unit the unit
* @return the instant
*/
public static Instant plus(Instant instant, long amountToAdd, TemporalUnit unit) {
return ZonedDateTime.ofInstant(instant, ZoneOffset.UTC).plus(amountToAdd, unit).toInstant();
}
/**
* Minus.
*
* @param instant
* @param amount
* @return
* @param instant the instant
* @param amount the amount
* @return the instant
*/
public static Instant minus(Instant instant, TemporalAmount amount) {
return ZonedDateTime.ofInstant(instant, ZoneOffset.UTC).minus(amount).toInstant();
}
/**
* Minus.
*
* @param instant
* @param amountToAdd
* @param unit
* @return
* @param instant the instant
* @param amountToAdd the amount to add
* @param unit the unit
* @return the instant
*/
public static Instant minus(Instant instant, long amountToAdd, TemporalUnit unit) {
return ZonedDateTime.ofInstant(instant, ZoneOffset.UTC).minus(amountToAdd, unit)
@ -61,10 +64,11 @@ public class InstantHelper {
}
/**
* Truncate.
*
* @param instant
* @param unit
* @return
* @param instant the instant
* @param unit the unit
* @return the instant
*/
public static Instant truncate(Instant instant, TemporalUnit 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;
/**
*
* @author _bastler@bstly.de
*
* The Class Authentication2FAController.
*/
@RestController
@RequestMapping("/auth/2fa")
@ -43,8 +41,9 @@ public class Authentication2FAController extends BaseController {
private SecondFactorProviderManager secondFactorProviderManager;
/**
* Gets the pre authentication id.
*
* @return
* @return the pre authentication id
*/
protected Long getPreAuthenticationId() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
@ -56,8 +55,9 @@ public class Authentication2FAController extends BaseController {
}
/**
* Gets the enabled.
*
* @return
* @return the enabled
*/
@GetMapping
public List<SecondFactorProviderModel> getEnabled() {
@ -77,8 +77,9 @@ public class Authentication2FAController extends BaseController {
}
/**
* Gets the available.
*
* @return
* @return the available
*/
@GetMapping("/available")
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")
@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')")
@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")
@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")
@PatchMapping("/{id}")
@ -185,7 +193,9 @@ public class Authentication2FAController extends BaseController {
}
/**
* Removes the second factor mail.
*
* @param providerId the provider id
*/
@PreAuthorize("authentication.authenticated")
@DeleteMapping("/{id}")

View File

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

View File

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

View File

@ -34,9 +34,7 @@ import de.bstly.we.controller.support.TokenSessionManager;
import de.bstly.we.model.User;
/**
*
* @author _bastler@bstly.de
*
* The Class ItemController.
*/
@RestController
@RequestMapping("/items")
@ -50,7 +48,10 @@ public class ItemController extends BaseController {
private UserManager userManager;
/**
* Gets the items.
*
* @param session the session
* @return the items
*/
@GetMapping
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("")
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
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()")
@PostMapping
@ -121,9 +128,10 @@ public class ItemController extends BaseController {
}
/**
* Redeem for user.
*
* @param username
* @param session
* @param username the username
* @param session the session
*/
@PreAuthorize("isAuthenticated()")
@PostMapping("/{username}")

View File

@ -19,9 +19,7 @@ import de.bstly.we.controller.support.TokenSessionManager;
import de.bstly.we.model.Permission;
/**
*
* @author _bastler@bstly.de
*
* The Class PermissionController.
*/
@RestController
@RequestMapping("/permissions")
@ -33,8 +31,9 @@ public class PermissionController extends BaseController {
private TokenSessionManager tokenSessionManager;
/**
* Gets the permissions.
*
* @return
* @return the permissions
*/
@GetMapping
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")
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")
public List<Permission> getAllPermissions() {

View File

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

View File

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

View File

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

View File

@ -20,9 +20,7 @@ import de.bstly.we.model.Quota;
import de.bstly.we.model.QuotaMapping;
/**
*
* @author _bastler@bstly.de
*
* The Class QuotaController.
*/
@RestController
@RequestMapping("/quotas")
@ -34,8 +32,9 @@ public class QuotaController extends BaseController {
private TokenSessionManager tokenSessionManager;
/**
* Gets the quotas.
*
* @return
* @return the quotas
*/
@GetMapping
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")
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")
public List<Quota> getAllQuotas() {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,24 +3,28 @@
*/
package de.bstly.we.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.beust.jcommander.internal.Lists;
import de.bstly.we.businesslogic.PermissionManager;
import de.bstly.we.businesslogic.PretixManager;
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.model.Quota;
import de.bstly.we.model.VoucherMapping;
/**
*
* @author _bastler@bstly.de
*
* The Class VoucherController.
*/
@RestController
@RequestMapping("/vouchers")
@ -29,47 +33,72 @@ public class VoucherController extends BaseController {
@Autowired
private QuotaManager quotaManager;
@Autowired
private PretixManager pretixManager;
private VoucherMappingManager voucherMappingManager;
@Autowired
private PermissionManager permissionManager;
/**
* Available.
*
* @return
* @return the list
*/
@PreAuthorize("isAuthenticated()")
@PostMapping("/registration")
public String getRegistrationVoucher() {
Quota registrationVouchers = quotaManager.get(getCurrentUserId(),
Quotas.REGISTRATION_VOUCHERS);
if (registrationVouchers == null || registrationVouchers.getValue() < 1) {
throw new EntityResponseStatusException(HttpStatus.CONFLICT);
}
@GetMapping()
public List<String> available() {
if (!permissionManager.isFullUser(getCurrentUserId())) {
throw new EntityResponseStatusException(HttpStatus.FORBIDDEN);
}
String result = pretixManager.createRegistrationVoucher().get("code").getAsString();
List<String> available = Lists.newArrayList();
registrationVouchers.setValue(registrationVouchers.getValue() - 1);
quotaManager.update(registrationVouchers);
for (VoucherMapping voucherMapping : voucherMappingManager.getForUser(getCurrentUserId())) {
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
*/
@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;
/**
* @author _bastler@bstly.de
*
* The Class MigrationController.
*/
@RestController
@RequestMapping("/migration")
@ -35,7 +34,7 @@ public class MigrationController extends BaseController {
private FindByIndexNameSessionRepository<? extends Session> sessionRepository;
/**
*
* Delete all sessions.
*/
@PreAuthorize("hasRole('ROLE_ADMIN')")
@DeleteMapping("/sessions")

View File

@ -6,8 +6,7 @@ package de.bstly.we.controller.model;
import java.util.Map;
/**
* @author _bastler@bstly.de
*
* The Class ItemModel.
*/
public class ItemModel {
@ -15,6 +14,8 @@ public class ItemModel {
private String secret;
/**
* Gets the name.
*
* @return the name
*/
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) {
this.name = name;
}
/**
* Gets the secret.
*
* @return the secret
*/
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) {
this.secret = secret;

View File

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

View File

@ -4,9 +4,7 @@
package de.bstly.we.controller.model;
/**
*
* @author _bastler@bstly.de
*
* The Class LoginModel.
*/
public class LoginModel {
@ -14,6 +12,8 @@ public class LoginModel {
private String password;
/**
* Gets the username.
*
* @return the username
*/
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) {
this.username = username;
}
/**
* Gets the password.
*
* @return the password
*/
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) {
this.password = password;

View File

@ -6,8 +6,9 @@ package de.bstly.we.controller.model;
import java.util.List;
/**
* @author _bastler@bstly.de
* The Class PagesResult.
*
* @param <T> the generic type
*/
public class PagesResult<T extends Object> {
@ -18,6 +19,8 @@ public class PagesResult<T extends Object> {
private int totalPages;
/**
* Gets the result.
*
* @return the result
*/
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) {
this.result = result;
}
/**
* Gets the size.
*
* @return the size
*/
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) {
this.size = size;
}
/**
* Gets the page.
*
* @return the page
*/
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) {
this.page = page;
}
/**
* @return the totalElements
* Gets the total elements.
*
* @return the total elements
*/
public int getTotalElements() {
return totalElements;
}
/**
* @param totalElements the totalElements to set
* Sets the total elements.
*
* @param totalElements the new total elements
*/
public void setTotalElements(int totalElements) {
this.totalElements = totalElements;
}
/**
* @return the totalPages
* Gets the total pages.
*
* @return the total pages
*/
public int getTotalPages() {
return totalPages;
}
/**
* @param totalPages the totalPages to set
* Sets the total pages.
*
* @param totalPages the new total pages
*/
public void setTotalPages(int totalPages) {
this.totalPages = totalPages;

View File

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

View File

@ -4,14 +4,15 @@
package de.bstly.we.controller.model;
/**
* @author _bastler@bstly.de
*
* The Class PasswordResetModel.
*/
public class PasswordResetModel extends PasswordModel {
private String token;
/**
* Gets the token.
*
* @return the token
*/
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) {
this.token = token;

View File

@ -8,9 +8,7 @@ import java.util.Map;
import org.springframework.http.HttpMethod;
/**
*
* @author _bastler@bstly.de
*
* The Class PretixRequest.
*/
public class PretixRequest {
@ -20,6 +18,8 @@ public class PretixRequest {
private Object payload;
/**
* Gets the path.
*
* @return the path
*/
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) {
this.path = path;
}
/**
* Gets the method.
*
* @return the method
*/
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) {
this.method = method;
}
/**
* @return the queryParameters
* Gets the query parameters.
*
* @return the query parameters
*/
public Map<String, String> getQueryParameters() {
return queryParameters;
}
/**
* @param queryParameters the queryParameters to set
* Sets the query parameters.
*
* @param queryParameters the query parameters
*/
public void setQueryParameters(Map<String, String> queryParameters) {
this.queryParameters = queryParameters;
}
/**
* Gets the payload.
*
* @return the payload
*/
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) {
this.payload = payload;

View File

@ -8,8 +8,7 @@ import java.util.List;
import de.bstly.we.model.UserProfileField;
/**
* @author _bastler@bstly.de
*
* The Class ProfileModel.
*/
public class ProfileModel {
@ -18,6 +17,8 @@ public class ProfileModel {
private List<UserProfileField> profileFields;
/**
* Gets the username.
*
* @return the username
*/
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) {
this.username = username;
}
/**
* Gets the aliases.
*
* @return the aliases
*/
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) {
this.aliases = aliases;
}
/**
* @return the profileFields
* Gets the profile fields.
*
* @return the profile fields
*/
public List<UserProfileField> getProfileFields() {
return profileFields;
}
/**
* @param profileFields the profileFields to set
* Sets the profile fields.
*
* @param profileFields the new profile fields
*/
public void setProfileFields(List<UserProfileField> profileFields) {
this.profileFields = profileFields;

View File

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

View File

@ -13,9 +13,7 @@ import de.bstly.we.model.UserProfileField;
import de.bstly.we.model.UserStatus;
/**
*
* @author _bastler@bstly.de
*
* The Class UserModel.
*/
public class UserModel extends PasswordModel {
@ -29,6 +27,8 @@ public class UserModel extends PasswordModel {
private List<UserProfileField> profileFields;
/**
* Gets the username.
*
* @return the username
*/
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) {
this.username = username;
}
/**
* Gets the permissions.
*
* @return the permissions
*/
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) {
this.permissions = permissions;
}
/**
* @return the permissionMappings
* Gets the permission mappings.
*
* @return the permission mappings
*/
public List<PermissionMapping> getPermissionMappings() {
return permissionMappings;
}
/**
* @param permissionMappings the permissionMappings to set
* Sets the permission mappings.
*
* @param permissionMappings the new permission mappings
*/
public void setPermissionMappings(List<PermissionMapping> permissionMappings) {
this.permissionMappings = permissionMappings;
}
/**
* Gets the quotas.
*
* @return the quotas
*/
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) {
this.quotas = quotas;
}
/**
* @return the quotaMappings
* Gets the quota mappings.
*
* @return the quota mappings
*/
public List<QuotaMapping> getQuotaMappings() {
return quotaMappings;
}
/**
* @param quotaMappings the quotaMappings to set
* Sets the quota mappings.
*
* @param quotaMappings the new quota mappings
*/
public void setQuotaMappings(List<QuotaMapping> quotaMappings) {
this.quotaMappings = quotaMappings;
}
/**
* Gets the status.
*
* @return the status
*/
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) {
this.status = status;
}
/**
* Gets the token.
*
* @return the token
*/
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) {
this.token = token;
}
/**
* @return the profileFields
* Gets the profile fields.
*
* @return the profile fields
*/
public List<UserProfileField> getProfileFields() {
return profileFields;
}
/**
* @param profileFields the profileFields to set
* Sets the profile fields.
*
* @param profileFields the new profile fields
*/
public void setProfileFields(List<UserProfileField> 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;
/**
*
* @author _bastler@bstly.de
*
* The Class ControllerExceptionHandler.
*/
@ControllerAdvice
public class ControllerExceptionHandler extends ResponseEntityExceptionHandler {
/**
* Handle response entity status exception.
*
* @param exception
* @param request
* @return
* @param exception the exception
* @param request the request
* @return the response entity
*/
@ExceptionHandler(value = { EntityResponseStatusException.class })
protected ResponseEntity<Object> handleResponseEntityStatusException(RuntimeException exception,

View File

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

View File

@ -22,18 +22,16 @@ import com.google.gson.Gson;
import com.google.gson.JsonPrimitive;
/**
* @author _bastler@bstly.de
*
* The Class JsonStringBodyControllerAdvice.
*/
@ControllerAdvice
public class JsonStringBodyControllerAdvice implements RequestBodyAdvice, ResponseBodyAdvice<String> {
private Gson gson = new Gson();
/*
* @see org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice#
* supports(org.springframework.core.MethodParameter, java.lang.reflect.Type,
* java.lang.Class)
* @see org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice#supports(org.springframework.core.MethodParameter, java.lang.reflect.Type, java.lang.Class)
*/
@Override
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#
* beforeBodyRead(org.springframework.http.HttpInputMessage,
* org.springframework.core.MethodParameter, java.lang.reflect.Type,
* java.lang.Class)
* @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)
*/
@Override
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType,
@ -53,11 +48,9 @@ public class JsonStringBodyControllerAdvice implements RequestBodyAdvice, Respon
return inputMessage;
}
/*
* @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)
* @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)
*/
@Override
public Object afterBodyRead(Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType,
@ -66,11 +59,9 @@ public class JsonStringBodyControllerAdvice implements RequestBodyAdvice, Respon
return body;
}
/*
* @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)
* @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)
*/
@Override
public Object handleEmptyBody(Object body, HttpInputMessage inputMessage, MethodParameter parameter,
@ -78,23 +69,18 @@ public class JsonStringBodyControllerAdvice implements RequestBodyAdvice, Respon
return body;
}
/*
* @see
* org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice#
* supports(org.springframework.core.MethodParameter, java.lang.Class)
* @see org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice#supports(org.springframework.core.MethodParameter, java.lang.Class)
*/
@Override
public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {
return converterType == StringHttpMessageConverter.class;
}
/*
* @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)
* @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)
*/
@Override
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;
/**
*
* @author _bastler@bstly.de
*
* The Class RequestBodyErrors.
*/
@SuppressWarnings("serial")
public class RequestBodyErrors extends AbstractBindingResult {
@ -18,9 +16,9 @@ public class RequestBodyErrors extends AbstractBindingResult {
private final Object target;
/**
* Instantiates a new request body errors.
*
* @param target
* @param objectName
* @param target the target
*/
public RequestBodyErrors(@Nullable Object target) {
super("request-body");
@ -35,10 +33,9 @@ public class RequestBodyErrors extends AbstractBindingResult {
return target;
}
/*
* @see
* org.springframework.validation.AbstractBindingResult#getActualFieldValue(java
* .lang.String)
* @see org.springframework.validation.AbstractBindingResult#getActualFieldValue(java.lang.String)
*/
@Override
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;
/**
*
* @author _bastler@bstly.de
*
* The Class TokenSessionManager.
*/
@Component
public class TokenSessionManager {
@ -53,10 +51,11 @@ public class TokenSessionManager {
private PretixManager pretixManager;
/**
* Gets the permission mappings for token.
*
* @param userId
* @param token
* @return
* @param userId the user id
* @param token the token
* @return the permission mappings for token
*/
public List<PermissionMapping> getPermissionMappingsForToken(Long userId, String token) {
List<PermissionMapping> permissionMappings = Lists.newArrayList();
@ -76,10 +75,11 @@ public class TokenSessionManager {
}
/**
* Gets the permissions for token.
*
* @param userId
* @param token
* @return
* @param userId the user id
* @param token the token
* @return the permissions for token
*/
public List<Permission> getPermissionsForToken(Long userId, String token) {
List<Permission> permissions = Lists.newArrayList();
@ -109,10 +109,11 @@ public class TokenSessionManager {
}
/**
* Gets the quota mappings for token.
*
* @param userId
* @param token
* @return
* @param userId the user id
* @param token the token
* @return the quota mappings for token
*/
public List<QuotaMapping> getQuotaMappingsForToken(Long userId, String token) {
List<QuotaMapping> quotaMappings = Lists.newArrayList();
@ -132,10 +133,11 @@ public class TokenSessionManager {
}
/**
* Apply tokens.
*
* @param userId
* @param tokens
* @return
* @param userId the user id
* @param tokens the tokens
* @return the item result model
*/
public ItemResultModel applyTokens(Long userId, Set<String> tokens) {
ItemResultModel itemResultModel = new ItemResultModel();
@ -173,9 +175,10 @@ public class TokenSessionManager {
}
/**
* Gets the token from session.
*
* @param session
* @return
* @param session the session
* @return the token from session
*/
public Set<String> getTokenFromSession(HttpSession session) {
@ -195,9 +198,10 @@ public class TokenSessionManager {
}
/**
* Adds the token to session.
*
* @param secret
* @return
* @param secret the secret
* @param session the session
*/
public void addTokenToSession(String secret, HttpSession session) {
@ -220,9 +224,10 @@ public class TokenSessionManager {
}
/**
* Removes the token from session.
*
* @param secret
* @return
* @param secret the secret
* @param session the session
*/
public void removeTokenFromSession(String secret, HttpSession session) {
String tokens = "";
@ -245,19 +250,20 @@ public class TokenSessionManager {
}
/**
* Removes the tokens from session.
*
* @param secret
* @return
* @param session the session
*/
public void removeTokensFromSession(HttpSession session) {
session.setAttribute(HTTP_SESSION_ATTRIBUTE_TOKENS, null);
}
/**
* Creates the new auth.
*
* @param auth
* @param details
* @return
* @param auth the auth
* @param details the details
* @return the authentication
*/
protected Authentication createNewAuth(Authentication auth, LocalUserDetails details) {
Authentication newAuth = null;

View File

@ -24,9 +24,7 @@ import de.bstly.we.businesslogic.SystemPropertyManager;
import de.bstly.we.controller.model.PasswordModel;
/**
*
* @author _bastler@bstly.de
*
* The Class PasswordModelValidator.
*/
@Component
public class PasswordModelValidator implements Validator {
@ -48,10 +46,9 @@ public class PasswordModelValidator implements Validator {
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
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;
/**
*
* @author _bastler@bstly.de
*
* The Class PermissionMappingValidator.
*/
@Component
public class PermissionMappingValidator implements Validator {

View File

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

View File

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

View File

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

View File

@ -15,9 +15,7 @@ import de.bstly.we.businesslogic.UserManager;
import de.bstly.we.controller.model.UserModel;
/**
*
* @author _bastler@bstly.de
*
* The Class UserModelValidator.
*/
@Component
public class UserModelValidator implements Validator {
@ -59,10 +57,11 @@ public class UserModelValidator implements Validator {
}
/**
* Validate username.
*
* @param username
* @param field
* @param errors
* @param username the username
* @param field the field
* @param errors the errors
*/
public void validateUsername(String username, String field, Errors errors) {
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;
/**
* @author _bastler@bstly.de
*
* The Class UserProfileFieldValidator.
*/
@Component
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;
/**
* @author Lurkars
*
* The Class AbstractModelEvent.
*/
public class AbstractModelEvent extends ApplicationEvent {
@ -22,9 +21,10 @@ public class AbstractModelEvent extends ApplicationEvent {
private AbstractModel model;
/**
* Instantiates a new abstract model event.
*
* @param type
* @param model
* @param type the type
* @param model the model
*/
public AbstractModelEvent(AbstractModelEventType type, AbstractModel model) {
super(model);
@ -33,6 +33,8 @@ public class AbstractModelEvent extends ApplicationEvent {
}
/**
* Gets the type.
*
* @return the type
*/
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) {
this.type = type;
}
/**
* Gets the model.
*
* @return the model
*/
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) {
this.model = model;

View File

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

View File

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

View File

@ -13,9 +13,7 @@ import javax.persistence.Id;
import javax.persistence.Table;
/**
*
* @author _bastler@bstly.de
*
* The Class Permission.
*/
@Entity
@Table(name = "permissions")
@ -37,6 +35,8 @@ public class Permission implements UserData {
private Instant expires;
/**
* Gets the id.
*
* @return the id
*/
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) {
this.id = id;
}
/**
* Gets the name.
*
* @return the name
*/
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) {
this.name = name;
}
/**
* Gets the target.
*
* @return the target
*/
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) {
this.target = target;
}
/**
* @return the addon
* Checks if is addon.
*
* @return true, if is addon
*/
public boolean isAddon() {
return addon;
}
/**
* @param addon the addon to set
* Sets the addon.
*
* @param addon the new addon
*/
public void setAddon(boolean addon) {
this.addon = addon;
}
/**
* Gets the starts.
*
* @return the starts
*/
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) {
this.starts = starts;
}
/**
* Gets the expires.
*
* @return the expires
*/
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) {
this.expires = expires;

View File

@ -22,9 +22,7 @@ import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
/**
*
* @author _bastler@bstly.de
*
* The Class PermissionMapping.
*/
@Entity
@Table(name = "permission_mappings")
@ -59,6 +57,8 @@ public class PermissionMapping {
private String expiresQuestion;
/**
* Gets the id.
*
* @return the id
*/
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) {
this.id = id;
}
/**
* Gets the product.
*
* @return the product
*/
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) {
this.product = product;
}
/**
* Gets the item.
*
* @return the item
*/
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) {
this.item = item;
}
/**
* Gets the names.
*
* @return the names
*/
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) {
this.names = names;
}
/**
* @return the addon
* Checks if is addon.
*
* @return true, if is addon
*/
public boolean isAddon() {
return addon;
}
/**
* @param addon the addon to set
* Sets the addon.
*
* @param addon the new addon
*/
public void setAddon(boolean addon) {
this.addon = addon;
}
/**
* Gets the lifetime.
*
* @return the lifetime
*/
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) {
this.lifetime = lifetime;
}
/**
* @return the lifetimeUnit
* Gets the lifetime unit.
*
* @return the lifetime unit
*/
public ChronoUnit getLifetimeUnit() {
return lifetimeUnit;
}
/**
* @param lifetimeUnit the lifetimeUnit to set
* Sets the lifetime unit.
*
* @param lifetimeUnit the new lifetime unit
*/
public void setLifetimeUnit(ChronoUnit lifetimeUnit) {
this.lifetimeUnit = lifetimeUnit;
}
/**
* @return the lifetimeRound
* Checks if is lifetime round.
*
* @return true, if is lifetime round
*/
public boolean isLifetimeRound() {
return lifetimeRound;
}
/**
* @param lifetimeRound the lifetimeRound to set
* Sets the lifetime round.
*
* @param lifetimeRound the new lifetime round
*/
public void setLifetimeRound(boolean lifetimeRound) {
this.lifetimeRound = lifetimeRound;
}
/**
* @return the startsQuestion
* Gets the starts question.
*
* @return the starts question
*/
public String getStartsQuestion() {
return startsQuestion;
}
/**
* @param startsQuestion the startsQuestion to set
* Sets the starts question.
*
* @param startsQuestion the new starts question
*/
public void setStartsQuestion(String startsQuestion) {
this.startsQuestion = startsQuestion;
}
/**
* @return the expiresQuestion
* Gets the expires question.
*
* @return the expires question
*/
public String getExpiresQuestion() {
return expiresQuestion;
}
/**
* @param expiresQuestion the expiresQuestion to set
* Sets the expires question.
*
* @param expiresQuestion the new expires question
*/
public void setExpiresQuestion(String expiresQuestion) {
this.expiresQuestion = expiresQuestion;
}
/**
* The Class ChronoUnitConverter.
*/
@Converter
public static class ChronoUnitConverter implements AttributeConverter<ChronoUnit, String> {
/*
* @see javax.persistence.AttributeConverter#convertToDatabaseColumn(java.lang.Object)
*/
@Override
public String convertToDatabaseColumn(ChronoUnit chronoUnit) {
return chronoUnit.name();
}
/*
* @see javax.persistence.AttributeConverter#convertToEntityAttribute(java.lang.Object)
*/
@Override
public ChronoUnit convertToEntityAttribute(String value) {
return ChronoUnit.valueOf(value);

View File

@ -11,9 +11,7 @@ import javax.persistence.Id;
import javax.persistence.Table;
/**
*
* @author _bastler@bstly.de
*
* The Class PersistentLogin.
*/
@Entity
@Table(name = "persistent_logins")
@ -30,6 +28,8 @@ public class PersistentLogin {
private Instant last_used;
/**
* Gets the username.
*
* @return the username
*/
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) {
this.username = username;
}
/**
* Gets the series.
*
* @return the series
*/
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) {
this.series = series;
}
/**
* Gets the token.
*
* @return the token
*/
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) {
this.token = token;
}
/**
* @return the last_used
* Gets the last used.
*
* @return the last used
*/
public Instant getLast_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) {
this.last_used = last_used;

View File

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

View File

@ -11,8 +11,7 @@ import javax.persistence.Id;
import javax.persistence.Table;
/**
* @author _bastler@bstly.de
*
* The Class Quota.
*/
@Entity
@Table(name = "quotas")
@ -34,6 +33,8 @@ public class Quota implements UserData {
private boolean disposable;
/**
* Gets the id.
*
* @return the id
*/
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) {
this.id = id;
}
/**
* Gets the target.
*
* @return the target
*/
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) {
this.target = target;
}
/**
* Gets the name.
*
* @return the name
*/
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) {
this.name = name;
}
/**
* Gets the value.
*
* @return the value
*/
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) {
this.value = value;
}
/**
* Gets the unit.
*
* @return the unit
*/
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) {
this.unit = unit;
}
/**
* @return the disposable
* Checks if is disposable.
*
* @return true, if is disposable
*/
public boolean isDisposable() {
return disposable;
}
/**
* @param disposable the disposable to set
* Sets the disposable.
*
* @param disposable the new disposable
*/
public void setDisposable(boolean disposable) {
this.disposable = disposable;

View File

@ -18,9 +18,7 @@ import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
/**
*
* @author _bastler@bstly.de
*
* The Class QuotaMapping.
*/
@Entity
@Table(name = "quota_mappings")
@ -50,6 +48,8 @@ public class QuotaMapping {
private boolean disposable;
/**
* Gets the id.
*
* @return the id
*/
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) {
this.id = id;
}
/**
* Gets the products.
*
* @return the products
*/
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) {
this.products = products;
}
/**
* Gets the items.
*
* @return the items
*/
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) {
this.items = items;
}
/**
* Gets the name.
*
* @return the name
*/
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) {
this.name = name;
}
/**
* Gets the value.
*
* @return the value
*/
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) {
this.value = value;
}
/**
* Gets the unit.
*
* @return the unit
*/
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) {
this.unit = unit;
}
/**
* @return the append
* Checks if is append.
*
* @return true, if is append
*/
public boolean isAppend() {
return append;
}
/**
* @param append the append to set
* Sets the append.
*
* @param append the new append
*/
public void setAppend(boolean append) {
this.append = append;
}
/**
* @return the disposable
* Checks if is disposable.
*
* @return true, if is disposable
*/
public boolean isDisposable() {
return disposable;
}
/**
* @param disposable the disposable to set
* Sets the disposable.
*
* @param disposable the new disposable
*/
public void setDisposable(boolean disposable) {
this.disposable = disposable;

View File

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

View File

@ -9,8 +9,7 @@ import javax.persistence.Id;
import javax.persistence.Table;
/**
* @author _bastler@bstly.de
*
* The Class SystemProfileField.
*/
@Entity
@Table(name = "system_profile_fields")
@ -25,6 +24,8 @@ public class SystemProfileField {
private boolean uniqueValue;
/**
* Gets the name.
*
* @return the name
*/
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) {
this.name = name;
}
/**
* Gets the type.
*
* @return the type
*/
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) {
this.type = type;
}
/**
* @return the uniqueValue
* Checks if is unique value.
*
* @return true, if is unique value
*/
public boolean isUniqueValue() {
return uniqueValue;
}
/**
* @param uniqueValue the uniqueValue to set
* Sets the unique value.
*
* @param uniqueValue the new unique value
*/
public void setUniqueValue(boolean uniqueValue) {
this.uniqueValue = uniqueValue;

View File

@ -10,9 +10,7 @@ import javax.persistence.Lob;
import javax.persistence.Table;
/**
*
* @author _bastler@bstly.de
*
* The Class SystemProperty.
*/
@Entity
@Table(name = "system_properties")
@ -26,15 +24,17 @@ public class SystemProperty {
private String value;
/**
*
* Instantiates a new system property.
*/
public SystemProperty() {
super();
}
/**
* @param key
* @param value
* Instantiates a new system property.
*
* @param key the key
* @param value the value
*/
public SystemProperty(String key, String value) {
super();
@ -43,6 +43,8 @@ public class SystemProperty {
}
/**
* Gets the key.
*
* @return the key
*/
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) {
this.key = key;
}
/**
* Gets the value.
*
* @return the value
*/
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) {
this.value = value;

View File

@ -14,9 +14,7 @@ import javax.persistence.UniqueConstraint;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
*
* @author _bastler@bstly.de
*
* The Class User.
*/
@Entity
@Table(name = "users", uniqueConstraints = @UniqueConstraint(columnNames = { "username" }))
@ -43,6 +41,8 @@ public class User implements UserData {
private String resetToken;
/**
* Gets the id.
*
* @return the id
*/
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) {
this.id = id;
}
/**
* Gets the username.
*
* @return the username
*/
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) {
this.username = username;
}
/**
* @return the passwordHash
* Gets the password hash.
*
* @return the password hash
*/
public String getPasswordHash() {
return passwordHash;
}
/**
* @param passwordHash the passwordHash to set
* Sets the password hash.
*
* @param passwordHash the new password hash
*/
public void setPasswordHash(String passwordHash) {
this.passwordHash = passwordHash;
}
/**
* @return the disabled
* Checks if is disabled.
*
* @return true, if is disabled
*/
public boolean isDisabled() {
return disabled;
}
/**
* @param disabled the disabled to set
* Sets the disabled.
*
* @param disabled the new disabled
*/
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}
/**
* @return the locked
* Checks if is locked.
*
* @return true, if is locked
*/
public boolean isLocked() {
return locked;
}
/**
* @param locked the locked to set
* Sets the locked.
*
* @param locked the new locked
*/
public void setLocked(boolean locked) {
this.locked = locked;
}
/**
* Gets the status.
*
* @return the status
*/
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) {
this.status = status;
}
/**
* Gets the secret.
*
* @return the secret
*/
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) {
this.secret = secret;
}
/**
* @return the resetToken
* Gets the reset token.
*
* @return the reset token
*/
public String getResetToken() {
return resetToken;
}
/**
* @param resetToken the resetToken to set
* Sets the reset token.
*
* @param resetToken the new reset token
*/
public void setResetToken(String resetToken) {
this.resetToken = resetToken;

View File

@ -12,8 +12,7 @@ import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
/**
* @author _bastler@bstly.de
*
* The Class UserAlias.
*/
@Entity
@Table(name = "aliases", uniqueConstraints = @UniqueConstraint(columnNames = { "alias" }))
@ -31,6 +30,8 @@ public class UserAlias implements UserData {
private Visibility visibility = Visibility.PROTECTED;
/**
* Gets the id.
*
* @return the id
*/
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) {
this.id = id;
}
/**
* Gets the target.
*
* @return the target
*/
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) {
this.target = target;
}
/**
* Gets the alias.
*
* @return the alias
*/
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) {
this.alias = alias;
}
/**
* Gets the visibility.
*
* @return the visibility
*/
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) {
this.visibility = visibility;

View File

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

View File

@ -12,8 +12,7 @@ import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
/**
* @author _bastler@bstly.de
*
* The Class UserDomain.
*/
@Entity
@Table(name = "domains", uniqueConstraints = @UniqueConstraint(columnNames = { "domain" }))
@ -35,6 +34,8 @@ public class UserDomain implements UserData {
private boolean validated;
/**
* Gets the id.
*
* @return the id
*/
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) {
this.id = id;
}
/**
* Gets the target.
*
* @return the target
*/
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) {
this.target = target;
}
/**
* Gets the domain.
*
* @return the domain
*/
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) {
this.domain = domain;
}
/**
* Gets the visibility.
*
* @return the visibility
*/
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) {
this.visibility = visibility;
}
/**
* Gets the secret.
*
* @return the secret
*/
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) {
this.secret = secret;
}
/**
* @return the validated
* Checks if is validated.
*
* @return true, if is validated
*/
public boolean isValidated() {
return validated;
}
/**
* @param validated the validated to set
* Sets the validated.
*
* @param validated the new validated
*/
public void setValidated(boolean validated) {
this.validated = validated;

View File

@ -16,8 +16,7 @@ import javax.persistence.UniqueConstraint;
import de.bstly.we.model.UserProfileField.UserProfileFieldId;
/**
* @author _bastler@bstly.de
*
* The Class UserProfileField.
*/
@Entity
@IdClass(UserProfileFieldId.class)
@ -44,6 +43,8 @@ public class UserProfileField implements UserData {
private Integer index = 0;
/**
* Gets the name.
*
* @return the name
*/
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) {
this.name = name;
}
/**
* Gets the target.
*
* @return the target
*/
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) {
this.target = target;
}
/**
* Gets the value.
*
* @return the value
*/
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) {
this.value = value;
}
/**
* Gets the blob.
*
* @return the blob
*/
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) {
this.blob = blob;
}
/**
* Gets the type.
*
* @return the type
*/
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) {
this.type = type;
}
/**
* Gets the visibility.
*
* @return the visibility
*/
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) {
this.visibility = visibility;
}
/**
* Gets the index.
*
* @return the index
*/
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) {
this.index = index;
}
/**
*
* @author _bastler@bstly.de
*
* The Class UserProfileFieldId.
*/
public static class UserProfileFieldId implements Serializable {
@ -156,6 +181,8 @@ public class UserProfileField implements UserData {
private String name;
/**
* Gets the target.
*
* @return the target
*/
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) {
this.target = target;
}
/**
* Gets the name.
*
* @return the name
*/
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) {
this.name = name;

View File

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

View File

@ -19,8 +19,7 @@ import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
/**
* @author _bastler@bstly.de
*
* The Class UserTotp.
*/
@Entity
@Table(name = "user_totps", uniqueConstraints = @UniqueConstraint(columnNames = { "target" }))
@ -42,6 +41,8 @@ public class UserTotp implements SecondFactor {
private List<String> recoveryCodes;
/**
* Gets the id.
*
* @return the id
*/
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) {
this.id = id;
}
/**
* Gets the target.
*
* @return the target
*/
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) {
this.target = target;
}
/**
* @return the enabled
* Checks if is enabled.
*
* @return true, if is enabled
*/
public boolean isEnabled() {
return enabled;
}
/**
* @param enabled the enabled to set
* Sets the enabled.
*
* @param enabled the new enabled
*/
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
/**
* Gets the secret.
*
* @return the secret
*/
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) {
this.secret = secret;
}
/**
* @return the qrData
* Gets the qr data.
*
* @return the qr data
*/
public String getQrData() {
return qrData;
}
/**
* @param qrData the qrData to set
* Sets the qr data.
*
* @param qrData the new qr data
*/
public void setQrData(String qrData) {
this.qrData = qrData;
}
/**
* @return the recoveryCodes
* Gets the recovery codes.
*
* @return the recovery codes
*/
public List<String> getRecoveryCodes() {
return recoveryCodes;
}
/**
* @param recoveryCodes the recoveryCodes to set
* Sets the recovery codes.
*
* @param recoveryCodes the new recovery codes
*/
public void setRecoveryCodes(List<String> recoveryCodes) {
this.recoveryCodes = recoveryCodes;

View File

@ -4,8 +4,7 @@
package de.bstly.we.model;
/**
* @author _bastler@bstly.de
*
* The 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;
/**
*
* @author _bastler@bstly.de
*
* The Interface PermissionMappingRepository.
*/
@Repository
public interface PermissionMappingRepository

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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