gw spotlessApply to latest revision, preparation for re-merging generated
This commit is contained in:
parent
a5f69a8cad
commit
b5d50acfbd
@ -1,6 +1,8 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng;
|
package org.hostsharing.hsadminng;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.config.DefaultProfileUtil;
|
import org.hostsharing.hsadminng.config.DefaultProfileUtil;
|
||||||
|
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||||
|
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng;
|
package org.hostsharing.hsadminng;
|
||||||
|
|
||||||
import io.github.jhipster.config.JHipsterConstants;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.hostsharing.hsadminng.config.ApplicationProperties;
|
import org.hostsharing.hsadminng.config.ApplicationProperties;
|
||||||
import org.hostsharing.hsadminng.config.DefaultProfileUtil;
|
import org.hostsharing.hsadminng.config.DefaultProfileUtil;
|
||||||
import org.hostsharing.hsadminng.security.SecurityUtils;
|
import org.hostsharing.hsadminng.security.SecurityUtils;
|
||||||
import org.hostsharing.hsadminng.service.accessfilter.Role;
|
import org.hostsharing.hsadminng.service.accessfilter.Role;
|
||||||
|
|
||||||
|
import io.github.jhipster.config.JHipsterConstants;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
@ -14,14 +17,15 @@ import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties;
|
|||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableConfigurationProperties({LiquibaseProperties.class, ApplicationProperties.class})
|
@EnableConfigurationProperties({ LiquibaseProperties.class, ApplicationProperties.class })
|
||||||
public class HsadminNgApp {
|
public class HsadminNgApp {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(HsadminNgApp.class);
|
private static final Logger log = LoggerFactory.getLogger(HsadminNgApp.class);
|
||||||
@ -37,19 +41,24 @@ public class HsadminNgApp {
|
|||||||
* <p>
|
* <p>
|
||||||
* Spring profiles can be configured with a program argument --spring.profiles.active=your-active-profile
|
* Spring profiles can be configured with a program argument --spring.profiles.active=your-active-profile
|
||||||
* <p>
|
* <p>
|
||||||
* You can find more information on how profiles work with JHipster on <a href="https://www.jhipster.tech/profiles/">https://www.jhipster.tech/profiles/</a>.
|
* You can find more information on how profiles work with JHipster on
|
||||||
|
* <a href="https://www.jhipster.tech/profiles/">https://www.jhipster.tech/profiles/</a>.
|
||||||
*/
|
*/
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void initApplication() {
|
public void initApplication() {
|
||||||
|
|
||||||
Collection<String> activeProfiles = Arrays.asList(env.getActiveProfiles());
|
Collection<String> activeProfiles = Arrays.asList(env.getActiveProfiles());
|
||||||
if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) {
|
if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)
|
||||||
log.error("You have misconfigured your application! It should not run " +
|
&& activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) {
|
||||||
"with both the 'dev' and 'prod' profiles at the same time.");
|
log.error(
|
||||||
|
"You have misconfigured your application! It should not run " +
|
||||||
|
"with both the 'dev' and 'prod' profiles at the same time.");
|
||||||
}
|
}
|
||||||
if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_CLOUD)) {
|
if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)
|
||||||
log.error("You have misconfigured your application! It should not " +
|
&& activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_CLOUD)) {
|
||||||
"run with both the 'dev' and 'cloud' profiles at the same time.");
|
log.error(
|
||||||
|
"You have misconfigured your application! It should not " +
|
||||||
|
"run with both the 'dev' and 'cloud' profiles at the same time.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove this hack once proper user roles are implemented
|
// TODO: remove this hack once proper user roles are implemented
|
||||||
@ -89,19 +98,20 @@ public class HsadminNgApp {
|
|||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
log.warn("The host name could not be determined, using `localhost` as fallback");
|
log.warn("The host name could not be determined, using `localhost` as fallback");
|
||||||
}
|
}
|
||||||
log.info("\n----------------------------------------------------------\n\t" +
|
log.info(
|
||||||
"Application '{}' is running! Access URLs:\n\t" +
|
"\n----------------------------------------------------------\n\t" +
|
||||||
"Local: \t\t{}://localhost:{}{}\n\t" +
|
"Application '{}' is running! Access URLs:\n\t" +
|
||||||
"External: \t{}://{}:{}{}\n\t" +
|
"Local: \t\t{}://localhost:{}{}\n\t" +
|
||||||
"Profile(s): \t{}\n----------------------------------------------------------",
|
"External: \t{}://{}:{}{}\n\t" +
|
||||||
env.getProperty("spring.application.name"),
|
"Profile(s): \t{}\n----------------------------------------------------------",
|
||||||
protocol,
|
env.getProperty("spring.application.name"),
|
||||||
serverPort,
|
protocol,
|
||||||
contextPath,
|
serverPort,
|
||||||
protocol,
|
contextPath,
|
||||||
hostAddress,
|
protocol,
|
||||||
serverPort,
|
hostAddress,
|
||||||
contextPath,
|
serverPort,
|
||||||
env.getActiveProfiles());
|
contextPath,
|
||||||
|
env.getActiveProfiles());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.aop.logging;
|
package org.hostsharing.hsadminng.aop.logging;
|
||||||
|
|
||||||
import io.github.jhipster.config.JHipsterConstants;
|
import io.github.jhipster.config.JHipsterConstants;
|
||||||
@ -34,8 +35,8 @@ public class LoggingAspect {
|
|||||||
* Pointcut that matches all repositories, services and Web REST endpoints.
|
* Pointcut that matches all repositories, services and Web REST endpoints.
|
||||||
*/
|
*/
|
||||||
@Pointcut("within(@org.springframework.stereotype.Repository *)" +
|
@Pointcut("within(@org.springframework.stereotype.Repository *)" +
|
||||||
" || within(@org.springframework.stereotype.Service *)" +
|
" || within(@org.springframework.stereotype.Service *)" +
|
||||||
" || within(@org.springframework.web.bind.annotation.RestController *)")
|
" || within(@org.springframework.web.bind.annotation.RestController *)")
|
||||||
public void springBeanPointcut() {
|
public void springBeanPointcut() {
|
||||||
// Method is empty as this is just a Pointcut, the implementations are in the advices.
|
// Method is empty as this is just a Pointcut, the implementations are in the advices.
|
||||||
}
|
}
|
||||||
@ -43,9 +44,9 @@ public class LoggingAspect {
|
|||||||
/**
|
/**
|
||||||
* Pointcut that matches all Spring beans in the application's main packages.
|
* Pointcut that matches all Spring beans in the application's main packages.
|
||||||
*/
|
*/
|
||||||
@Pointcut("within(org.hostsharing.hsadminng.repository..*)"+
|
@Pointcut("within(org.hostsharing.hsadminng.repository..*)" +
|
||||||
" || within(org.hostsharing.hsadminng.service..*)"+
|
" || within(org.hostsharing.hsadminng.service..*)" +
|
||||||
" || within(org.hostsharing.hsadminng.web.rest..*)")
|
" || within(org.hostsharing.hsadminng.web.rest..*)")
|
||||||
public void applicationPackagePointcut() {
|
public void applicationPackagePointcut() {
|
||||||
// Method is empty as this is just a Pointcut, the implementations are in the advices.
|
// Method is empty as this is just a Pointcut, the implementations are in the advices.
|
||||||
}
|
}
|
||||||
@ -59,12 +60,20 @@ public class LoggingAspect {
|
|||||||
@AfterThrowing(pointcut = "applicationPackagePointcut() && springBeanPointcut()", throwing = "e")
|
@AfterThrowing(pointcut = "applicationPackagePointcut() && springBeanPointcut()", throwing = "e")
|
||||||
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
|
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
|
||||||
if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
|
if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
|
||||||
log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
|
log.error(
|
||||||
joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e);
|
"Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'",
|
||||||
|
joinPoint.getSignature().getDeclaringTypeName(),
|
||||||
|
joinPoint.getSignature().getName(),
|
||||||
|
e.getCause() != null ? e.getCause() : "NULL",
|
||||||
|
e.getMessage(),
|
||||||
|
e);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
|
log.error(
|
||||||
joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL");
|
"Exception in {}.{}() with cause = {}",
|
||||||
|
joinPoint.getSignature().getDeclaringTypeName(),
|
||||||
|
joinPoint.getSignature().getName(),
|
||||||
|
e.getCause() != null ? e.getCause() : "NULL");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,19 +87,28 @@ public class LoggingAspect {
|
|||||||
@Around("applicationPackagePointcut() && springBeanPointcut()")
|
@Around("applicationPackagePointcut() && springBeanPointcut()")
|
||||||
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
|
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Enter: {}.{}() with argument[s] = {}", joinPoint.getSignature().getDeclaringTypeName(),
|
log.debug(
|
||||||
joinPoint.getSignature().getName(), Arrays.toString(joinPoint.getArgs()));
|
"Enter: {}.{}() with argument[s] = {}",
|
||||||
|
joinPoint.getSignature().getDeclaringTypeName(),
|
||||||
|
joinPoint.getSignature().getName(),
|
||||||
|
Arrays.toString(joinPoint.getArgs()));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Object result = joinPoint.proceed();
|
Object result = joinPoint.proceed();
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Exit: {}.{}() with result = {}", joinPoint.getSignature().getDeclaringTypeName(),
|
log.debug(
|
||||||
joinPoint.getSignature().getName(), result);
|
"Exit: {}.{}() with result = {}",
|
||||||
|
joinPoint.getSignature().getDeclaringTypeName(),
|
||||||
|
joinPoint.getSignature().getName(),
|
||||||
|
result);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
log.error("Illegal argument: {} in {}.{}()", Arrays.toString(joinPoint.getArgs()),
|
log.error(
|
||||||
joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName());
|
"Illegal argument: {} in {}.{}()",
|
||||||
|
Arrays.toString(joinPoint.getArgs()),
|
||||||
|
joinPoint.getSignature().getDeclaringTypeName(),
|
||||||
|
joinPoint.getSignature().getName());
|
||||||
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.config;
|
package org.hostsharing.hsadminng.config;
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.config;
|
package org.hostsharing.hsadminng.config;
|
||||||
|
|
||||||
import io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor;
|
import io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor;
|
||||||
@ -10,8 +11,8 @@ import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler;
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.scheduling.annotation.*;
|
import org.springframework.scheduling.annotation.*;
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
||||||
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||||
|
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
@ -46,7 +47,7 @@ public class AsyncConfiguration implements AsyncConfigurer, SchedulingConfigurer
|
|||||||
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
|
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
|
||||||
return new SimpleAsyncUncaughtExceptionHandler();
|
return new SimpleAsyncUncaughtExceptionHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
||||||
taskRegistrar.setScheduler(scheduledTaskExecutor());
|
taskRegistrar.setScheduler(scheduledTaskExecutor());
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.config;
|
package org.hostsharing.hsadminng.config;
|
||||||
|
|
||||||
import java.time.Duration;
|
|
||||||
|
|
||||||
import org.ehcache.config.builders.*;
|
|
||||||
import org.ehcache.jsr107.Eh107Configuration;
|
|
||||||
|
|
||||||
import io.github.jhipster.config.JHipsterProperties;
|
import io.github.jhipster.config.JHipsterProperties;
|
||||||
|
|
||||||
|
import org.ehcache.config.builders.*;
|
||||||
|
import org.ehcache.jsr107.Eh107Configuration;
|
||||||
import org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer;
|
import org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer;
|
||||||
import org.springframework.cache.annotation.EnableCaching;
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
import org.springframework.context.annotation.*;
|
import org.springframework.context.annotation.*;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableCaching
|
@EnableCaching
|
||||||
public class CacheConfiguration {
|
public class CacheConfiguration {
|
||||||
@ -18,14 +18,16 @@ public class CacheConfiguration {
|
|||||||
private final javax.cache.configuration.Configuration<Object, Object> jcacheConfiguration;
|
private final javax.cache.configuration.Configuration<Object, Object> jcacheConfiguration;
|
||||||
|
|
||||||
public CacheConfiguration(JHipsterProperties jHipsterProperties) {
|
public CacheConfiguration(JHipsterProperties jHipsterProperties) {
|
||||||
JHipsterProperties.Cache.Ehcache ehcache =
|
JHipsterProperties.Cache.Ehcache ehcache = jHipsterProperties.getCache().getEhcache();
|
||||||
jHipsterProperties.getCache().getEhcache();
|
|
||||||
|
|
||||||
jcacheConfiguration = Eh107Configuration.fromEhcacheCacheConfiguration(
|
jcacheConfiguration = Eh107Configuration.fromEhcacheCacheConfiguration(
|
||||||
CacheConfigurationBuilder.newCacheConfigurationBuilder(Object.class, Object.class,
|
CacheConfigurationBuilder.newCacheConfigurationBuilder(
|
||||||
ResourcePoolsBuilder.heap(ehcache.getMaxEntries()))
|
Object.class,
|
||||||
.withExpiry(ExpiryPolicyBuilder.timeToLiveExpiration(Duration.ofSeconds(ehcache.getTimeToLiveSeconds())))
|
Object.class,
|
||||||
.build());
|
ResourcePoolsBuilder.heap(ehcache.getMaxEntries()))
|
||||||
|
.withExpiry(
|
||||||
|
ExpiryPolicyBuilder.timeToLiveExpiration(Duration.ofSeconds(ehcache.getTimeToLiveSeconds())))
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.config;
|
package org.hostsharing.hsadminng.config;
|
||||||
|
|
||||||
import io.github.jhipster.config.JHipsterConstants;
|
import io.github.jhipster.config.JHipsterConstants;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.cloud.config.java.AbstractCloudConfig;
|
import org.springframework.cloud.config.java.AbstractCloudConfig;
|
||||||
import org.springframework.context.annotation.*;
|
import org.springframework.context.annotation.*;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Profile(JHipsterConstants.SPRING_PROFILE_CLOUD)
|
@Profile(JHipsterConstants.SPRING_PROFILE_CLOUD)
|
||||||
public class CloudDatabaseConfiguration extends AbstractCloudConfig {
|
public class CloudDatabaseConfiguration extends AbstractCloudConfig {
|
||||||
|
|
||||||
private final Logger log = LoggerFactory.getLogger(CloudDatabaseConfiguration.class);
|
private final Logger log = LoggerFactory.getLogger(CloudDatabaseConfiguration.class);
|
||||||
|
|
||||||
private static final String CLOUD_CONFIGURATION_HIKARI_PREFIX = "spring.datasource.hikari";
|
private static final String CLOUD_CONFIGURATION_HIKARI_PREFIX = "spring.datasource.hikari";
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.config;
|
package org.hostsharing.hsadminng.config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11,7 +12,7 @@ public final class Constants {
|
|||||||
public static final String SYSTEM_ACCOUNT = "system";
|
public static final String SYSTEM_ACCOUNT = "system";
|
||||||
public static final String ANONYMOUS_USER = "anonymoususer";
|
public static final String ANONYMOUS_USER = "anonymoususer";
|
||||||
public static final String DEFAULT_LANGUAGE = "de";
|
public static final String DEFAULT_LANGUAGE = "de";
|
||||||
|
|
||||||
private Constants() {
|
private Constants() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.config;
|
package org.hostsharing.hsadminng.config;
|
||||||
|
|
||||||
import io.github.jhipster.config.JHipsterConstants;
|
import io.github.jhipster.config.JHipsterConstants;
|
||||||
import io.github.jhipster.config.h2.H2ConfigurationHelper;
|
import io.github.jhipster.config.h2.H2ConfigurationHelper;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Profile;
|
import org.springframework.context.annotation.Profile;
|
||||||
|
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||||
@ -42,7 +43,7 @@ public class DatabaseConfiguration {
|
|||||||
log.debug("H2 database is available on port {}", port);
|
log.debug("H2 database is available on port {}", port);
|
||||||
return H2ConfigurationHelper.createServer(port);
|
return H2ConfigurationHelper.createServer(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getValidPortForH2() {
|
private String getValidPortForH2() {
|
||||||
int port = Integer.parseInt(env.getProperty("server.port"));
|
int port = Integer.parseInt(env.getProperty("server.port"));
|
||||||
if (port < 10000) {
|
if (port < 10000) {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.config;
|
package org.hostsharing.hsadminng.config;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.config;
|
package org.hostsharing.hsadminng.config;
|
||||||
|
|
||||||
import io.github.jhipster.config.JHipsterConstants;
|
import io.github.jhipster.config.JHipsterConstants;
|
||||||
@ -27,10 +28,10 @@ public final class DefaultProfileUtil {
|
|||||||
public static void addDefaultProfile(SpringApplication app) {
|
public static void addDefaultProfile(SpringApplication app) {
|
||||||
Map<String, Object> defProperties = new HashMap<>();
|
Map<String, Object> defProperties = new HashMap<>();
|
||||||
/*
|
/*
|
||||||
* The default profile to use when no other profiles are defined
|
* The default profile to use when no other profiles are defined
|
||||||
* This cannot be set in the <code>application.yml</code> file.
|
* This cannot be set in the <code>application.yml</code> file.
|
||||||
* See https://github.com/spring-projects/spring-boot/issues/1219
|
* See https://github.com/spring-projects/spring-boot/issues/1219
|
||||||
*/
|
*/
|
||||||
defProperties.put(SPRING_PROFILE_DEFAULT, JHipsterConstants.SPRING_PROFILE_DEVELOPMENT);
|
defProperties.put(SPRING_PROFILE_DEFAULT, JHipsterConstants.SPRING_PROFILE_DEVELOPMENT);
|
||||||
app.setDefaultProperties(defProperties);
|
app.setDefaultProperties(defProperties);
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.config;
|
package org.hostsharing.hsadminng.config;
|
||||||
|
|
||||||
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
|
import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
|
||||||
@ -15,6 +16,7 @@ public class JacksonConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Support for Java date and time API.
|
* Support for Java date and time API.
|
||||||
|
*
|
||||||
* @return the corresponding Jackson module.
|
* @return the corresponding Jackson module.
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@ -27,7 +29,6 @@ public class JacksonConfiguration {
|
|||||||
return new Jdk8Module();
|
return new Jdk8Module();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Support for Hibernate types in Jackson.
|
* Support for Hibernate types in Jackson.
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.config;
|
package org.hostsharing.hsadminng.config;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import io.github.jhipster.config.JHipsterConstants;
|
||||||
|
import io.github.jhipster.config.liquibase.AsyncSpringLiquibase;
|
||||||
|
import liquibase.integration.spring.SpringLiquibase;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -11,9 +14,7 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.core.task.TaskExecutor;
|
import org.springframework.core.task.TaskExecutor;
|
||||||
|
|
||||||
import io.github.jhipster.config.JHipsterConstants;
|
import javax.sql.DataSource;
|
||||||
import io.github.jhipster.config.liquibase.AsyncSpringLiquibase;
|
|
||||||
import liquibase.integration.spring.SpringLiquibase;
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class LiquibaseConfiguration {
|
public class LiquibaseConfiguration {
|
||||||
@ -22,14 +23,15 @@ public class LiquibaseConfiguration {
|
|||||||
|
|
||||||
private final Environment env;
|
private final Environment env;
|
||||||
|
|
||||||
|
|
||||||
public LiquibaseConfiguration(Environment env) {
|
public LiquibaseConfiguration(Environment env) {
|
||||||
this.env = env;
|
this.env = env;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SpringLiquibase liquibase(@Qualifier("taskExecutor") TaskExecutor taskExecutor,
|
public SpringLiquibase liquibase(
|
||||||
DataSource dataSource, LiquibaseProperties liquibaseProperties) {
|
@Qualifier("taskExecutor") TaskExecutor taskExecutor,
|
||||||
|
DataSource dataSource,
|
||||||
|
LiquibaseProperties liquibaseProperties) {
|
||||||
|
|
||||||
// Use liquibase.integration.spring.SpringLiquibase if you don't want Liquibase to start asynchronously
|
// Use liquibase.integration.spring.SpringLiquibase if you don't want Liquibase to start asynchronously
|
||||||
SpringLiquibase liquibase = new AsyncSpringLiquibase(taskExecutor, env);
|
SpringLiquibase liquibase = new AsyncSpringLiquibase(taskExecutor, env);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.config;
|
package org.hostsharing.hsadminng.config;
|
||||||
|
|
||||||
import io.github.jhipster.config.locale.AngularCookieLocaleResolver;
|
import io.github.jhipster.config.locale.AngularCookieLocaleResolver;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.config;
|
package org.hostsharing.hsadminng.config;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.aop.logging.LoggingAspect;
|
import org.hostsharing.hsadminng.aop.logging.LoggingAspect;
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.config;
|
package org.hostsharing.hsadminng.config;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import io.github.jhipster.config.JHipsterProperties;
|
|
||||||
|
|
||||||
import ch.qos.logback.classic.AsyncAppender;
|
import ch.qos.logback.classic.AsyncAppender;
|
||||||
import ch.qos.logback.classic.Level;
|
import ch.qos.logback.classic.Level;
|
||||||
import ch.qos.logback.classic.LoggerContext;
|
import ch.qos.logback.classic.LoggerContext;
|
||||||
@ -15,14 +11,19 @@ import ch.qos.logback.core.Appender;
|
|||||||
import ch.qos.logback.core.filter.EvaluatorFilter;
|
import ch.qos.logback.core.filter.EvaluatorFilter;
|
||||||
import ch.qos.logback.core.spi.ContextAwareBase;
|
import ch.qos.logback.core.spi.ContextAwareBase;
|
||||||
import ch.qos.logback.core.spi.FilterReply;
|
import ch.qos.logback.core.spi.FilterReply;
|
||||||
|
import io.github.jhipster.config.JHipsterProperties;
|
||||||
import net.logstash.logback.appender.LogstashTcpSocketAppender;
|
import net.logstash.logback.appender.LogstashTcpSocketAppender;
|
||||||
import net.logstash.logback.encoder.LogstashEncoder;
|
import net.logstash.logback.encoder.LogstashEncoder;
|
||||||
import net.logstash.logback.stacktrace.ShortenedThrowableConverter;
|
import net.logstash.logback.stacktrace.ShortenedThrowableConverter;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class LoggingConfiguration {
|
public class LoggingConfiguration {
|
||||||
|
|
||||||
@ -40,8 +41,10 @@ public class LoggingConfiguration {
|
|||||||
|
|
||||||
private final JHipsterProperties jHipsterProperties;
|
private final JHipsterProperties jHipsterProperties;
|
||||||
|
|
||||||
public LoggingConfiguration(@Value("${spring.application.name}") String appName, @Value("${server.port}") String serverPort,
|
public LoggingConfiguration(
|
||||||
JHipsterProperties jHipsterProperties) {
|
@Value("${spring.application.name}") String appName,
|
||||||
|
@Value("${server.port}") String serverPort,
|
||||||
|
JHipsterProperties jHipsterProperties) {
|
||||||
this.appName = appName;
|
this.appName = appName;
|
||||||
this.serverPort = serverPort;
|
this.serverPort = serverPort;
|
||||||
this.jHipsterProperties = jHipsterProperties;
|
this.jHipsterProperties = jHipsterProperties;
|
||||||
@ -71,7 +74,10 @@ public class LoggingConfiguration {
|
|||||||
// More documentation is available at: https://github.com/logstash/logstash-logback-encoder
|
// More documentation is available at: https://github.com/logstash/logstash-logback-encoder
|
||||||
LogstashEncoder logstashEncoder = new LogstashEncoder();
|
LogstashEncoder logstashEncoder = new LogstashEncoder();
|
||||||
// Set the Logstash appender config from JHipster properties
|
// Set the Logstash appender config from JHipster properties
|
||||||
logstashAppender.addDestinations(new InetSocketAddress(jHipsterProperties.getLogging().getLogstash().getHost(), jHipsterProperties.getLogging().getLogstash().getPort()));
|
logstashAppender.addDestinations(
|
||||||
|
new InetSocketAddress(
|
||||||
|
jHipsterProperties.getLogging().getLogstash().getHost(),
|
||||||
|
jHipsterProperties.getLogging().getLogstash().getPort()));
|
||||||
|
|
||||||
ShortenedThrowableConverter throwableConverter = new ShortenedThrowableConverter();
|
ShortenedThrowableConverter throwableConverter = new ShortenedThrowableConverter();
|
||||||
throwableConverter.setRootCauseFirst(true);
|
throwableConverter.setRootCauseFirst(true);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.config;
|
package org.hostsharing.hsadminng.config;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.security.*;
|
import org.hostsharing.hsadminng.security.*;
|
||||||
@ -41,7 +42,12 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||||||
|
|
||||||
private final SecurityProblemSupport problemSupport;
|
private final SecurityProblemSupport problemSupport;
|
||||||
|
|
||||||
public SecurityConfiguration(AuthenticationManagerBuilder authenticationManagerBuilder, UserDetailsService userDetailsService, TokenProvider tokenProvider, CorsFilter corsFilter, SecurityProblemSupport problemSupport) {
|
public SecurityConfiguration(
|
||||||
|
AuthenticationManagerBuilder authenticationManagerBuilder,
|
||||||
|
UserDetailsService userDetailsService,
|
||||||
|
TokenProvider tokenProvider,
|
||||||
|
CorsFilter corsFilter,
|
||||||
|
SecurityProblemSupport problemSupport) {
|
||||||
this.authenticationManagerBuilder = authenticationManagerBuilder;
|
this.authenticationManagerBuilder = authenticationManagerBuilder;
|
||||||
this.userDetailsService = userDetailsService;
|
this.userDetailsService = userDetailsService;
|
||||||
this.tokenProvider = tokenProvider;
|
this.tokenProvider = tokenProvider;
|
||||||
@ -53,8 +59,8 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||||||
public void init() {
|
public void init() {
|
||||||
try {
|
try {
|
||||||
authenticationManagerBuilder
|
authenticationManagerBuilder
|
||||||
.userDetailsService(userDetailsService)
|
.userDetailsService(userDetailsService)
|
||||||
.passwordEncoder(passwordEncoder());
|
.passwordEncoder(passwordEncoder());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new BeanInitializationException("Security configuration failed", e);
|
throw new BeanInitializationException("Security configuration failed", e);
|
||||||
}
|
}
|
||||||
@ -74,17 +80,18 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public void configure(WebSecurity web) throws Exception {
|
public void configure(WebSecurity web) throws Exception {
|
||||||
web.ignoring()
|
web.ignoring()
|
||||||
.antMatchers(HttpMethod.OPTIONS, "/**")
|
.antMatchers(HttpMethod.OPTIONS, "/**")
|
||||||
.antMatchers("/app/**/*.{js,html}")
|
.antMatchers("/app/**/*.{js,html}")
|
||||||
.antMatchers("/i18n/**")
|
.antMatchers("/i18n/**")
|
||||||
.antMatchers("/content/**")
|
.antMatchers("/content/**")
|
||||||
.antMatchers("/h2-console/**")
|
.antMatchers("/h2-console/**")
|
||||||
.antMatchers("/swagger-ui/index.html")
|
.antMatchers("/swagger-ui/index.html")
|
||||||
.antMatchers("/test/**");
|
.antMatchers("/test/**");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configure(HttpSecurity http) throws Exception {
|
public void configure(HttpSecurity http) throws Exception {
|
||||||
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.csrf()
|
.csrf()
|
||||||
.disable()
|
.disable()
|
||||||
@ -112,7 +119,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
|||||||
.antMatchers("/management/**").hasAuthority(AuthoritiesConstants.ADMIN)
|
.antMatchers("/management/**").hasAuthority(AuthoritiesConstants.ADMIN)
|
||||||
.and()
|
.and()
|
||||||
.apply(securityConfigurerAdapter());
|
.apply(securityConfigurerAdapter());
|
||||||
|
// @formatter:on
|
||||||
}
|
}
|
||||||
|
|
||||||
private JWTConfigurer securityConfigurerAdapter() {
|
private JWTConfigurer securityConfigurerAdapter() {
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.config;
|
package org.hostsharing.hsadminng.config;
|
||||||
|
|
||||||
|
import static java.net.URLDecoder.decode;
|
||||||
|
|
||||||
import io.github.jhipster.config.JHipsterConstants;
|
import io.github.jhipster.config.JHipsterConstants;
|
||||||
import io.github.jhipster.config.JHipsterProperties;
|
import io.github.jhipster.config.JHipsterProperties;
|
||||||
import io.github.jhipster.config.h2.H2ConfigurationHelper;
|
import io.github.jhipster.config.h2.H2ConfigurationHelper;
|
||||||
import io.github.jhipster.web.filter.CachingHttpHeadersFilter;
|
import io.github.jhipster.web.filter.CachingHttpHeadersFilter;
|
||||||
import io.undertow.UndertowOptions;
|
import io.undertow.UndertowOptions;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
|
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
|
||||||
import org.springframework.boot.web.server.*;
|
import org.springframework.boot.web.server.*;
|
||||||
import org.springframework.boot.web.servlet.ServletContextInitializer;
|
import org.springframework.boot.web.servlet.ServletContextInitializer;
|
||||||
@ -20,14 +23,13 @@ import org.springframework.web.cors.CorsConfiguration;
|
|||||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||||
import org.springframework.web.filter.CorsFilter;
|
import org.springframework.web.filter.CorsFilter;
|
||||||
|
|
||||||
import javax.servlet.*;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static java.net.URLDecoder.decode;
|
import javax.servlet.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration of web application with Servlet 3.0 APIs.
|
* Configuration of web application with Servlet 3.0 APIs.
|
||||||
@ -78,11 +80,10 @@ public class WebConfigurer implements ServletContextInitializer, WebServerFactor
|
|||||||
* for more information.
|
* for more information.
|
||||||
*/
|
*/
|
||||||
if (jHipsterProperties.getHttp().getVersion().equals(JHipsterProperties.Http.Version.V_2_0) &&
|
if (jHipsterProperties.getHttp().getVersion().equals(JHipsterProperties.Http.Version.V_2_0) &&
|
||||||
server instanceof UndertowServletWebServerFactory) {
|
server instanceof UndertowServletWebServerFactory) {
|
||||||
|
|
||||||
((UndertowServletWebServerFactory) server)
|
((UndertowServletWebServerFactory) server)
|
||||||
.addBuilderCustomizers(builder ->
|
.addBuilderCustomizers(builder -> builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true));
|
||||||
builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,11 +134,12 @@ public class WebConfigurer implements ServletContextInitializer, WebServerFactor
|
|||||||
/**
|
/**
|
||||||
* Initializes the caching HTTP Headers Filter.
|
* Initializes the caching HTTP Headers Filter.
|
||||||
*/
|
*/
|
||||||
private void initCachingHttpHeadersFilter(ServletContext servletContext,
|
private void initCachingHttpHeadersFilter(
|
||||||
EnumSet<DispatcherType> disps) {
|
ServletContext servletContext,
|
||||||
|
EnumSet<DispatcherType> disps) {
|
||||||
log.debug("Registering Caching HTTP Headers Filter");
|
log.debug("Registering Caching HTTP Headers Filter");
|
||||||
FilterRegistration.Dynamic cachingHttpHeadersFilter =
|
FilterRegistration.Dynamic cachingHttpHeadersFilter = servletContext.addFilter(
|
||||||
servletContext.addFilter("cachingHttpHeadersFilter",
|
"cachingHttpHeadersFilter",
|
||||||
new CachingHttpHeadersFilter(jHipsterProperties));
|
new CachingHttpHeadersFilter(jHipsterProperties));
|
||||||
|
|
||||||
cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/i18n/*");
|
cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/i18n/*");
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.config.audit;
|
package org.hostsharing.hsadminng.config.audit;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.PersistentAuditEvent;
|
import org.hostsharing.hsadminng.domain.PersistentAuditEvent;
|
||||||
@ -38,8 +39,11 @@ public class AuditEventConverter {
|
|||||||
if (persistentAuditEvent == null) {
|
if (persistentAuditEvent == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new AuditEvent(persistentAuditEvent.getAuditEventDate(), persistentAuditEvent.getPrincipal(),
|
return new AuditEvent(
|
||||||
persistentAuditEvent.getAuditEventType(), convertDataToObjects(persistentAuditEvent.getData()));
|
persistentAuditEvent.getAuditEventDate(),
|
||||||
|
persistentAuditEvent.getPrincipal(),
|
||||||
|
persistentAuditEvent.getAuditEventType(),
|
||||||
|
convertDataToObjects(persistentAuditEvent.getData()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.domain;
|
package org.hostsharing.hsadminng.domain;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
import org.springframework.data.annotation.CreatedBy;
|
import org.springframework.data.annotation.CreatedBy;
|
||||||
import org.springframework.data.annotation.CreatedDate;
|
import org.springframework.data.annotation.CreatedDate;
|
||||||
@ -10,6 +12,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.EntityListeners;
|
import javax.persistence.EntityListeners;
|
||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.domain;
|
package org.hostsharing.hsadminng.domain;
|
||||||
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
||||||
import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
|
import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import javax.validation.constraints.Size;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Asset.
|
* A Asset.
|
||||||
*/
|
*/
|
||||||
@ -170,12 +172,12 @@ public class Asset implements Serializable {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Asset{" +
|
return "Asset{" +
|
||||||
"id=" + getId() +
|
"id=" + getId() +
|
||||||
", documentDate='" + getDocumentDate() + "'" +
|
", documentDate='" + getDocumentDate() + "'" +
|
||||||
", valueDate='" + getValueDate() + "'" +
|
", valueDate='" + getValueDate() + "'" +
|
||||||
", action='" + getAction() + "'" +
|
", action='" + getAction() + "'" +
|
||||||
", amount=" + getAmount() +
|
", amount=" + getAmount() +
|
||||||
", remark='" + getRemark() + "'" +
|
", remark='" + getRemark() + "'" +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.domain;
|
package org.hostsharing.hsadminng.domain;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An authority (a security role) used by Spring Security.
|
* An authority (a security role) used by Spring Security.
|
||||||
@ -53,7 +55,7 @@ public class Authority implements Serializable {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Authority{" +
|
return "Authority{" +
|
||||||
"name='" + name + '\'' +
|
"name='" + name + '\'' +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.domain;
|
package org.hostsharing.hsadminng.domain;
|
||||||
|
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.enumeration.CustomerKind;
|
import org.hostsharing.hsadminng.domain.enumeration.CustomerKind;
|
||||||
import org.hostsharing.hsadminng.domain.enumeration.VatRegion;
|
import org.hostsharing.hsadminng.domain.enumeration.VatRegion;
|
||||||
|
|
||||||
import javax.persistence.*;
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Customer.
|
* A Customer.
|
||||||
*/
|
*/
|
||||||
@ -20,7 +21,7 @@ import java.util.Set;
|
|||||||
public class Customer implements Serializable {
|
public class Customer implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
|
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
|
||||||
@SequenceGenerator(name = "sequenceGenerator")
|
@SequenceGenerator(name = "sequenceGenerator")
|
||||||
@ -384,22 +385,22 @@ public class Customer implements Serializable {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Customer{" +
|
return "Customer{" +
|
||||||
"id=" + getId() +
|
"id=" + getId() +
|
||||||
", reference=" + getReference() +
|
", reference=" + getReference() +
|
||||||
", prefix='" + getPrefix() + "'" +
|
", prefix='" + getPrefix() + "'" +
|
||||||
", name='" + getName() + "'" +
|
", name='" + getName() + "'" +
|
||||||
", kind='" + getKind() + "'" +
|
", kind='" + getKind() + "'" +
|
||||||
", birthDate='" + getBirthDate() + "'" +
|
", birthDate='" + getBirthDate() + "'" +
|
||||||
", birthPlace='" + getBirthPlace() + "'" +
|
", birthPlace='" + getBirthPlace() + "'" +
|
||||||
", registrationCourt='" + getRegistrationCourt() + "'" +
|
", registrationCourt='" + getRegistrationCourt() + "'" +
|
||||||
", registrationNumber='" + getRegistrationNumber() + "'" +
|
", registrationNumber='" + getRegistrationNumber() + "'" +
|
||||||
", vatRegion='" + getVatRegion() + "'" +
|
", vatRegion='" + getVatRegion() + "'" +
|
||||||
", vatNumber='" + getVatNumber() + "'" +
|
", vatNumber='" + getVatNumber() + "'" +
|
||||||
", contractualSalutation='" + getContractualSalutation() + "'" +
|
", contractualSalutation='" + getContractualSalutation() + "'" +
|
||||||
", contractualAddress='" + getContractualAddress() + "'" +
|
", contractualAddress='" + getContractualAddress() + "'" +
|
||||||
", billingSalutation='" + getBillingSalutation() + "'" +
|
", billingSalutation='" + getBillingSalutation() + "'" +
|
||||||
", billingAddress='" + getBillingAddress() + "'" +
|
", billingAddress='" + getBillingAddress() + "'" +
|
||||||
", remark='" + getRemark() + "'" +
|
", remark='" + getRemark() + "'" +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.domain;
|
package org.hostsharing.hsadminng.domain;
|
||||||
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
|
||||||
import javax.persistence.*;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import javax.validation.constraints.Size;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Membership.
|
* A Membership.
|
||||||
*/
|
*/
|
||||||
@ -225,12 +226,12 @@ public class Membership implements Serializable {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Membership{" +
|
return "Membership{" +
|
||||||
"id=" + getId() +
|
"id=" + getId() +
|
||||||
", admissionDocumentDate='" + getAdmissionDocumentDate() + "'" +
|
", admissionDocumentDate='" + getAdmissionDocumentDate() + "'" +
|
||||||
", cancellationDocumentDate='" + getCancellationDocumentDate() + "'" +
|
", cancellationDocumentDate='" + getCancellationDocumentDate() + "'" +
|
||||||
", memberFromDate='" + getMemberFromDate() + "'" +
|
", memberFromDate='" + getMemberFromDate() + "'" +
|
||||||
", memberUntilDate='" + getMemberUntilDate() + "'" +
|
", memberUntilDate='" + getMemberUntilDate() + "'" +
|
||||||
", remark='" + getRemark() + "'" +
|
", remark='" + getRemark() + "'" +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.domain;
|
package org.hostsharing.hsadminng.domain;
|
||||||
|
|
||||||
import javax.persistence.*;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Persist AuditEvent managed by the Spring Boot actuator.
|
* Persist AuditEvent managed by the Spring Boot actuator.
|
||||||
@ -38,7 +40,7 @@ public class PersistentAuditEvent implements Serializable {
|
|||||||
@ElementCollection
|
@ElementCollection
|
||||||
@MapKeyColumn(name = "name")
|
@MapKeyColumn(name = "name")
|
||||||
@Column(name = "value")
|
@Column(name = "value")
|
||||||
@CollectionTable(name = "jhi_persistent_audit_evt_data", joinColumns=@JoinColumn(name="event_id"))
|
@CollectionTable(name = "jhi_persistent_audit_evt_data", joinColumns = @JoinColumn(name = "event_id"))
|
||||||
private Map<String, String> data = new HashMap<>();
|
private Map<String, String> data = new HashMap<>();
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
@ -91,7 +93,8 @@ public class PersistentAuditEvent implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PersistentAuditEvent persistentAuditEvent = (PersistentAuditEvent) o;
|
PersistentAuditEvent persistentAuditEvent = (PersistentAuditEvent) o;
|
||||||
return !(persistentAuditEvent.getId() == null || getId() == null) && Objects.equals(getId(), persistentAuditEvent.getId());
|
return !(persistentAuditEvent.getId() == null || getId() == null)
|
||||||
|
&& Objects.equals(getId(), persistentAuditEvent.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -102,9 +105,9 @@ public class PersistentAuditEvent implements Serializable {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PersistentAuditEvent{" +
|
return "PersistentAuditEvent{" +
|
||||||
"principal='" + principal + '\'' +
|
"principal='" + principal + '\'' +
|
||||||
", auditEventDate=" + auditEventDate +
|
", auditEventDate=" + auditEventDate +
|
||||||
", auditEventType='" + auditEventType + '\'' +
|
", auditEventType='" + auditEventType + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.domain;
|
package org.hostsharing.hsadminng.domain;
|
||||||
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A SepaMandate.
|
* A SepaMandate.
|
||||||
@ -18,7 +19,7 @@ import java.util.Objects;
|
|||||||
public class SepaMandate implements Serializable {
|
public class SepaMandate implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
|
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
|
||||||
@SequenceGenerator(name = "sequenceGenerator")
|
@SequenceGenerator(name = "sequenceGenerator")
|
||||||
@ -232,16 +233,16 @@ public class SepaMandate implements Serializable {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SepaMandate{" +
|
return "SepaMandate{" +
|
||||||
"id=" + getId() +
|
"id=" + getId() +
|
||||||
", reference='" + getReference() + "'" +
|
", reference='" + getReference() + "'" +
|
||||||
", iban='" + getIban() + "'" +
|
", iban='" + getIban() + "'" +
|
||||||
", bic='" + getBic() + "'" +
|
", bic='" + getBic() + "'" +
|
||||||
", grantingDocumentDate='" + getGrantingDocumentDate() + "'" +
|
", grantingDocumentDate='" + getGrantingDocumentDate() + "'" +
|
||||||
", revokationDocumentDate='" + getRevokationDocumentDate() + "'" +
|
", revokationDocumentDate='" + getRevokationDocumentDate() + "'" +
|
||||||
", validFromDate='" + getValidFromDate() + "'" +
|
", validFromDate='" + getValidFromDate() + "'" +
|
||||||
", validUntilDate='" + getValidUntilDate() + "'" +
|
", validUntilDate='" + getValidUntilDate() + "'" +
|
||||||
", lastUsedDate='" + getLastUsedDate() + "'" +
|
", lastUsedDate='" + getLastUsedDate() + "'" +
|
||||||
", remark='" + getRemark() + "'" +
|
", remark='" + getRemark() + "'" +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.domain;
|
package org.hostsharing.hsadminng.domain;
|
||||||
|
|
||||||
|
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Share.
|
* A Share.
|
||||||
@ -169,12 +171,12 @@ public class Share implements Serializable {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Share{" +
|
return "Share{" +
|
||||||
"id=" + getId() +
|
"id=" + getId() +
|
||||||
", documentDate='" + getDocumentDate() + "'" +
|
", documentDate='" + getDocumentDate() + "'" +
|
||||||
", valueDate='" + getValueDate() + "'" +
|
", valueDate='" + getValueDate() + "'" +
|
||||||
", action='" + getAction() + "'" +
|
", action='" + getAction() + "'" +
|
||||||
", quantity=" + getQuantity() +
|
", quantity=" + getQuantity() +
|
||||||
", remark='" + getRemark() + "'" +
|
", remark='" + getRemark() + "'" +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,25 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.domain;
|
package org.hostsharing.hsadminng.domain;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.config.Constants;
|
import org.hostsharing.hsadminng.config.Constants;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.hibernate.annotations.BatchSize;
|
import org.hibernate.annotations.BatchSize;
|
||||||
import javax.validation.constraints.Email;
|
|
||||||
|
|
||||||
import javax.persistence.*;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import javax.validation.constraints.Pattern;
|
|
||||||
import javax.validation.constraints.Size;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.time.Instant;
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import javax.validation.constraints.Email;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Pattern;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A user.
|
* A user.
|
||||||
@ -86,9 +89,9 @@ public class User extends AbstractAuditingEntity implements Serializable {
|
|||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@ManyToMany
|
@ManyToMany
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
name = "jhi_user_authority",
|
name = "jhi_user_authority",
|
||||||
joinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "id")},
|
joinColumns = { @JoinColumn(name = "user_id", referencedColumnName = "id") },
|
||||||
inverseJoinColumns = {@JoinColumn(name = "authority_name", referencedColumnName = "name")})
|
inverseJoinColumns = { @JoinColumn(name = "authority_name", referencedColumnName = "name") })
|
||||||
|
|
||||||
@BatchSize(size = 20)
|
@BatchSize(size = 20)
|
||||||
private Set<Authority> authorities = new HashSet<>();
|
private Set<Authority> authorities = new HashSet<>();
|
||||||
@ -219,14 +222,14 @@ public class User extends AbstractAuditingEntity implements Serializable {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "User{" +
|
return "User{" +
|
||||||
"login='" + login + '\'' +
|
"login='" + login + '\'' +
|
||||||
", firstName='" + firstName + '\'' +
|
", firstName='" + firstName + '\'' +
|
||||||
", lastName='" + lastName + '\'' +
|
", lastName='" + lastName + '\'' +
|
||||||
", email='" + email + '\'' +
|
", email='" + email + '\'' +
|
||||||
", imageUrl='" + imageUrl + '\'' +
|
", imageUrl='" + imageUrl + '\'' +
|
||||||
", activated='" + activated + '\'' +
|
", activated='" + activated + '\'' +
|
||||||
", langKey='" + langKey + '\'' +
|
", langKey='" + langKey + '\'' +
|
||||||
", activationKey='" + activationKey + '\'' +
|
", activationKey='" + activationKey + '\'' +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,14 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.domain.enumeration;
|
package org.hostsharing.hsadminng.domain.enumeration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The AssetAction enumeration.
|
* The AssetAction enumeration.
|
||||||
*/
|
*/
|
||||||
public enum AssetAction {
|
public enum AssetAction {
|
||||||
PAYMENT, HANDOVER, ADOPTION, LOSS, CLEARING, PAYBACK
|
PAYMENT,
|
||||||
|
HANDOVER,
|
||||||
|
ADOPTION,
|
||||||
|
LOSS,
|
||||||
|
CLEARING,
|
||||||
|
PAYBACK
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.domain.enumeration;
|
package org.hostsharing.hsadminng.domain.enumeration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The CustomerKind enumeration.
|
* The CustomerKind enumeration.
|
||||||
*/
|
*/
|
||||||
public enum CustomerKind {
|
public enum CustomerKind {
|
||||||
NATURAL, LEGAL
|
NATURAL,
|
||||||
|
LEGAL
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.domain.enumeration;
|
package org.hostsharing.hsadminng.domain.enumeration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ShareAction enumeration.
|
* The ShareAction enumeration.
|
||||||
*/
|
*/
|
||||||
public enum ShareAction {
|
public enum ShareAction {
|
||||||
SUBSCRIPTION, CANCELLATION
|
SUBSCRIPTION,
|
||||||
|
CANCELLATION
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.domain.enumeration;
|
package org.hostsharing.hsadminng.domain.enumeration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The VatRegion enumeration.
|
* The VatRegion enumeration.
|
||||||
*/
|
*/
|
||||||
public enum VatRegion {
|
public enum VatRegion {
|
||||||
DOMESTIC, EU, OTHER
|
DOMESTIC,
|
||||||
|
EU,
|
||||||
|
OTHER
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.repository;
|
package org.hostsharing.hsadminng.repository;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.Asset;
|
import org.hostsharing.hsadminng.domain.Asset;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.*;
|
import org.springframework.data.jpa.repository.*;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring Data repository for the Asset entity.
|
* Spring Data repository for the Asset entity.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Repository
|
@Repository
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.repository;
|
package org.hostsharing.hsadminng.repository;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.Authority;
|
import org.hostsharing.hsadminng.domain.Authority;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.repository;
|
package org.hostsharing.hsadminng.repository;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.config.Constants;
|
import org.hostsharing.hsadminng.config.Constants;
|
||||||
@ -34,7 +35,8 @@ public class CustomAuditEventRepository implements AuditEventRepository {
|
|||||||
|
|
||||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
public CustomAuditEventRepository(PersistenceAuditEventRepository persistenceAuditEventRepository,
|
public CustomAuditEventRepository(
|
||||||
|
PersistenceAuditEventRepository persistenceAuditEventRepository,
|
||||||
AuditEventConverter auditEventConverter) {
|
AuditEventConverter auditEventConverter) {
|
||||||
|
|
||||||
this.persistenceAuditEventRepository = persistenceAuditEventRepository;
|
this.persistenceAuditEventRepository = persistenceAuditEventRepository;
|
||||||
@ -43,8 +45,8 @@ public class CustomAuditEventRepository implements AuditEventRepository {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AuditEvent> find(String principal, Instant after, String type) {
|
public List<AuditEvent> find(String principal, Instant after, String type) {
|
||||||
Iterable<PersistentAuditEvent> persistentAuditEvents =
|
Iterable<PersistentAuditEvent> persistentAuditEvents = persistenceAuditEventRepository
|
||||||
persistenceAuditEventRepository.findByPrincipalAndAuditEventDateAfterAndAuditEventType(principal, after, type);
|
.findByPrincipalAndAuditEventDateAfterAndAuditEventType(principal, after, type);
|
||||||
return auditEventConverter.convertToAuditEvent(persistentAuditEvents);
|
return auditEventConverter.convertToAuditEvent(persistentAuditEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +54,7 @@ public class CustomAuditEventRepository implements AuditEventRepository {
|
|||||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||||
public void add(AuditEvent event) {
|
public void add(AuditEvent event) {
|
||||||
if (!AUTHORIZATION_FAILURE.equals(event.getType()) &&
|
if (!AUTHORIZATION_FAILURE.equals(event.getType()) &&
|
||||||
!Constants.ANONYMOUS_USER.equals(event.getPrincipal())) {
|
!Constants.ANONYMOUS_USER.equals(event.getPrincipal())) {
|
||||||
|
|
||||||
PersistentAuditEvent persistentAuditEvent = new PersistentAuditEvent();
|
PersistentAuditEvent persistentAuditEvent = new PersistentAuditEvent();
|
||||||
persistentAuditEvent.setPrincipal(event.getPrincipal());
|
persistentAuditEvent.setPrincipal(event.getPrincipal());
|
||||||
@ -77,8 +79,11 @@ public class CustomAuditEventRepository implements AuditEventRepository {
|
|||||||
int length = value.length();
|
int length = value.length();
|
||||||
if (length > EVENT_DATA_COLUMN_MAX_LENGTH) {
|
if (length > EVENT_DATA_COLUMN_MAX_LENGTH) {
|
||||||
value = value.substring(0, EVENT_DATA_COLUMN_MAX_LENGTH);
|
value = value.substring(0, EVENT_DATA_COLUMN_MAX_LENGTH);
|
||||||
log.warn("Event data for {} too long ({}) has been truncated to {}. Consider increasing column width.",
|
log.warn(
|
||||||
entry.getKey(), length, EVENT_DATA_COLUMN_MAX_LENGTH);
|
"Event data for {} too long ({}) has been truncated to {}. Consider increasing column width.",
|
||||||
|
entry.getKey(),
|
||||||
|
length,
|
||||||
|
EVENT_DATA_COLUMN_MAX_LENGTH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
results.put(entry.getKey(), value);
|
results.put(entry.getKey(), value);
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.repository;
|
package org.hostsharing.hsadminng.repository;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.Customer;
|
import org.hostsharing.hsadminng.domain.Customer;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.*;
|
import org.springframework.data.jpa.repository.*;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring Data repository for the Customer entity.
|
* Spring Data repository for the Customer entity.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Repository
|
@Repository
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.repository;
|
package org.hostsharing.hsadminng.repository;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.Membership;
|
import org.hostsharing.hsadminng.domain.Membership;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring Data repository for the Membership entity.
|
* Spring Data repository for the Membership entity.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Repository
|
@Repository
|
||||||
public interface MembershipRepository extends JpaRepository<Membership, Long>, JpaSpecificationExecutor<Membership> {
|
public interface MembershipRepository extends JpaRepository<Membership, Long>, JpaSpecificationExecutor<Membership> {
|
||||||
|
|
||||||
@Query("SELECT CASE WHEN COUNT(m)> 0 THEN TRUE ELSE FALSE END " +
|
@Query("SELECT CASE WHEN COUNT(m)> 0 THEN TRUE ELSE FALSE END " +
|
||||||
" FROM Membership m WHERE m.customer.id=:customerId AND m.memberUntilDate IS NULL")
|
" FROM Membership m WHERE m.customer.id=:customerId AND m.memberUntilDate IS NULL")
|
||||||
boolean hasUncancelledMembershipForCustomer(@Param("customerId") final long customerId);
|
boolean hasUncancelledMembershipForCustomer(@Param("customerId") final long customerId);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.repository;
|
package org.hostsharing.hsadminng.repository;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.PersistentAuditEvent;
|
import org.hostsharing.hsadminng.domain.PersistentAuditEvent;
|
||||||
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
@ -19,7 +21,10 @@ public interface PersistenceAuditEventRepository extends JpaRepository<Persisten
|
|||||||
|
|
||||||
List<PersistentAuditEvent> findByPrincipalAndAuditEventDateAfter(String principal, Instant after);
|
List<PersistentAuditEvent> findByPrincipalAndAuditEventDateAfter(String principal, Instant after);
|
||||||
|
|
||||||
List<PersistentAuditEvent> findByPrincipalAndAuditEventDateAfterAndAuditEventType(String principal, Instant after, String type);
|
List<PersistentAuditEvent> findByPrincipalAndAuditEventDateAfterAndAuditEventType(
|
||||||
|
String principal,
|
||||||
|
Instant after,
|
||||||
|
String type);
|
||||||
|
|
||||||
Page<PersistentAuditEvent> findAllByAuditEventDateBetween(Instant fromDate, Instant toDate, Pageable pageable);
|
Page<PersistentAuditEvent> findAllByAuditEventDateBetween(Instant fromDate, Instant toDate, Pageable pageable);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.repository;
|
package org.hostsharing.hsadminng.repository;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.SepaMandate;
|
import org.hostsharing.hsadminng.domain.SepaMandate;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.*;
|
import org.springframework.data.jpa.repository.*;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring Data repository for the SepaMandate entity.
|
* Spring Data repository for the SepaMandate entity.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Repository
|
@Repository
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.repository;
|
package org.hostsharing.hsadminng.repository;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.Share;
|
import org.hostsharing.hsadminng.domain.Share;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.*;
|
import org.springframework.data.jpa.repository.*;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring Data repository for the Share entity.
|
* Spring Data repository for the Share entity.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Repository
|
@Repository
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.repository;
|
package org.hostsharing.hsadminng.repository;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.User;
|
import org.hostsharing.hsadminng.domain.User;
|
||||||
@ -8,9 +9,10 @@ import org.springframework.data.domain.Pageable;
|
|||||||
import org.springframework.data.jpa.repository.EntityGraph;
|
import org.springframework.data.jpa.repository.EntityGraph;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.time.Instant;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring Data JPA repository for the User entity.
|
* Spring Data JPA repository for the User entity.
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.security;
|
package org.hostsharing.hsadminng.security;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.security;
|
package org.hostsharing.hsadminng.security;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.User;
|
import org.hostsharing.hsadminng.domain.User;
|
||||||
import org.hostsharing.hsadminng.repository.UserRepository;
|
import org.hostsharing.hsadminng.repository.UserRepository;
|
||||||
|
|
||||||
import org.hibernate.validator.internal.constraintvalidators.hv.EmailValidator;
|
import org.hibernate.validator.internal.constraintvalidators.hv.EmailValidator;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -37,14 +39,15 @@ public class DomainUserDetailsService implements UserDetailsService {
|
|||||||
|
|
||||||
if (new EmailValidator().isValid(login, null)) {
|
if (new EmailValidator().isValid(login, null)) {
|
||||||
return userRepository.findOneWithAuthoritiesByEmail(login)
|
return userRepository.findOneWithAuthoritiesByEmail(login)
|
||||||
.map(user -> createSpringSecurityUser(login, user))
|
.map(user -> createSpringSecurityUser(login, user))
|
||||||
.orElseThrow(() -> new UsernameNotFoundException("User with email " + login + " was not found in the database"));
|
.orElseThrow(
|
||||||
|
() -> new UsernameNotFoundException("User with email " + login + " was not found in the database"));
|
||||||
}
|
}
|
||||||
|
|
||||||
String lowercaseLogin = login.toLowerCase(Locale.ENGLISH);
|
String lowercaseLogin = login.toLowerCase(Locale.ENGLISH);
|
||||||
return userRepository.findOneWithAuthoritiesByLogin(lowercaseLogin)
|
return userRepository.findOneWithAuthoritiesByLogin(lowercaseLogin)
|
||||||
.map(user -> createSpringSecurityUser(lowercaseLogin, user))
|
.map(user -> createSpringSecurityUser(lowercaseLogin, user))
|
||||||
.orElseThrow(() -> new UsernameNotFoundException("User " + lowercaseLogin + " was not found in the database"));
|
.orElseThrow(() -> new UsernameNotFoundException("User " + lowercaseLogin + " was not found in the database"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,11 +55,13 @@ public class DomainUserDetailsService implements UserDetailsService {
|
|||||||
if (!user.getActivated()) {
|
if (!user.getActivated()) {
|
||||||
throw new UserNotActivatedException("User " + lowercaseLogin + " was not activated");
|
throw new UserNotActivatedException("User " + lowercaseLogin + " was not activated");
|
||||||
}
|
}
|
||||||
List<GrantedAuthority> grantedAuthorities = user.getAuthorities().stream()
|
List<GrantedAuthority> grantedAuthorities = user.getAuthorities()
|
||||||
.map(authority -> new SimpleGrantedAuthority(authority.getName()))
|
.stream()
|
||||||
.collect(Collectors.toList());
|
.map(authority -> new SimpleGrantedAuthority(authority.getName()))
|
||||||
return new org.springframework.security.core.userdetails.User(user.getLogin(),
|
.collect(Collectors.toList());
|
||||||
user.getPassword(),
|
return new org.springframework.security.core.userdetails.User(
|
||||||
grantedAuthorities);
|
user.getLogin(),
|
||||||
|
user.getPassword(),
|
||||||
|
grantedAuthorities);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.security;
|
package org.hostsharing.hsadminng.security;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.service.accessfilter.Role;
|
import org.hostsharing.hsadminng.service.accessfilter.Role;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.security.core.context.SecurityContext;
|
import org.springframework.security.core.context.SecurityContext;
|
||||||
@ -31,15 +33,15 @@ public final class SecurityUtils {
|
|||||||
public static Optional<String> getCurrentUserLogin() {
|
public static Optional<String> getCurrentUserLogin() {
|
||||||
SecurityContext securityContext = SecurityContextHolder.getContext();
|
SecurityContext securityContext = SecurityContextHolder.getContext();
|
||||||
return Optional.ofNullable(securityContext.getAuthentication())
|
return Optional.ofNullable(securityContext.getAuthentication())
|
||||||
.map(authentication -> {
|
.map(authentication -> {
|
||||||
if (authentication.getPrincipal() instanceof UserDetails) {
|
if (authentication.getPrincipal() instanceof UserDetails) {
|
||||||
UserDetails springSecurityUser = (UserDetails) authentication.getPrincipal();
|
UserDetails springSecurityUser = (UserDetails) authentication.getPrincipal();
|
||||||
return springSecurityUser.getUsername();
|
return springSecurityUser.getUsername();
|
||||||
} else if (authentication.getPrincipal() instanceof String) {
|
} else if (authentication.getPrincipal() instanceof String) {
|
||||||
return (String) authentication.getPrincipal();
|
return (String) authentication.getPrincipal();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,8 +52,8 @@ public final class SecurityUtils {
|
|||||||
public static Optional<String> getCurrentUserJWT() {
|
public static Optional<String> getCurrentUserJWT() {
|
||||||
SecurityContext securityContext = SecurityContextHolder.getContext();
|
SecurityContext securityContext = SecurityContextHolder.getContext();
|
||||||
return Optional.ofNullable(securityContext.getAuthentication())
|
return Optional.ofNullable(securityContext.getAuthentication())
|
||||||
.filter(authentication -> authentication.getCredentials() instanceof String)
|
.filter(authentication -> authentication.getCredentials() instanceof String)
|
||||||
.map(authentication -> (String) authentication.getCredentials());
|
.map(authentication -> (String) authentication.getCredentials());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,9 +64,13 @@ public final class SecurityUtils {
|
|||||||
public static boolean isAuthenticated() {
|
public static boolean isAuthenticated() {
|
||||||
SecurityContext securityContext = SecurityContextHolder.getContext();
|
SecurityContext securityContext = SecurityContextHolder.getContext();
|
||||||
return Optional.ofNullable(securityContext.getAuthentication())
|
return Optional.ofNullable(securityContext.getAuthentication())
|
||||||
.map(authentication -> authentication.getAuthorities().stream()
|
.map(
|
||||||
.noneMatch(grantedAuthority -> grantedAuthority.getAuthority().equals(AuthoritiesConstants.ANONYMOUS)))
|
authentication -> authentication.getAuthorities()
|
||||||
.orElse(false);
|
.stream()
|
||||||
|
.noneMatch(
|
||||||
|
grantedAuthority -> grantedAuthority.getAuthority()
|
||||||
|
.equals(AuthoritiesConstants.ANONYMOUS)))
|
||||||
|
.orElse(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,24 +84,27 @@ public final class SecurityUtils {
|
|||||||
public static boolean isCurrentUserInRole(String authority) {
|
public static boolean isCurrentUserInRole(String authority) {
|
||||||
SecurityContext securityContext = SecurityContextHolder.getContext();
|
SecurityContext securityContext = SecurityContextHolder.getContext();
|
||||||
return Optional.ofNullable(securityContext.getAuthentication())
|
return Optional.ofNullable(securityContext.getAuthentication())
|
||||||
.map(authentication -> authentication.getAuthorities().stream()
|
.map(
|
||||||
.anyMatch(grantedAuthority -> grantedAuthority.getAuthority().equals(authority)))
|
authentication -> authentication.getAuthorities()
|
||||||
.orElse(false);
|
.stream()
|
||||||
|
.anyMatch(grantedAuthority -> grantedAuthority.getAuthority().equals(authority)))
|
||||||
|
.orElse(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Role getLoginUserRoleFor(final Class<?> onDtoClass, final Long onId) {
|
public static Role getLoginUserRoleFor(final Class<?> onDtoClass, final Long onId) {
|
||||||
final Role highestRole = userRoleAssignments.stream().
|
final Role highestRole = userRoleAssignments.stream()
|
||||||
map(ura ->
|
.map(
|
||||||
matches(onDtoClass, onId, ura)
|
ura -> matches(onDtoClass, onId, ura)
|
||||||
? ura.role
|
? ura.role
|
||||||
: Role.ANYBODY).
|
: Role.ANYBODY)
|
||||||
reduce(Role.ANYBODY, (r1, r2) -> r1.covers(r2) ? r1 : r2);
|
.reduce(Role.ANYBODY, (r1, r2) -> r1.covers(r2) ? r1 : r2);
|
||||||
log.debug("getLoginUserRoleFor({}, {}) returned {}", onDtoClass, onId, highestRole);
|
log.debug("getLoginUserRoleFor({}, {}) returned {}", onDtoClass, onId, highestRole);
|
||||||
return highestRole;
|
return highestRole;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean matches(Class<?> onDtoClass, Long onId, UserRoleAssignment ura) {
|
private static boolean matches(Class<?> onDtoClass, Long onId, UserRoleAssignment ura) {
|
||||||
final boolean matches = (ura.onClass == null || onDtoClass == ura.onClass) && (ura.onId == null || ura.onId.equals(onId));
|
final boolean matches = (ura.onClass == null || onDtoClass == ura.onClass)
|
||||||
|
&& (ura.onId == null || ura.onId.equals(onId));
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,6 +120,7 @@ public final class SecurityUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class UserRoleAssignment {
|
private static class UserRoleAssignment {
|
||||||
|
|
||||||
final Class<?> onClass;
|
final Class<?> onClass;
|
||||||
final Long onId;
|
final Long onId;
|
||||||
final Role role;
|
final Role role;
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.security;
|
package org.hostsharing.hsadminng.security;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.config.Constants;
|
import org.hostsharing.hsadminng.config.Constants;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import org.springframework.data.domain.AuditorAware;
|
import org.springframework.data.domain.AuditorAware;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of AuditorAware based on Spring Security.
|
* Implementation of AuditorAware based on Spring Security.
|
||||||
*/
|
*/
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.security;
|
package org.hostsharing.hsadminng.security;
|
||||||
|
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.security.jwt;
|
package org.hostsharing.hsadminng.security.jwt;
|
||||||
|
|
||||||
import org.springframework.security.config.annotation.SecurityConfigurerAdapter;
|
import org.springframework.security.config.annotation.SecurityConfigurerAdapter;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.security.jwt;
|
package org.hostsharing.hsadminng.security.jwt;
|
||||||
|
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
@ -5,12 +6,13 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.filter.GenericFilterBean;
|
import org.springframework.web.filter.GenericFilterBean;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import javax.servlet.FilterChain;
|
import javax.servlet.FilterChain;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.ServletRequest;
|
import javax.servlet.ServletRequest;
|
||||||
import javax.servlet.ServletResponse;
|
import javax.servlet.ServletResponse;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters incoming requests and installs a Spring Security principal if a header corresponding to a valid user is
|
* Filters incoming requests and installs a Spring Security principal if a header corresponding to a valid user is
|
||||||
@ -28,7 +30,7 @@ public class JWTFilter extends GenericFilterBean {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
|
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
|
||||||
throws IOException, ServletException {
|
throws IOException, ServletException {
|
||||||
HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
|
HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
|
||||||
String jwt = resolveToken(httpServletRequest);
|
String jwt = resolveToken(httpServletRequest);
|
||||||
if (StringUtils.hasText(jwt) && this.tokenProvider.validateToken(jwt)) {
|
if (StringUtils.hasText(jwt) && this.tokenProvider.validateToken(jwt)) {
|
||||||
@ -38,7 +40,7 @@ public class JWTFilter extends GenericFilterBean {
|
|||||||
filterChain.doFilter(servletRequest, servletResponse);
|
filterChain.doFilter(servletRequest, servletResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String resolveToken(HttpServletRequest request){
|
private String resolveToken(HttpServletRequest request) {
|
||||||
String bearerToken = request.getHeader(AUTHORIZATION_HEADER);
|
String bearerToken = request.getHeader(AUTHORIZATION_HEADER);
|
||||||
if (StringUtils.hasText(bearerToken) && bearerToken.startsWith("Bearer ")) {
|
if (StringUtils.hasText(bearerToken) && bearerToken.startsWith("Bearer ")) {
|
||||||
return bearerToken.substring(7);
|
return bearerToken.substring(7);
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.security.jwt;
|
package org.hostsharing.hsadminng.security.jwt;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import io.github.jhipster.config.JHipsterProperties;
|
||||||
import java.security.Key;
|
import io.jsonwebtoken.*;
|
||||||
import java.util.*;
|
import io.jsonwebtoken.io.Decoders;
|
||||||
import java.util.stream.Collectors;
|
import io.jsonwebtoken.security.Keys;
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -16,10 +16,12 @@ import org.springframework.security.core.userdetails.User;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import io.github.jhipster.config.JHipsterProperties;
|
import java.nio.charset.StandardCharsets;
|
||||||
import io.jsonwebtoken.*;
|
import java.security.Key;
|
||||||
import io.jsonwebtoken.io.Decoders;
|
import java.util.*;
|
||||||
import io.jsonwebtoken.security.Keys;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class TokenProvider {
|
public class TokenProvider {
|
||||||
@ -45,25 +47,28 @@ public class TokenProvider {
|
|||||||
byte[] keyBytes;
|
byte[] keyBytes;
|
||||||
String secret = jHipsterProperties.getSecurity().getAuthentication().getJwt().getSecret();
|
String secret = jHipsterProperties.getSecurity().getAuthentication().getJwt().getSecret();
|
||||||
if (!StringUtils.isEmpty(secret)) {
|
if (!StringUtils.isEmpty(secret)) {
|
||||||
log.warn("Warning: the JWT key used is not Base64-encoded. " +
|
log.warn(
|
||||||
"We recommend using the `jhipster.security.authentication.jwt.base64-secret` key for optimum security.");
|
"Warning: the JWT key used is not Base64-encoded. " +
|
||||||
|
"We recommend using the `jhipster.security.authentication.jwt.base64-secret` key for optimum security.");
|
||||||
keyBytes = secret.getBytes(StandardCharsets.UTF_8);
|
keyBytes = secret.getBytes(StandardCharsets.UTF_8);
|
||||||
} else {
|
} else {
|
||||||
log.debug("Using a Base64-encoded JWT secret key");
|
log.debug("Using a Base64-encoded JWT secret key");
|
||||||
keyBytes = Decoders.BASE64.decode(jHipsterProperties.getSecurity().getAuthentication().getJwt().getBase64Secret());
|
keyBytes = Decoders.BASE64.decode(jHipsterProperties.getSecurity().getAuthentication().getJwt().getBase64Secret());
|
||||||
}
|
}
|
||||||
this.key = Keys.hmacShaKeyFor(keyBytes);
|
this.key = Keys.hmacShaKeyFor(keyBytes);
|
||||||
this.tokenValidityInMilliseconds =
|
this.tokenValidityInMilliseconds = 1000
|
||||||
1000 * jHipsterProperties.getSecurity().getAuthentication().getJwt().getTokenValidityInSeconds();
|
* jHipsterProperties.getSecurity().getAuthentication().getJwt().getTokenValidityInSeconds();
|
||||||
this.tokenValidityInMillisecondsForRememberMe =
|
this.tokenValidityInMillisecondsForRememberMe = 1000 * jHipsterProperties.getSecurity()
|
||||||
1000 * jHipsterProperties.getSecurity().getAuthentication().getJwt()
|
.getAuthentication()
|
||||||
|
.getJwt()
|
||||||
.getTokenValidityInSecondsForRememberMe();
|
.getTokenValidityInSecondsForRememberMe();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String createToken(Authentication authentication, boolean rememberMe) {
|
public String createToken(Authentication authentication, boolean rememberMe) {
|
||||||
String authorities = authentication.getAuthorities().stream()
|
String authorities = authentication.getAuthorities()
|
||||||
.map(GrantedAuthority::getAuthority)
|
.stream()
|
||||||
.collect(Collectors.joining(","));
|
.map(GrantedAuthority::getAuthority)
|
||||||
|
.collect(Collectors.joining(","));
|
||||||
|
|
||||||
long now = (new Date()).getTime();
|
long now = (new Date()).getTime();
|
||||||
Date validity;
|
Date validity;
|
||||||
@ -74,21 +79,20 @@ public class TokenProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Jwts.builder()
|
return Jwts.builder()
|
||||||
.setSubject(authentication.getName())
|
.setSubject(authentication.getName())
|
||||||
.claim(AUTHORITIES_KEY, authorities)
|
.claim(AUTHORITIES_KEY, authorities)
|
||||||
.signWith(key, SignatureAlgorithm.HS512)
|
.signWith(key, SignatureAlgorithm.HS512)
|
||||||
.setExpiration(validity)
|
.setExpiration(validity)
|
||||||
.compact();
|
.compact();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Authentication getAuthentication(String token) {
|
public Authentication getAuthentication(String token) {
|
||||||
Claims claims = Jwts.parser()
|
Claims claims = Jwts.parser()
|
||||||
.setSigningKey(key)
|
.setSigningKey(key)
|
||||||
.parseClaimsJws(token)
|
.parseClaimsJws(token)
|
||||||
.getBody();
|
.getBody();
|
||||||
|
|
||||||
Collection<? extends GrantedAuthority> authorities =
|
Collection<? extends GrantedAuthority> authorities = Arrays.stream(claims.get(AUTHORITIES_KEY).toString().split(","))
|
||||||
Arrays.stream(claims.get(AUTHORITIES_KEY).toString().split(","))
|
|
||||||
.map(SimpleGrantedAuthority::new)
|
.map(SimpleGrantedAuthority::new)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
@ -1,8 +1,14 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service;
|
package org.hostsharing.hsadminng.service;
|
||||||
|
|
||||||
import java.util.List;
|
import org.hostsharing.hsadminng.domain.*;
|
||||||
|
import org.hostsharing.hsadminng.domain.Asset;
|
||||||
|
import org.hostsharing.hsadminng.repository.AssetRepository;
|
||||||
|
import org.hostsharing.hsadminng.service.dto.AssetCriteria;
|
||||||
|
import org.hostsharing.hsadminng.service.dto.AssetDTO;
|
||||||
|
import org.hostsharing.hsadminng.service.mapper.AssetMapper;
|
||||||
|
|
||||||
import javax.persistence.criteria.JoinType;
|
import io.github.jhipster.service.QueryService;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -12,14 +18,9 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import io.github.jhipster.service.QueryService;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.Asset;
|
import javax.persistence.criteria.JoinType;
|
||||||
import org.hostsharing.hsadminng.domain.*; // for static metamodels
|
|
||||||
import org.hostsharing.hsadminng.repository.AssetRepository;
|
|
||||||
import org.hostsharing.hsadminng.service.dto.AssetCriteria;
|
|
||||||
import org.hostsharing.hsadminng.service.dto.AssetDTO;
|
|
||||||
import org.hostsharing.hsadminng.service.mapper.AssetMapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for executing complex queries for Asset entities in the database.
|
* Service for executing complex queries for Asset entities in the database.
|
||||||
@ -44,6 +45,7 @@ public class AssetQueryService extends QueryService<Asset> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a {@link List} of {@link AssetDTO} which matches the criteria from the database
|
* Return a {@link List} of {@link AssetDTO} which matches the criteria from the database
|
||||||
|
*
|
||||||
* @param criteria The object which holds all the filters, which the entities should match.
|
* @param criteria The object which holds all the filters, which the entities should match.
|
||||||
* @return the matching entities.
|
* @return the matching entities.
|
||||||
*/
|
*/
|
||||||
@ -56,6 +58,7 @@ public class AssetQueryService extends QueryService<Asset> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a {@link Page} of {@link AssetDTO} which matches the criteria from the database
|
* Return a {@link Page} of {@link AssetDTO} which matches the criteria from the database
|
||||||
|
*
|
||||||
* @param criteria The object which holds all the filters, which the entities should match.
|
* @param criteria The object which holds all the filters, which the entities should match.
|
||||||
* @param page The page, which should be returned.
|
* @param page The page, which should be returned.
|
||||||
* @return the matching entities.
|
* @return the matching entities.
|
||||||
@ -65,11 +68,12 @@ public class AssetQueryService extends QueryService<Asset> {
|
|||||||
log.debug("find by criteria : {}, page: {}", criteria, page);
|
log.debug("find by criteria : {}, page: {}", criteria, page);
|
||||||
final Specification<Asset> specification = createSpecification(criteria);
|
final Specification<Asset> specification = createSpecification(criteria);
|
||||||
return assetRepository.findAll(specification, page)
|
return assetRepository.findAll(specification, page)
|
||||||
.map(assetMapper::toDto);
|
.map(assetMapper::toDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of matching entities in the database
|
* Return the number of matching entities in the database
|
||||||
|
*
|
||||||
* @param criteria The object which holds all the filters, which the entities should match.
|
* @param criteria The object which holds all the filters, which the entities should match.
|
||||||
* @return the number of matching entities.
|
* @return the number of matching entities.
|
||||||
*/
|
*/
|
||||||
@ -105,8 +109,10 @@ public class AssetQueryService extends QueryService<Asset> {
|
|||||||
specification = specification.and(buildStringSpecification(criteria.getRemark(), Asset_.remark));
|
specification = specification.and(buildStringSpecification(criteria.getRemark(), Asset_.remark));
|
||||||
}
|
}
|
||||||
if (criteria.getMembershipId() != null) {
|
if (criteria.getMembershipId() != null) {
|
||||||
specification = specification.and(buildSpecification(criteria.getMembershipId(),
|
specification = specification.and(
|
||||||
root -> root.join(Asset_.membership, JoinType.LEFT).get(Membership_.id)));
|
buildSpecification(
|
||||||
|
criteria.getMembershipId(),
|
||||||
|
root -> root.join(Asset_.membership, JoinType.LEFT).get(Membership_.id)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return specification;
|
return specification;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service;
|
package org.hostsharing.hsadminng.service;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.Asset;
|
import org.hostsharing.hsadminng.domain.Asset;
|
||||||
@ -5,6 +6,7 @@ import org.hostsharing.hsadminng.repository.AssetRepository;
|
|||||||
import org.hostsharing.hsadminng.service.dto.AssetDTO;
|
import org.hostsharing.hsadminng.service.dto.AssetDTO;
|
||||||
import org.hostsharing.hsadminng.service.mapper.AssetMapper;
|
import org.hostsharing.hsadminng.service.mapper.AssetMapper;
|
||||||
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@ -12,9 +14,10 @@ import org.springframework.data.domain.Pageable;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service Implementation for managing Asset.
|
* Service Implementation for managing Asset.
|
||||||
*/
|
*/
|
||||||
@ -31,7 +34,11 @@ public class AssetService implements IdToDtoResolver<AssetDTO> {
|
|||||||
private final AssetMapper assetMapper;
|
private final AssetMapper assetMapper;
|
||||||
private final AssetValidator assetValidator;
|
private final AssetValidator assetValidator;
|
||||||
|
|
||||||
public AssetService(final EntityManager em, final AssetRepository assetRepository, final AssetMapper assetMapper, final AssetValidator assetValidator) {
|
public AssetService(
|
||||||
|
final EntityManager em,
|
||||||
|
final AssetRepository assetRepository,
|
||||||
|
final AssetMapper assetMapper,
|
||||||
|
final AssetValidator assetValidator) {
|
||||||
this.em = em;
|
this.em = em;
|
||||||
this.assetRepository = assetRepository;
|
this.assetRepository = assetRepository;
|
||||||
this.assetMapper = assetMapper;
|
this.assetMapper = assetMapper;
|
||||||
@ -64,10 +71,9 @@ public class AssetService implements IdToDtoResolver<AssetDTO> {
|
|||||||
public Page<AssetDTO> findAll(Pageable pageable) {
|
public Page<AssetDTO> findAll(Pageable pageable) {
|
||||||
log.debug("Request to get all Assets");
|
log.debug("Request to get all Assets");
|
||||||
return assetRepository.findAll(pageable)
|
return assetRepository.findAll(pageable)
|
||||||
.map(assetMapper::toDto);
|
.map(assetMapper::toDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get one asset by id.
|
* Get one asset by id.
|
||||||
*
|
*
|
||||||
@ -78,7 +84,7 @@ public class AssetService implements IdToDtoResolver<AssetDTO> {
|
|||||||
public Optional<AssetDTO> findOne(Long id) {
|
public Optional<AssetDTO> findOne(Long id) {
|
||||||
log.debug("Request to get Asset : {}", id);
|
log.debug("Request to get Asset : {}", id);
|
||||||
return assetRepository.findById(id)
|
return assetRepository.findById(id)
|
||||||
.map(assetMapper::toDto);
|
.map(assetMapper::toDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,42 +1,69 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service;
|
package org.hostsharing.hsadminng.service;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.Asset;
|
import org.hostsharing.hsadminng.domain.Asset;
|
||||||
import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
|
import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
|
||||||
import org.hostsharing.hsadminng.service.dto.AssetDTO;
|
import org.hostsharing.hsadminng.service.dto.AssetDTO;
|
||||||
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class AssetValidator {
|
public class AssetValidator {
|
||||||
|
|
||||||
public void validate(final AssetDTO assetDTO) {
|
public void validate(final AssetDTO assetDTO) {
|
||||||
if (assetDTO.getId() != null) {
|
if (assetDTO.getId() != null) {
|
||||||
throw new BadRequestAlertException("Asset transactions are immutable", Asset.ENTITY_NAME, "assetTransactionImmutable");
|
throw new BadRequestAlertException(
|
||||||
|
"Asset transactions are immutable",
|
||||||
|
Asset.ENTITY_NAME,
|
||||||
|
"assetTransactionImmutable");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (assetDTO.getDocumentDate().isAfter(assetDTO.getValueDate())) {
|
if (assetDTO.getDocumentDate().isAfter(assetDTO.getValueDate())) {
|
||||||
throw new BadRequestAlertException("Document date may not be after value date", Asset.ENTITY_NAME, "documentDateMayNotBeAfterValueDate");
|
throw new BadRequestAlertException(
|
||||||
|
"Document date may not be after value date",
|
||||||
|
Asset.ENTITY_NAME,
|
||||||
|
"documentDateMayNotBeAfterValueDate");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((assetDTO.getAction() == AssetAction.PAYMENT) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) <= 0)) {
|
if ((assetDTO.getAction() == AssetAction.PAYMENT) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) <= 0)) {
|
||||||
throw new BadRequestAlertException("Asset payments require a positive amount", Asset.ENTITY_NAME, "assetPaymentsPositiveAmount");
|
throw new BadRequestAlertException(
|
||||||
|
"Asset payments require a positive amount",
|
||||||
|
Asset.ENTITY_NAME,
|
||||||
|
"assetPaymentsPositiveAmount");
|
||||||
}
|
}
|
||||||
if ((assetDTO.getAction() == AssetAction.ADOPTION) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) <= 0)) {
|
if ((assetDTO.getAction() == AssetAction.ADOPTION) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) <= 0)) {
|
||||||
throw new BadRequestAlertException("Asset adoptions require a positive amount", Asset.ENTITY_NAME, "assetAdoptionsPositiveAmount");
|
throw new BadRequestAlertException(
|
||||||
|
"Asset adoptions require a positive amount",
|
||||||
|
Asset.ENTITY_NAME,
|
||||||
|
"assetAdoptionsPositiveAmount");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((assetDTO.getAction() == AssetAction.PAYBACK) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) >= 0)) {
|
if ((assetDTO.getAction() == AssetAction.PAYBACK) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) >= 0)) {
|
||||||
throw new BadRequestAlertException("Asset paybacks require a negative amount", Asset.ENTITY_NAME, "assetPaybacksNegativeAmount");
|
throw new BadRequestAlertException(
|
||||||
|
"Asset paybacks require a negative amount",
|
||||||
|
Asset.ENTITY_NAME,
|
||||||
|
"assetPaybacksNegativeAmount");
|
||||||
}
|
}
|
||||||
if ((assetDTO.getAction() == AssetAction.HANDOVER) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) >= 0)) {
|
if ((assetDTO.getAction() == AssetAction.HANDOVER) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) >= 0)) {
|
||||||
throw new BadRequestAlertException("Asset handovers require a negative amount", Asset.ENTITY_NAME, "assetHandoversNegativeAmount");
|
throw new BadRequestAlertException(
|
||||||
|
"Asset handovers require a negative amount",
|
||||||
|
Asset.ENTITY_NAME,
|
||||||
|
"assetHandoversNegativeAmount");
|
||||||
}
|
}
|
||||||
if ((assetDTO.getAction() == AssetAction.LOSS) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) >= 0)) {
|
if ((assetDTO.getAction() == AssetAction.LOSS) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) >= 0)) {
|
||||||
throw new BadRequestAlertException("Asset losses require a negative amount", Asset.ENTITY_NAME, "assetLossesNegativeAmount");
|
throw new BadRequestAlertException(
|
||||||
|
"Asset losses require a negative amount",
|
||||||
|
Asset.ENTITY_NAME,
|
||||||
|
"assetLossesNegativeAmount");
|
||||||
}
|
}
|
||||||
if ((assetDTO.getAction() == AssetAction.CLEARING) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) >= 0)) {
|
if ((assetDTO.getAction() == AssetAction.CLEARING) && (assetDTO.getAmount().compareTo(BigDecimal.valueOf(0)) >= 0)) {
|
||||||
throw new BadRequestAlertException("Asset clearings require a negative amount", Asset.ENTITY_NAME, "assetClearingsNegativeAmount");
|
throw new BadRequestAlertException(
|
||||||
|
"Asset clearings require a negative amount",
|
||||||
|
Asset.ENTITY_NAME,
|
||||||
|
"assetClearingsNegativeAmount");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service;
|
package org.hostsharing.hsadminng.service;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.config.audit.AuditEventConverter;
|
import org.hostsharing.hsadminng.config.audit.AuditEventConverter;
|
||||||
import org.hostsharing.hsadminng.repository.PersistenceAuditEventRepository;
|
import org.hostsharing.hsadminng.repository.PersistenceAuditEventRepository;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.audit.AuditEvent;
|
import org.springframework.boot.actuate.audit.AuditEvent;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
@ -25,8 +27,8 @@ public class AuditEventService {
|
|||||||
private final AuditEventConverter auditEventConverter;
|
private final AuditEventConverter auditEventConverter;
|
||||||
|
|
||||||
public AuditEventService(
|
public AuditEventService(
|
||||||
PersistenceAuditEventRepository persistenceAuditEventRepository,
|
PersistenceAuditEventRepository persistenceAuditEventRepository,
|
||||||
AuditEventConverter auditEventConverter) {
|
AuditEventConverter auditEventConverter) {
|
||||||
|
|
||||||
this.persistenceAuditEventRepository = persistenceAuditEventRepository;
|
this.persistenceAuditEventRepository = persistenceAuditEventRepository;
|
||||||
this.auditEventConverter = auditEventConverter;
|
this.auditEventConverter = auditEventConverter;
|
||||||
@ -34,18 +36,18 @@ public class AuditEventService {
|
|||||||
|
|
||||||
public Page<AuditEvent> findAll(Pageable pageable) {
|
public Page<AuditEvent> findAll(Pageable pageable) {
|
||||||
return persistenceAuditEventRepository.findAll(pageable)
|
return persistenceAuditEventRepository.findAll(pageable)
|
||||||
.map(auditEventConverter::convertToAuditEvent);
|
.map(auditEventConverter::convertToAuditEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<AuditEvent> findByDates(Instant fromDate, Instant toDate, Pageable pageable) {
|
public Page<AuditEvent> findByDates(Instant fromDate, Instant toDate, Pageable pageable) {
|
||||||
return persistenceAuditEventRepository.findAllByAuditEventDateBetween(fromDate, toDate, pageable)
|
return persistenceAuditEventRepository.findAllByAuditEventDateBetween(fromDate, toDate, pageable)
|
||||||
.map(auditEventConverter::convertToAuditEvent);
|
.map(auditEventConverter::convertToAuditEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<AuditEvent> find(Long id) {
|
public Optional<AuditEvent> find(Long id) {
|
||||||
return Optional.ofNullable(persistenceAuditEventRepository.findById(id))
|
return Optional.ofNullable(persistenceAuditEventRepository.findById(id))
|
||||||
.filter(Optional::isPresent)
|
.filter(Optional::isPresent)
|
||||||
.map(Optional::get)
|
.map(Optional::get)
|
||||||
.map(auditEventConverter::convertToAuditEvent);
|
.map(auditEventConverter::convertToAuditEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service;
|
package org.hostsharing.hsadminng.service;
|
||||||
|
|
||||||
import io.github.jhipster.service.QueryService;
|
|
||||||
import org.hostsharing.hsadminng.domain.Customer;
|
import org.hostsharing.hsadminng.domain.Customer;
|
||||||
import org.hostsharing.hsadminng.domain.Customer_;
|
import org.hostsharing.hsadminng.domain.Customer_;
|
||||||
import org.hostsharing.hsadminng.domain.Membership_;
|
import org.hostsharing.hsadminng.domain.Membership_;
|
||||||
@ -9,6 +9,9 @@ import org.hostsharing.hsadminng.repository.CustomerRepository;
|
|||||||
import org.hostsharing.hsadminng.service.dto.CustomerCriteria;
|
import org.hostsharing.hsadminng.service.dto.CustomerCriteria;
|
||||||
import org.hostsharing.hsadminng.service.dto.CustomerDTO;
|
import org.hostsharing.hsadminng.service.dto.CustomerDTO;
|
||||||
import org.hostsharing.hsadminng.service.mapper.CustomerMapper;
|
import org.hostsharing.hsadminng.service.mapper.CustomerMapper;
|
||||||
|
|
||||||
|
import io.github.jhipster.service.QueryService;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@ -17,9 +20,10 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.persistence.criteria.JoinType;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.persistence.criteria.JoinType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for executing complex queries for Customer entities in the database.
|
* Service for executing complex queries for Customer entities in the database.
|
||||||
* The main input is a {@link CustomerCriteria} which gets converted to {@link Specification},
|
* The main input is a {@link CustomerCriteria} which gets converted to {@link Specification},
|
||||||
@ -43,6 +47,7 @@ public class CustomerQueryService extends QueryService<Customer> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a {@link List} of {@link CustomerDTO} which matches the criteria from the database
|
* Return a {@link List} of {@link CustomerDTO} which matches the criteria from the database
|
||||||
|
*
|
||||||
* @param criteria The object which holds all the filters, which the entities should match.
|
* @param criteria The object which holds all the filters, which the entities should match.
|
||||||
* @return the matching entities.
|
* @return the matching entities.
|
||||||
*/
|
*/
|
||||||
@ -55,6 +60,7 @@ public class CustomerQueryService extends QueryService<Customer> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a {@link Page} of {@link CustomerDTO} which matches the criteria from the database
|
* Return a {@link Page} of {@link CustomerDTO} which matches the criteria from the database
|
||||||
|
*
|
||||||
* @param criteria The object which holds all the filters, which the entities should match.
|
* @param criteria The object which holds all the filters, which the entities should match.
|
||||||
* @param page The page, which should be returned.
|
* @param page The page, which should be returned.
|
||||||
* @return the matching entities.
|
* @return the matching entities.
|
||||||
@ -64,11 +70,12 @@ public class CustomerQueryService extends QueryService<Customer> {
|
|||||||
log.debug("find by criteria : {}, page: {}", criteria, page);
|
log.debug("find by criteria : {}, page: {}", criteria, page);
|
||||||
final Specification<Customer> specification = createSpecification(criteria);
|
final Specification<Customer> specification = createSpecification(criteria);
|
||||||
return customerRepository.findAll(specification, page)
|
return customerRepository.findAll(specification, page)
|
||||||
.map(customerMapper::toDto);
|
.map(customerMapper::toDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of matching entities in the database
|
* Return the number of matching entities in the database
|
||||||
|
*
|
||||||
* @param criteria The object which holds all the filters, which the entities should match.
|
* @param criteria The object which holds all the filters, which the entities should match.
|
||||||
* @return the number of matching entities.
|
* @return the number of matching entities.
|
||||||
*/
|
*/
|
||||||
@ -107,10 +114,12 @@ public class CustomerQueryService extends QueryService<Customer> {
|
|||||||
specification = specification.and(buildStringSpecification(criteria.getBirthPlace(), Customer_.birthPlace));
|
specification = specification.and(buildStringSpecification(criteria.getBirthPlace(), Customer_.birthPlace));
|
||||||
}
|
}
|
||||||
if (criteria.getRegistrationCourt() != null) {
|
if (criteria.getRegistrationCourt() != null) {
|
||||||
specification = specification.and(buildStringSpecification(criteria.getRegistrationCourt(), Customer_.registrationCourt));
|
specification = specification
|
||||||
|
.and(buildStringSpecification(criteria.getRegistrationCourt(), Customer_.registrationCourt));
|
||||||
}
|
}
|
||||||
if (criteria.getRegistrationNumber() != null) {
|
if (criteria.getRegistrationNumber() != null) {
|
||||||
specification = specification.and(buildStringSpecification(criteria.getRegistrationNumber(), Customer_.registrationNumber));
|
specification = specification
|
||||||
|
.and(buildStringSpecification(criteria.getRegistrationNumber(), Customer_.registrationNumber));
|
||||||
}
|
}
|
||||||
if (criteria.getVatRegion() != null) {
|
if (criteria.getVatRegion() != null) {
|
||||||
specification = specification.and(buildSpecification(criteria.getVatRegion(), Customer_.vatRegion));
|
specification = specification.and(buildSpecification(criteria.getVatRegion(), Customer_.vatRegion));
|
||||||
@ -119,27 +128,35 @@ public class CustomerQueryService extends QueryService<Customer> {
|
|||||||
specification = specification.and(buildStringSpecification(criteria.getVatNumber(), Customer_.vatNumber));
|
specification = specification.and(buildStringSpecification(criteria.getVatNumber(), Customer_.vatNumber));
|
||||||
}
|
}
|
||||||
if (criteria.getContractualSalutation() != null) {
|
if (criteria.getContractualSalutation() != null) {
|
||||||
specification = specification.and(buildStringSpecification(criteria.getContractualSalutation(), Customer_.contractualSalutation));
|
specification = specification
|
||||||
|
.and(buildStringSpecification(criteria.getContractualSalutation(), Customer_.contractualSalutation));
|
||||||
}
|
}
|
||||||
if (criteria.getContractualAddress() != null) {
|
if (criteria.getContractualAddress() != null) {
|
||||||
specification = specification.and(buildStringSpecification(criteria.getContractualAddress(), Customer_.contractualAddress));
|
specification = specification
|
||||||
|
.and(buildStringSpecification(criteria.getContractualAddress(), Customer_.contractualAddress));
|
||||||
}
|
}
|
||||||
if (criteria.getBillingSalutation() != null) {
|
if (criteria.getBillingSalutation() != null) {
|
||||||
specification = specification.and(buildStringSpecification(criteria.getBillingSalutation(), Customer_.billingSalutation));
|
specification = specification
|
||||||
|
.and(buildStringSpecification(criteria.getBillingSalutation(), Customer_.billingSalutation));
|
||||||
}
|
}
|
||||||
if (criteria.getBillingAddress() != null) {
|
if (criteria.getBillingAddress() != null) {
|
||||||
specification = specification.and(buildStringSpecification(criteria.getBillingAddress(), Customer_.billingAddress));
|
specification = specification
|
||||||
|
.and(buildStringSpecification(criteria.getBillingAddress(), Customer_.billingAddress));
|
||||||
}
|
}
|
||||||
if (criteria.getRemark() != null) {
|
if (criteria.getRemark() != null) {
|
||||||
specification = specification.and(buildStringSpecification(criteria.getRemark(), Customer_.remark));
|
specification = specification.and(buildStringSpecification(criteria.getRemark(), Customer_.remark));
|
||||||
}
|
}
|
||||||
if (criteria.getMembershipId() != null) {
|
if (criteria.getMembershipId() != null) {
|
||||||
specification = specification.and(buildSpecification(criteria.getMembershipId(),
|
specification = specification.and(
|
||||||
root -> root.join(Customer_.memberships, JoinType.LEFT).get(Membership_.id)));
|
buildSpecification(
|
||||||
|
criteria.getMembershipId(),
|
||||||
|
root -> root.join(Customer_.memberships, JoinType.LEFT).get(Membership_.id)));
|
||||||
}
|
}
|
||||||
if (criteria.getSepamandateId() != null) {
|
if (criteria.getSepamandateId() != null) {
|
||||||
specification = specification.and(buildSpecification(criteria.getSepamandateId(),
|
specification = specification.and(
|
||||||
root -> root.join(Customer_.sepamandates, JoinType.LEFT).get(SepaMandate_.id)));
|
buildSpecification(
|
||||||
|
criteria.getSepamandateId(),
|
||||||
|
root -> root.join(Customer_.sepamandates, JoinType.LEFT).get(SepaMandate_.id)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return specification;
|
return specification;
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service;
|
package org.hostsharing.hsadminng.service;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.Customer;
|
import org.hostsharing.hsadminng.domain.Customer;
|
||||||
import org.hostsharing.hsadminng.repository.CustomerRepository;
|
import org.hostsharing.hsadminng.repository.CustomerRepository;
|
||||||
import org.hostsharing.hsadminng.service.dto.CustomerDTO;
|
import org.hostsharing.hsadminng.service.dto.CustomerDTO;
|
||||||
import org.hostsharing.hsadminng.service.mapper.CustomerMapper;
|
import org.hostsharing.hsadminng.service.mapper.CustomerMapper;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@ -54,10 +56,9 @@ public class CustomerService implements IdToDtoResolver<CustomerDTO> {
|
|||||||
public Page<CustomerDTO> findAll(Pageable pageable) {
|
public Page<CustomerDTO> findAll(Pageable pageable) {
|
||||||
log.debug("Request to get all Customers");
|
log.debug("Request to get all Customers");
|
||||||
return customerRepository.findAll(pageable)
|
return customerRepository.findAll(pageable)
|
||||||
.map(customerMapper::toDto);
|
.map(customerMapper::toDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get one customer by id.
|
* Get one customer by id.
|
||||||
*
|
*
|
||||||
@ -68,7 +69,7 @@ public class CustomerService implements IdToDtoResolver<CustomerDTO> {
|
|||||||
public Optional<CustomerDTO> findOne(Long id) {
|
public Optional<CustomerDTO> findOne(Long id) {
|
||||||
log.debug("Request to get Customer : {}", id);
|
log.debug("Request to get Customer : {}", id);
|
||||||
return customerRepository.findById(id)
|
return customerRepository.findById(id)
|
||||||
.map(customerMapper::toDto);
|
.map(customerMapper::toDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service;
|
package org.hostsharing.hsadminng.service;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public interface IdToDtoResolver<T> {
|
public interface IdToDtoResolver<T> {
|
||||||
|
|
||||||
Optional<T> findOne(Long id);
|
Optional<T> findOne(Long id);
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service;
|
package org.hostsharing.hsadminng.service;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.User;
|
import org.hostsharing.hsadminng.domain.User;
|
||||||
|
|
||||||
import io.github.jhipster.config.JHipsterProperties;
|
import io.github.jhipster.config.JHipsterProperties;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.Locale;
|
|
||||||
import javax.mail.internet.MimeMessage;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
@ -18,6 +15,11 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.thymeleaf.context.Context;
|
import org.thymeleaf.context.Context;
|
||||||
import org.thymeleaf.spring5.SpringTemplateEngine;
|
import org.thymeleaf.spring5.SpringTemplateEngine;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import javax.mail.internet.MimeMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for sending emails.
|
* Service for sending emails.
|
||||||
* <p>
|
* <p>
|
||||||
@ -40,8 +42,11 @@ public class MailService {
|
|||||||
|
|
||||||
private final SpringTemplateEngine templateEngine;
|
private final SpringTemplateEngine templateEngine;
|
||||||
|
|
||||||
public MailService(JHipsterProperties jHipsterProperties, JavaMailSender javaMailSender,
|
public MailService(
|
||||||
MessageSource messageSource, SpringTemplateEngine templateEngine) {
|
JHipsterProperties jHipsterProperties,
|
||||||
|
JavaMailSender javaMailSender,
|
||||||
|
MessageSource messageSource,
|
||||||
|
SpringTemplateEngine templateEngine) {
|
||||||
|
|
||||||
this.jHipsterProperties = jHipsterProperties;
|
this.jHipsterProperties = jHipsterProperties;
|
||||||
this.javaMailSender = javaMailSender;
|
this.javaMailSender = javaMailSender;
|
||||||
@ -51,8 +56,13 @@ public class MailService {
|
|||||||
|
|
||||||
@Async
|
@Async
|
||||||
public void sendEmail(String to, String subject, String content, boolean isMultipart, boolean isHtml) {
|
public void sendEmail(String to, String subject, String content, boolean isMultipart, boolean isHtml) {
|
||||||
log.debug("Send email[multipart '{}' and html '{}'] to '{}' with subject '{}' and content={}",
|
log.debug(
|
||||||
isMultipart, isHtml, to, subject, content);
|
"Send email[multipart '{}' and html '{}'] to '{}' with subject '{}' and content={}",
|
||||||
|
isMultipart,
|
||||||
|
isHtml,
|
||||||
|
to,
|
||||||
|
subject,
|
||||||
|
content);
|
||||||
|
|
||||||
// Prepare message using a Spring helper
|
// Prepare message using a Spring helper
|
||||||
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
|
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service;
|
package org.hostsharing.hsadminng.service;
|
||||||
|
|
||||||
import io.github.jhipster.service.QueryService;
|
|
||||||
import org.hostsharing.hsadminng.domain.*;
|
import org.hostsharing.hsadminng.domain.*;
|
||||||
import org.hostsharing.hsadminng.repository.MembershipRepository;
|
import org.hostsharing.hsadminng.repository.MembershipRepository;
|
||||||
import org.hostsharing.hsadminng.service.dto.MembershipCriteria;
|
import org.hostsharing.hsadminng.service.dto.MembershipCriteria;
|
||||||
import org.hostsharing.hsadminng.service.dto.MembershipDTO;
|
import org.hostsharing.hsadminng.service.dto.MembershipDTO;
|
||||||
import org.hostsharing.hsadminng.service.mapper.MembershipMapper;
|
import org.hostsharing.hsadminng.service.mapper.MembershipMapper;
|
||||||
|
|
||||||
|
import io.github.jhipster.service.QueryService;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@ -14,9 +17,10 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.persistence.criteria.JoinType;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.persistence.criteria.JoinType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for executing complex queries for Membership entities in the database.
|
* Service for executing complex queries for Membership entities in the database.
|
||||||
* The main input is a {@link MembershipCriteria} which gets converted to {@link Specification},
|
* The main input is a {@link MembershipCriteria} which gets converted to {@link Specification},
|
||||||
@ -40,6 +44,7 @@ public class MembershipQueryService extends QueryService<Membership> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a {@link List} of {@link MembershipDTO} which matches the criteria from the database
|
* Return a {@link List} of {@link MembershipDTO} which matches the criteria from the database
|
||||||
|
*
|
||||||
* @param criteria The object which holds all the filters, which the entities should match.
|
* @param criteria The object which holds all the filters, which the entities should match.
|
||||||
* @return the matching entities.
|
* @return the matching entities.
|
||||||
*/
|
*/
|
||||||
@ -52,6 +57,7 @@ public class MembershipQueryService extends QueryService<Membership> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a {@link Page} of {@link MembershipDTO} which matches the criteria from the database
|
* Return a {@link Page} of {@link MembershipDTO} which matches the criteria from the database
|
||||||
|
*
|
||||||
* @param criteria The object which holds all the filters, which the entities should match.
|
* @param criteria The object which holds all the filters, which the entities should match.
|
||||||
* @param page The page, which should be returned.
|
* @param page The page, which should be returned.
|
||||||
* @return the matching entities.
|
* @return the matching entities.
|
||||||
@ -61,11 +67,12 @@ public class MembershipQueryService extends QueryService<Membership> {
|
|||||||
log.debug("find by criteria : {}, page: {}", criteria, page);
|
log.debug("find by criteria : {}, page: {}", criteria, page);
|
||||||
final Specification<Membership> specification = createSpecification(criteria);
|
final Specification<Membership> specification = createSpecification(criteria);
|
||||||
return membershipRepository.findAll(specification, page)
|
return membershipRepository.findAll(specification, page)
|
||||||
.map(membershipMapper::toDto);
|
.map(membershipMapper::toDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of matching entities in the database
|
* Return the number of matching entities in the database
|
||||||
|
*
|
||||||
* @param criteria The object which holds all the filters, which the entities should match.
|
* @param criteria The object which holds all the filters, which the entities should match.
|
||||||
* @return the number of matching entities.
|
* @return the number of matching entities.
|
||||||
*/
|
*/
|
||||||
@ -86,31 +93,41 @@ public class MembershipQueryService extends QueryService<Membership> {
|
|||||||
specification = specification.and(buildSpecification(criteria.getId(), Membership_.id));
|
specification = specification.and(buildSpecification(criteria.getId(), Membership_.id));
|
||||||
}
|
}
|
||||||
if (criteria.getAdmissionDocumentDate() != null) {
|
if (criteria.getAdmissionDocumentDate() != null) {
|
||||||
specification = specification.and(buildRangeSpecification(criteria.getAdmissionDocumentDate(), Membership_.admissionDocumentDate));
|
specification = specification
|
||||||
|
.and(buildRangeSpecification(criteria.getAdmissionDocumentDate(), Membership_.admissionDocumentDate));
|
||||||
}
|
}
|
||||||
if (criteria.getCancellationDocumentDate() != null) {
|
if (criteria.getCancellationDocumentDate() != null) {
|
||||||
specification = specification.and(buildRangeSpecification(criteria.getCancellationDocumentDate(), Membership_.cancellationDocumentDate));
|
specification = specification.and(
|
||||||
|
buildRangeSpecification(criteria.getCancellationDocumentDate(), Membership_.cancellationDocumentDate));
|
||||||
}
|
}
|
||||||
if (criteria.getMemberFromDate() != null) {
|
if (criteria.getMemberFromDate() != null) {
|
||||||
specification = specification.and(buildRangeSpecification(criteria.getMemberFromDate(), Membership_.memberFromDate));
|
specification = specification
|
||||||
|
.and(buildRangeSpecification(criteria.getMemberFromDate(), Membership_.memberFromDate));
|
||||||
}
|
}
|
||||||
if (criteria.getMemberUntilDate() != null) {
|
if (criteria.getMemberUntilDate() != null) {
|
||||||
specification = specification.and(buildRangeSpecification(criteria.getMemberUntilDate(), Membership_.memberUntilDate));
|
specification = specification
|
||||||
|
.and(buildRangeSpecification(criteria.getMemberUntilDate(), Membership_.memberUntilDate));
|
||||||
}
|
}
|
||||||
if (criteria.getRemark() != null) {
|
if (criteria.getRemark() != null) {
|
||||||
specification = specification.and(buildStringSpecification(criteria.getRemark(), Membership_.remark));
|
specification = specification.and(buildStringSpecification(criteria.getRemark(), Membership_.remark));
|
||||||
}
|
}
|
||||||
if (criteria.getShareId() != null) {
|
if (criteria.getShareId() != null) {
|
||||||
specification = specification.and(buildSpecification(criteria.getShareId(),
|
specification = specification.and(
|
||||||
root -> root.join(Membership_.shares, JoinType.LEFT).get(Share_.id)));
|
buildSpecification(
|
||||||
|
criteria.getShareId(),
|
||||||
|
root -> root.join(Membership_.shares, JoinType.LEFT).get(Share_.id)));
|
||||||
}
|
}
|
||||||
if (criteria.getAssetId() != null) {
|
if (criteria.getAssetId() != null) {
|
||||||
specification = specification.and(buildSpecification(criteria.getAssetId(),
|
specification = specification.and(
|
||||||
root -> root.join(Membership_.assets, JoinType.LEFT).get(Asset_.id)));
|
buildSpecification(
|
||||||
|
criteria.getAssetId(),
|
||||||
|
root -> root.join(Membership_.assets, JoinType.LEFT).get(Asset_.id)));
|
||||||
}
|
}
|
||||||
if (criteria.getCustomerId() != null) {
|
if (criteria.getCustomerId() != null) {
|
||||||
specification = specification.and(buildSpecification(criteria.getCustomerId(),
|
specification = specification.and(
|
||||||
root -> root.join(Membership_.customer, JoinType.LEFT).get(Customer_.id)));
|
buildSpecification(
|
||||||
|
criteria.getCustomerId(),
|
||||||
|
root -> root.join(Membership_.customer, JoinType.LEFT).get(Customer_.id)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return specification;
|
return specification;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service;
|
package org.hostsharing.hsadminng.service;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.Membership;
|
import org.hostsharing.hsadminng.domain.Membership;
|
||||||
@ -5,6 +6,7 @@ import org.hostsharing.hsadminng.repository.MembershipRepository;
|
|||||||
import org.hostsharing.hsadminng.service.dto.MembershipDTO;
|
import org.hostsharing.hsadminng.service.dto.MembershipDTO;
|
||||||
import org.hostsharing.hsadminng.service.mapper.MembershipMapper;
|
import org.hostsharing.hsadminng.service.mapper.MembershipMapper;
|
||||||
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@ -12,9 +14,10 @@ import org.springframework.data.domain.Pageable;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service Implementation for managing Membership.
|
* Service Implementation for managing Membership.
|
||||||
*/
|
*/
|
||||||
@ -32,10 +35,11 @@ public class MembershipService implements IdToDtoResolver<MembershipDTO> {
|
|||||||
|
|
||||||
private final MembershipMapper membershipMapper;
|
private final MembershipMapper membershipMapper;
|
||||||
|
|
||||||
public MembershipService(final EntityManager em,
|
public MembershipService(
|
||||||
final MembershipValidator membershipValidator,
|
final EntityManager em,
|
||||||
final MembershipRepository membershipRepository,
|
final MembershipValidator membershipValidator,
|
||||||
final MembershipMapper membershipMapper) {
|
final MembershipRepository membershipRepository,
|
||||||
|
final MembershipMapper membershipMapper) {
|
||||||
this.em = em;
|
this.em = em;
|
||||||
this.membershipValidator = membershipValidator;
|
this.membershipValidator = membershipValidator;
|
||||||
this.membershipRepository = membershipRepository;
|
this.membershipRepository = membershipRepository;
|
||||||
@ -70,10 +74,9 @@ public class MembershipService implements IdToDtoResolver<MembershipDTO> {
|
|||||||
public Page<MembershipDTO> findAll(Pageable pageable) {
|
public Page<MembershipDTO> findAll(Pageable pageable) {
|
||||||
log.debug("Request to get all Memberships");
|
log.debug("Request to get all Memberships");
|
||||||
return membershipRepository.findAll(pageable)
|
return membershipRepository.findAll(pageable)
|
||||||
.map(membershipMapper::toDto);
|
.map(membershipMapper::toDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get one membership by id.
|
* Get one membership by id.
|
||||||
*
|
*
|
||||||
@ -85,7 +88,7 @@ public class MembershipService implements IdToDtoResolver<MembershipDTO> {
|
|||||||
public Optional<MembershipDTO> findOne(Long id) {
|
public Optional<MembershipDTO> findOne(Long id) {
|
||||||
log.debug("Request to get Membership : {}", id);
|
log.debug("Request to get Membership : {}", id);
|
||||||
return membershipRepository.findById(id)
|
return membershipRepository.findById(id)
|
||||||
.map(membershipMapper::toDto);
|
.map(membershipMapper::toDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service;
|
package org.hostsharing.hsadminng.service;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.Membership;
|
import org.hostsharing.hsadminng.domain.Membership;
|
||||||
import org.hostsharing.hsadminng.repository.MembershipRepository;
|
import org.hostsharing.hsadminng.repository.MembershipRepository;
|
||||||
import org.hostsharing.hsadminng.service.dto.MembershipDTO;
|
import org.hostsharing.hsadminng.service.dto.MembershipDTO;
|
||||||
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -14,14 +16,18 @@ public class MembershipValidator {
|
|||||||
private MembershipRepository membershipRepository;
|
private MembershipRepository membershipRepository;
|
||||||
|
|
||||||
public void validate(final MembershipDTO membershipDTO) {
|
public void validate(final MembershipDTO membershipDTO) {
|
||||||
if (membershipDTO.getMemberUntilDate() != null && !membershipDTO.getMemberUntilDate().isAfter(membershipDTO.getMemberFromDate())) {
|
if (membershipDTO.getMemberUntilDate() != null
|
||||||
|
&& !membershipDTO.getMemberUntilDate().isAfter(membershipDTO.getMemberFromDate())) {
|
||||||
throw new BadRequestAlertException("Invalid untilDate", Membership.ENTITY_NAME, "untilDateMustBeAfterSinceDate");
|
throw new BadRequestAlertException("Invalid untilDate", Membership.ENTITY_NAME, "untilDateMustBeAfterSinceDate");
|
||||||
}
|
}
|
||||||
|
|
||||||
// It's known that this validation can cause a race condition if two memberships of the same customer are saved at
|
// It's known that this validation can cause a race condition if two memberships of the same customer are saved at
|
||||||
// same time (overlapping transactions). This is ignored in this case because it's too unlikely to be worth the effort.
|
// same time (overlapping transactions). This is ignored in this case because it's too unlikely to be worth the effort.
|
||||||
if (membershipRepository.hasUncancelledMembershipForCustomer(membershipDTO.getCustomerId())) {
|
if (membershipRepository.hasUncancelledMembershipForCustomer(membershipDTO.getCustomerId())) {
|
||||||
throw new BadRequestAlertException("Another uncancelled membership exists", Membership.ENTITY_NAME, "anotherUncancelledMembershipExists");
|
throw new BadRequestAlertException(
|
||||||
|
"Another uncancelled membership exists",
|
||||||
|
Membership.ENTITY_NAME,
|
||||||
|
"anotherUncancelledMembershipExists");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service;
|
package org.hostsharing.hsadminng.service;
|
||||||
|
|
||||||
import io.github.jhipster.service.QueryService;
|
|
||||||
import org.hostsharing.hsadminng.domain.Customer_;
|
import org.hostsharing.hsadminng.domain.Customer_;
|
||||||
import org.hostsharing.hsadminng.domain.SepaMandate;
|
import org.hostsharing.hsadminng.domain.SepaMandate;
|
||||||
import org.hostsharing.hsadminng.domain.SepaMandate_;
|
import org.hostsharing.hsadminng.domain.SepaMandate_;
|
||||||
@ -8,6 +8,9 @@ import org.hostsharing.hsadminng.repository.SepaMandateRepository;
|
|||||||
import org.hostsharing.hsadminng.service.dto.SepaMandateCriteria;
|
import org.hostsharing.hsadminng.service.dto.SepaMandateCriteria;
|
||||||
import org.hostsharing.hsadminng.service.dto.SepaMandateDTO;
|
import org.hostsharing.hsadminng.service.dto.SepaMandateDTO;
|
||||||
import org.hostsharing.hsadminng.service.mapper.SepaMandateMapper;
|
import org.hostsharing.hsadminng.service.mapper.SepaMandateMapper;
|
||||||
|
|
||||||
|
import io.github.jhipster.service.QueryService;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@ -16,9 +19,10 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.persistence.criteria.JoinType;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.persistence.criteria.JoinType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for executing complex queries for SepaMandate entities in the database.
|
* Service for executing complex queries for SepaMandate entities in the database.
|
||||||
* The main input is a {@link SepaMandateCriteria} which gets converted to {@link Specification},
|
* The main input is a {@link SepaMandateCriteria} which gets converted to {@link Specification},
|
||||||
@ -42,6 +46,7 @@ public class SepaMandateQueryService extends QueryService<SepaMandate> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a {@link List} of {@link SepaMandateDTO} which matches the criteria from the database
|
* Return a {@link List} of {@link SepaMandateDTO} which matches the criteria from the database
|
||||||
|
*
|
||||||
* @param criteria The object which holds all the filters, which the entities should match.
|
* @param criteria The object which holds all the filters, which the entities should match.
|
||||||
* @return the matching entities.
|
* @return the matching entities.
|
||||||
*/
|
*/
|
||||||
@ -54,6 +59,7 @@ public class SepaMandateQueryService extends QueryService<SepaMandate> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a {@link Page} of {@link SepaMandateDTO} which matches the criteria from the database
|
* Return a {@link Page} of {@link SepaMandateDTO} which matches the criteria from the database
|
||||||
|
*
|
||||||
* @param criteria The object which holds all the filters, which the entities should match.
|
* @param criteria The object which holds all the filters, which the entities should match.
|
||||||
* @param page The page, which should be returned.
|
* @param page The page, which should be returned.
|
||||||
* @return the matching entities.
|
* @return the matching entities.
|
||||||
@ -63,11 +69,12 @@ public class SepaMandateQueryService extends QueryService<SepaMandate> {
|
|||||||
log.debug("find by criteria : {}, page: {}", criteria, page);
|
log.debug("find by criteria : {}, page: {}", criteria, page);
|
||||||
final Specification<SepaMandate> specification = createSpecification(criteria);
|
final Specification<SepaMandate> specification = createSpecification(criteria);
|
||||||
return sepaMandateRepository.findAll(specification, page)
|
return sepaMandateRepository.findAll(specification, page)
|
||||||
.map(sepaMandateMapper::toDto);
|
.map(sepaMandateMapper::toDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of matching entities in the database
|
* Return the number of matching entities in the database
|
||||||
|
*
|
||||||
* @param criteria The object which holds all the filters, which the entities should match.
|
* @param criteria The object which holds all the filters, which the entities should match.
|
||||||
* @return the number of matching entities.
|
* @return the number of matching entities.
|
||||||
*/
|
*/
|
||||||
@ -97,26 +104,33 @@ public class SepaMandateQueryService extends QueryService<SepaMandate> {
|
|||||||
specification = specification.and(buildStringSpecification(criteria.getBic(), SepaMandate_.bic));
|
specification = specification.and(buildStringSpecification(criteria.getBic(), SepaMandate_.bic));
|
||||||
}
|
}
|
||||||
if (criteria.getGrantingDocumentDate() != null) {
|
if (criteria.getGrantingDocumentDate() != null) {
|
||||||
specification = specification.and(buildRangeSpecification(criteria.getGrantingDocumentDate(), SepaMandate_.grantingDocumentDate));
|
specification = specification
|
||||||
|
.and(buildRangeSpecification(criteria.getGrantingDocumentDate(), SepaMandate_.grantingDocumentDate));
|
||||||
}
|
}
|
||||||
if (criteria.getRevokationDocumentDate() != null) {
|
if (criteria.getRevokationDocumentDate() != null) {
|
||||||
specification = specification.and(buildRangeSpecification(criteria.getRevokationDocumentDate(), SepaMandate_.revokationDocumentDate));
|
specification = specification.and(
|
||||||
|
buildRangeSpecification(criteria.getRevokationDocumentDate(), SepaMandate_.revokationDocumentDate));
|
||||||
}
|
}
|
||||||
if (criteria.getValidFromDate() != null) {
|
if (criteria.getValidFromDate() != null) {
|
||||||
specification = specification.and(buildRangeSpecification(criteria.getValidFromDate(), SepaMandate_.validFromDate));
|
specification = specification
|
||||||
|
.and(buildRangeSpecification(criteria.getValidFromDate(), SepaMandate_.validFromDate));
|
||||||
}
|
}
|
||||||
if (criteria.getValidUntilDate() != null) {
|
if (criteria.getValidUntilDate() != null) {
|
||||||
specification = specification.and(buildRangeSpecification(criteria.getValidUntilDate(), SepaMandate_.validUntilDate));
|
specification = specification
|
||||||
|
.and(buildRangeSpecification(criteria.getValidUntilDate(), SepaMandate_.validUntilDate));
|
||||||
}
|
}
|
||||||
if (criteria.getLastUsedDate() != null) {
|
if (criteria.getLastUsedDate() != null) {
|
||||||
specification = specification.and(buildRangeSpecification(criteria.getLastUsedDate(), SepaMandate_.lastUsedDate));
|
specification = specification
|
||||||
|
.and(buildRangeSpecification(criteria.getLastUsedDate(), SepaMandate_.lastUsedDate));
|
||||||
}
|
}
|
||||||
if (criteria.getRemark() != null) {
|
if (criteria.getRemark() != null) {
|
||||||
specification = specification.and(buildStringSpecification(criteria.getRemark(), SepaMandate_.remark));
|
specification = specification.and(buildStringSpecification(criteria.getRemark(), SepaMandate_.remark));
|
||||||
}
|
}
|
||||||
if (criteria.getCustomerId() != null) {
|
if (criteria.getCustomerId() != null) {
|
||||||
specification = specification.and(buildSpecification(criteria.getCustomerId(),
|
specification = specification.and(
|
||||||
root -> root.join(SepaMandate_.customer, JoinType.LEFT).get(Customer_.id)));
|
buildSpecification(
|
||||||
|
criteria.getCustomerId(),
|
||||||
|
root -> root.join(SepaMandate_.customer, JoinType.LEFT).get(Customer_.id)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return specification;
|
return specification;
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service;
|
package org.hostsharing.hsadminng.service;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.SepaMandate;
|
import org.hostsharing.hsadminng.domain.SepaMandate;
|
||||||
import org.hostsharing.hsadminng.repository.SepaMandateRepository;
|
import org.hostsharing.hsadminng.repository.SepaMandateRepository;
|
||||||
import org.hostsharing.hsadminng.service.dto.SepaMandateDTO;
|
import org.hostsharing.hsadminng.service.dto.SepaMandateDTO;
|
||||||
import org.hostsharing.hsadminng.service.mapper.SepaMandateMapper;
|
import org.hostsharing.hsadminng.service.mapper.SepaMandateMapper;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@ -11,9 +13,10 @@ import org.springframework.data.domain.Pageable;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service Implementation for managing SepaMandate.
|
* Service Implementation for managing SepaMandate.
|
||||||
*/
|
*/
|
||||||
@ -29,7 +32,10 @@ public class SepaMandateService implements IdToDtoResolver<SepaMandateDTO> {
|
|||||||
|
|
||||||
private final SepaMandateMapper sepaMandateMapper;
|
private final SepaMandateMapper sepaMandateMapper;
|
||||||
|
|
||||||
public SepaMandateService(final EntityManager em, final SepaMandateRepository sepaMandateRepository, final SepaMandateMapper sepaMandateMapper) {
|
public SepaMandateService(
|
||||||
|
final EntityManager em,
|
||||||
|
final SepaMandateRepository sepaMandateRepository,
|
||||||
|
final SepaMandateMapper sepaMandateMapper) {
|
||||||
this.em = em;
|
this.em = em;
|
||||||
this.sepaMandateRepository = sepaMandateRepository;
|
this.sepaMandateRepository = sepaMandateRepository;
|
||||||
this.sepaMandateMapper = sepaMandateMapper;
|
this.sepaMandateMapper = sepaMandateMapper;
|
||||||
@ -60,10 +66,9 @@ public class SepaMandateService implements IdToDtoResolver<SepaMandateDTO> {
|
|||||||
public Page<SepaMandateDTO> findAll(Pageable pageable) {
|
public Page<SepaMandateDTO> findAll(Pageable pageable) {
|
||||||
log.debug("Request to get all SepaMandates");
|
log.debug("Request to get all SepaMandates");
|
||||||
return sepaMandateRepository.findAll(pageable)
|
return sepaMandateRepository.findAll(pageable)
|
||||||
.map(sepaMandateMapper::toDto);
|
.map(sepaMandateMapper::toDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get one sepaMandate by id.
|
* Get one sepaMandate by id.
|
||||||
*
|
*
|
||||||
@ -74,7 +79,7 @@ public class SepaMandateService implements IdToDtoResolver<SepaMandateDTO> {
|
|||||||
public Optional<SepaMandateDTO> findOne(Long id) {
|
public Optional<SepaMandateDTO> findOne(Long id) {
|
||||||
log.debug("Request to get SepaMandate : {}", id);
|
log.debug("Request to get SepaMandate : {}", id);
|
||||||
return sepaMandateRepository.findById(id)
|
return sepaMandateRepository.findById(id)
|
||||||
.map(sepaMandateMapper::toDto);
|
.map(sepaMandateMapper::toDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,8 +1,14 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service;
|
package org.hostsharing.hsadminng.service;
|
||||||
|
|
||||||
import java.util.List;
|
import org.hostsharing.hsadminng.domain.*;
|
||||||
|
import org.hostsharing.hsadminng.domain.Share;
|
||||||
|
import org.hostsharing.hsadminng.repository.ShareRepository;
|
||||||
|
import org.hostsharing.hsadminng.service.dto.ShareCriteria;
|
||||||
|
import org.hostsharing.hsadminng.service.dto.ShareDTO;
|
||||||
|
import org.hostsharing.hsadminng.service.mapper.ShareMapper;
|
||||||
|
|
||||||
import javax.persistence.criteria.JoinType;
|
import io.github.jhipster.service.QueryService;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -12,14 +18,9 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import io.github.jhipster.service.QueryService;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.Share;
|
import javax.persistence.criteria.JoinType;
|
||||||
import org.hostsharing.hsadminng.domain.*; // for static metamodels
|
|
||||||
import org.hostsharing.hsadminng.repository.ShareRepository;
|
|
||||||
import org.hostsharing.hsadminng.service.dto.ShareCriteria;
|
|
||||||
import org.hostsharing.hsadminng.service.dto.ShareDTO;
|
|
||||||
import org.hostsharing.hsadminng.service.mapper.ShareMapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for executing complex queries for Share entities in the database.
|
* Service for executing complex queries for Share entities in the database.
|
||||||
@ -44,6 +45,7 @@ public class ShareQueryService extends QueryService<Share> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a {@link List} of {@link ShareDTO} which matches the criteria from the database
|
* Return a {@link List} of {@link ShareDTO} which matches the criteria from the database
|
||||||
|
*
|
||||||
* @param criteria The object which holds all the filters, which the entities should match.
|
* @param criteria The object which holds all the filters, which the entities should match.
|
||||||
* @return the matching entities.
|
* @return the matching entities.
|
||||||
*/
|
*/
|
||||||
@ -56,6 +58,7 @@ public class ShareQueryService extends QueryService<Share> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a {@link Page} of {@link ShareDTO} which matches the criteria from the database
|
* Return a {@link Page} of {@link ShareDTO} which matches the criteria from the database
|
||||||
|
*
|
||||||
* @param criteria The object which holds all the filters, which the entities should match.
|
* @param criteria The object which holds all the filters, which the entities should match.
|
||||||
* @param page The page, which should be returned.
|
* @param page The page, which should be returned.
|
||||||
* @return the matching entities.
|
* @return the matching entities.
|
||||||
@ -65,11 +68,12 @@ public class ShareQueryService extends QueryService<Share> {
|
|||||||
log.debug("find by criteria : {}, page: {}", criteria, page);
|
log.debug("find by criteria : {}, page: {}", criteria, page);
|
||||||
final Specification<Share> specification = createSpecification(criteria);
|
final Specification<Share> specification = createSpecification(criteria);
|
||||||
return shareRepository.findAll(specification, page)
|
return shareRepository.findAll(specification, page)
|
||||||
.map(shareMapper::toDto);
|
.map(shareMapper::toDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of matching entities in the database
|
* Return the number of matching entities in the database
|
||||||
|
*
|
||||||
* @param criteria The object which holds all the filters, which the entities should match.
|
* @param criteria The object which holds all the filters, which the entities should match.
|
||||||
* @return the number of matching entities.
|
* @return the number of matching entities.
|
||||||
*/
|
*/
|
||||||
@ -105,8 +109,10 @@ public class ShareQueryService extends QueryService<Share> {
|
|||||||
specification = specification.and(buildStringSpecification(criteria.getRemark(), Share_.remark));
|
specification = specification.and(buildStringSpecification(criteria.getRemark(), Share_.remark));
|
||||||
}
|
}
|
||||||
if (criteria.getMembershipId() != null) {
|
if (criteria.getMembershipId() != null) {
|
||||||
specification = specification.and(buildSpecification(criteria.getMembershipId(),
|
specification = specification.and(
|
||||||
root -> root.join(Share_.membership, JoinType.LEFT).get(Membership_.id)));
|
buildSpecification(
|
||||||
|
criteria.getMembershipId(),
|
||||||
|
root -> root.join(Share_.membership, JoinType.LEFT).get(Membership_.id)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return specification;
|
return specification;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service;
|
package org.hostsharing.hsadminng.service;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.Share;
|
import org.hostsharing.hsadminng.domain.Share;
|
||||||
@ -5,6 +6,7 @@ import org.hostsharing.hsadminng.repository.ShareRepository;
|
|||||||
import org.hostsharing.hsadminng.service.dto.ShareDTO;
|
import org.hostsharing.hsadminng.service.dto.ShareDTO;
|
||||||
import org.hostsharing.hsadminng.service.mapper.ShareMapper;
|
import org.hostsharing.hsadminng.service.mapper.ShareMapper;
|
||||||
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@ -12,9 +14,10 @@ import org.springframework.data.domain.Pageable;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service Implementation for managing Share.
|
* Service Implementation for managing Share.
|
||||||
*/
|
*/
|
||||||
@ -32,7 +35,11 @@ public class ShareService implements IdToDtoResolver<ShareDTO> {
|
|||||||
|
|
||||||
private final ShareValidator shareValidator;
|
private final ShareValidator shareValidator;
|
||||||
|
|
||||||
public ShareService(final EntityManager em, final ShareRepository shareRepository, final ShareMapper shareMapper, final ShareValidator shareValidator) {
|
public ShareService(
|
||||||
|
final EntityManager em,
|
||||||
|
final ShareRepository shareRepository,
|
||||||
|
final ShareMapper shareMapper,
|
||||||
|
final ShareValidator shareValidator) {
|
||||||
this.em = em;
|
this.em = em;
|
||||||
this.shareRepository = shareRepository;
|
this.shareRepository = shareRepository;
|
||||||
this.shareMapper = shareMapper;
|
this.shareMapper = shareMapper;
|
||||||
@ -67,10 +74,9 @@ public class ShareService implements IdToDtoResolver<ShareDTO> {
|
|||||||
public Page<ShareDTO> findAll(Pageable pageable) {
|
public Page<ShareDTO> findAll(Pageable pageable) {
|
||||||
log.debug("Request to get all Shares");
|
log.debug("Request to get all Shares");
|
||||||
return shareRepository.findAll(pageable)
|
return shareRepository.findAll(pageable)
|
||||||
.map(shareMapper::toDto);
|
.map(shareMapper::toDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get one share by id.
|
* Get one share by id.
|
||||||
*
|
*
|
||||||
@ -81,7 +87,7 @@ public class ShareService implements IdToDtoResolver<ShareDTO> {
|
|||||||
public Optional<ShareDTO> findOne(Long id) {
|
public Optional<ShareDTO> findOne(Long id) {
|
||||||
log.debug("Request to get Share : {}", id);
|
log.debug("Request to get Share : {}", id);
|
||||||
return shareRepository.findById(id)
|
return shareRepository.findById(id)
|
||||||
.map(shareMapper::toDto);
|
.map(shareMapper::toDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service;
|
package org.hostsharing.hsadminng.service;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.Share;
|
import org.hostsharing.hsadminng.domain.Share;
|
||||||
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
|
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
|
||||||
import org.hostsharing.hsadminng.service.dto.ShareDTO;
|
import org.hostsharing.hsadminng.service.dto.ShareDTO;
|
||||||
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -11,19 +13,31 @@ public class ShareValidator {
|
|||||||
|
|
||||||
public void validate(final ShareDTO shareDTO) {
|
public void validate(final ShareDTO shareDTO) {
|
||||||
if (shareDTO.getId() != null) {
|
if (shareDTO.getId() != null) {
|
||||||
throw new BadRequestAlertException("Share transactions are immutable", Share.ENTITY_NAME, "shareTransactionImmutable");
|
throw new BadRequestAlertException(
|
||||||
|
"Share transactions are immutable",
|
||||||
|
Share.ENTITY_NAME,
|
||||||
|
"shareTransactionImmutable");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shareDTO.getDocumentDate().isAfter(shareDTO.getValueDate())) {
|
if (shareDTO.getDocumentDate().isAfter(shareDTO.getValueDate())) {
|
||||||
throw new BadRequestAlertException("Document date may not be after value date", Share.ENTITY_NAME, "documentDateMayNotBeAfterValueDate");
|
throw new BadRequestAlertException(
|
||||||
|
"Document date may not be after value date",
|
||||||
|
Share.ENTITY_NAME,
|
||||||
|
"documentDateMayNotBeAfterValueDate");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((shareDTO.getAction() == ShareAction.SUBSCRIPTION) && (shareDTO.getQuantity() <= 0)) {
|
if ((shareDTO.getAction() == ShareAction.SUBSCRIPTION) && (shareDTO.getQuantity() <= 0)) {
|
||||||
throw new BadRequestAlertException("Share subscriptions require a positive quantity", Share.ENTITY_NAME, "shareSubscriptionPositiveQuantity");
|
throw new BadRequestAlertException(
|
||||||
|
"Share subscriptions require a positive quantity",
|
||||||
|
Share.ENTITY_NAME,
|
||||||
|
"shareSubscriptionPositiveQuantity");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((shareDTO.getAction() == ShareAction.CANCELLATION) && (shareDTO.getQuantity() >= 0)) {
|
if ((shareDTO.getAction() == ShareAction.CANCELLATION) && (shareDTO.getQuantity() >= 0)) {
|
||||||
throw new BadRequestAlertException("Share cancellations require a negative quantity", Share.ENTITY_NAME, "shareCancellationNegativeQuantity");
|
throw new BadRequestAlertException(
|
||||||
|
"Share cancellations require a negative quantity",
|
||||||
|
Share.ENTITY_NAME,
|
||||||
|
"shareCancellationNegativeQuantity");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service;
|
package org.hostsharing.hsadminng.service;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.config.Constants;
|
import org.hostsharing.hsadminng.config.Constants;
|
||||||
@ -43,7 +44,11 @@ public class UserService {
|
|||||||
|
|
||||||
private final CacheManager cacheManager;
|
private final CacheManager cacheManager;
|
||||||
|
|
||||||
public UserService(UserRepository userRepository, PasswordEncoder passwordEncoder, AuthorityRepository authorityRepository, CacheManager cacheManager) {
|
public UserService(
|
||||||
|
UserRepository userRepository,
|
||||||
|
PasswordEncoder passwordEncoder,
|
||||||
|
AuthorityRepository authorityRepository,
|
||||||
|
CacheManager cacheManager) {
|
||||||
this.userRepository = userRepository;
|
this.userRepository = userRepository;
|
||||||
this.passwordEncoder = passwordEncoder;
|
this.passwordEncoder = passwordEncoder;
|
||||||
this.authorityRepository = authorityRepository;
|
this.authorityRepository = authorityRepository;
|
||||||
@ -53,38 +58,38 @@ public class UserService {
|
|||||||
public Optional<User> activateRegistration(String key) {
|
public Optional<User> activateRegistration(String key) {
|
||||||
log.debug("Activating user for activation key {}", key);
|
log.debug("Activating user for activation key {}", key);
|
||||||
return userRepository.findOneByActivationKey(key)
|
return userRepository.findOneByActivationKey(key)
|
||||||
.map(user -> {
|
.map(user -> {
|
||||||
// activate given user for the registration key.
|
// activate given user for the registration key.
|
||||||
user.setActivated(true);
|
user.setActivated(true);
|
||||||
user.setActivationKey(null);
|
user.setActivationKey(null);
|
||||||
this.clearUserCaches(user);
|
this.clearUserCaches(user);
|
||||||
log.debug("Activated user: {}", user);
|
log.debug("Activated user: {}", user);
|
||||||
return user;
|
return user;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<User> completePasswordReset(String newPassword, String key) {
|
public Optional<User> completePasswordReset(String newPassword, String key) {
|
||||||
log.debug("Reset user password for reset key {}", key);
|
log.debug("Reset user password for reset key {}", key);
|
||||||
return userRepository.findOneByResetKey(key)
|
return userRepository.findOneByResetKey(key)
|
||||||
.filter(user -> user.getResetDate().isAfter(Instant.now().minusSeconds(86400)))
|
.filter(user -> user.getResetDate().isAfter(Instant.now().minusSeconds(86400)))
|
||||||
.map(user -> {
|
.map(user -> {
|
||||||
user.setPassword(passwordEncoder.encode(newPassword));
|
user.setPassword(passwordEncoder.encode(newPassword));
|
||||||
user.setResetKey(null);
|
user.setResetKey(null);
|
||||||
user.setResetDate(null);
|
user.setResetDate(null);
|
||||||
this.clearUserCaches(user);
|
this.clearUserCaches(user);
|
||||||
return user;
|
return user;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<User> requestPasswordReset(String mail) {
|
public Optional<User> requestPasswordReset(String mail) {
|
||||||
return userRepository.findOneByEmailIgnoreCase(mail)
|
return userRepository.findOneByEmailIgnoreCase(mail)
|
||||||
.filter(User::getActivated)
|
.filter(User::getActivated)
|
||||||
.map(user -> {
|
.map(user -> {
|
||||||
user.setResetKey(RandomUtil.generateResetKey());
|
user.setResetKey(RandomUtil.generateResetKey());
|
||||||
user.setResetDate(Instant.now());
|
user.setResetDate(Instant.now());
|
||||||
this.clearUserCaches(user);
|
this.clearUserCaches(user);
|
||||||
return user;
|
return user;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public User registerUser(UserDTO userDTO, String password) {
|
public User registerUser(UserDTO userDTO, String password) {
|
||||||
@ -123,9 +128,9 @@ public class UserService {
|
|||||||
return newUser;
|
return newUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean removeNonActivatedUser(User existingUser){
|
private boolean removeNonActivatedUser(User existingUser) {
|
||||||
if (existingUser.getActivated()) {
|
if (existingUser.getActivated()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
userRepository.delete(existingUser);
|
userRepository.delete(existingUser);
|
||||||
userRepository.flush();
|
userRepository.flush();
|
||||||
@ -151,11 +156,12 @@ public class UserService {
|
|||||||
user.setResetDate(Instant.now());
|
user.setResetDate(Instant.now());
|
||||||
user.setActivated(true);
|
user.setActivated(true);
|
||||||
if (userDTO.getAuthorities() != null) {
|
if (userDTO.getAuthorities() != null) {
|
||||||
Set<Authority> authorities = userDTO.getAuthorities().stream()
|
Set<Authority> authorities = userDTO.getAuthorities()
|
||||||
.map(authorityRepository::findById)
|
.stream()
|
||||||
.filter(Optional::isPresent)
|
.map(authorityRepository::findById)
|
||||||
.map(Optional::get)
|
.filter(Optional::isPresent)
|
||||||
.collect(Collectors.toSet());
|
.map(Optional::get)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
user.setAuthorities(authorities);
|
user.setAuthorities(authorities);
|
||||||
}
|
}
|
||||||
userRepository.save(user);
|
userRepository.save(user);
|
||||||
@ -175,16 +181,16 @@ public class UserService {
|
|||||||
*/
|
*/
|
||||||
public void updateUser(String firstName, String lastName, String email, String langKey, String imageUrl) {
|
public void updateUser(String firstName, String lastName, String email, String langKey, String imageUrl) {
|
||||||
SecurityUtils.getCurrentUserLogin()
|
SecurityUtils.getCurrentUserLogin()
|
||||||
.flatMap(userRepository::findOneByLogin)
|
.flatMap(userRepository::findOneByLogin)
|
||||||
.ifPresent(user -> {
|
.ifPresent(user -> {
|
||||||
user.setFirstName(firstName);
|
user.setFirstName(firstName);
|
||||||
user.setLastName(lastName);
|
user.setLastName(lastName);
|
||||||
user.setEmail(email.toLowerCase());
|
user.setEmail(email.toLowerCase());
|
||||||
user.setLangKey(langKey);
|
user.setLangKey(langKey);
|
||||||
user.setImageUrl(imageUrl);
|
user.setImageUrl(imageUrl);
|
||||||
this.clearUserCaches(user);
|
this.clearUserCaches(user);
|
||||||
log.debug("Changed Information for User: {}", user);
|
log.debug("Changed Information for User: {}", user);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -194,31 +200,33 @@ public class UserService {
|
|||||||
* @return updated user
|
* @return updated user
|
||||||
*/
|
*/
|
||||||
public Optional<UserDTO> updateUser(UserDTO userDTO) {
|
public Optional<UserDTO> updateUser(UserDTO userDTO) {
|
||||||
return Optional.of(userRepository
|
return Optional.of(
|
||||||
.findById(userDTO.getId()))
|
userRepository
|
||||||
.filter(Optional::isPresent)
|
.findById(userDTO.getId()))
|
||||||
.map(Optional::get)
|
.filter(Optional::isPresent)
|
||||||
.map(user -> {
|
.map(Optional::get)
|
||||||
this.clearUserCaches(user);
|
.map(user -> {
|
||||||
user.setLogin(userDTO.getLogin().toLowerCase());
|
this.clearUserCaches(user);
|
||||||
user.setFirstName(userDTO.getFirstName());
|
user.setLogin(userDTO.getLogin().toLowerCase());
|
||||||
user.setLastName(userDTO.getLastName());
|
user.setFirstName(userDTO.getFirstName());
|
||||||
user.setEmail(userDTO.getEmail().toLowerCase());
|
user.setLastName(userDTO.getLastName());
|
||||||
user.setImageUrl(userDTO.getImageUrl());
|
user.setEmail(userDTO.getEmail().toLowerCase());
|
||||||
user.setActivated(userDTO.isActivated());
|
user.setImageUrl(userDTO.getImageUrl());
|
||||||
user.setLangKey(userDTO.getLangKey());
|
user.setActivated(userDTO.isActivated());
|
||||||
Set<Authority> managedAuthorities = user.getAuthorities();
|
user.setLangKey(userDTO.getLangKey());
|
||||||
managedAuthorities.clear();
|
Set<Authority> managedAuthorities = user.getAuthorities();
|
||||||
userDTO.getAuthorities().stream()
|
managedAuthorities.clear();
|
||||||
.map(authorityRepository::findById)
|
userDTO.getAuthorities()
|
||||||
.filter(Optional::isPresent)
|
.stream()
|
||||||
.map(Optional::get)
|
.map(authorityRepository::findById)
|
||||||
.forEach(managedAuthorities::add);
|
.filter(Optional::isPresent)
|
||||||
this.clearUserCaches(user);
|
.map(Optional::get)
|
||||||
log.debug("Changed Information for User: {}", user);
|
.forEach(managedAuthorities::add);
|
||||||
return user;
|
this.clearUserCaches(user);
|
||||||
})
|
log.debug("Changed Information for User: {}", user);
|
||||||
.map(UserDTO::new);
|
return user;
|
||||||
|
})
|
||||||
|
.map(UserDTO::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteUser(String login) {
|
public void deleteUser(String login) {
|
||||||
@ -231,17 +239,17 @@ public class UserService {
|
|||||||
|
|
||||||
public void changePassword(String currentClearTextPassword, String newPassword) {
|
public void changePassword(String currentClearTextPassword, String newPassword) {
|
||||||
SecurityUtils.getCurrentUserLogin()
|
SecurityUtils.getCurrentUserLogin()
|
||||||
.flatMap(userRepository::findOneByLogin)
|
.flatMap(userRepository::findOneByLogin)
|
||||||
.ifPresent(user -> {
|
.ifPresent(user -> {
|
||||||
String currentEncryptedPassword = user.getPassword();
|
String currentEncryptedPassword = user.getPassword();
|
||||||
if (!passwordEncoder.matches(currentClearTextPassword, currentEncryptedPassword)) {
|
if (!passwordEncoder.matches(currentClearTextPassword, currentEncryptedPassword)) {
|
||||||
throw new InvalidPasswordException();
|
throw new InvalidPasswordException();
|
||||||
}
|
}
|
||||||
String encryptedPassword = passwordEncoder.encode(newPassword);
|
String encryptedPassword = passwordEncoder.encode(newPassword);
|
||||||
user.setPassword(encryptedPassword);
|
user.setPassword(encryptedPassword);
|
||||||
this.clearUserCaches(user);
|
this.clearUserCaches(user);
|
||||||
log.debug("Changed password for User: {}", user);
|
log.debug("Changed password for User: {}", user);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
@ -272,12 +280,12 @@ public class UserService {
|
|||||||
@Scheduled(cron = "0 0 1 * * ?")
|
@Scheduled(cron = "0 0 1 * * ?")
|
||||||
public void removeNotActivatedUsers() {
|
public void removeNotActivatedUsers() {
|
||||||
userRepository
|
userRepository
|
||||||
.findAllByActivatedIsFalseAndCreatedDateBefore(Instant.now().minus(3, ChronoUnit.DAYS))
|
.findAllByActivatedIsFalseAndCreatedDateBefore(Instant.now().minus(3, ChronoUnit.DAYS))
|
||||||
.forEach(user -> {
|
.forEach(user -> {
|
||||||
log.debug("Deleting not activated user {}", user.getLogin());
|
log.debug("Deleting not activated user {}", user.getLogin());
|
||||||
userRepository.delete(user);
|
userRepository.delete(user);
|
||||||
this.clearUserCaches(user);
|
this.clearUserCaches(user);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.accessfilter;
|
package org.hostsharing.hsadminng.service.accessfilter;
|
||||||
|
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
@Documented
|
@Documented
|
||||||
@Target({ElementType.FIELD, ElementType.TYPE_USE})
|
@Target({ ElementType.FIELD, ElementType.TYPE_USE })
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface AccessFor {
|
public @interface AccessFor {
|
||||||
|
|
||||||
Role[] init() default Role.NOBODY;
|
Role[] init() default Role.NOBODY;
|
||||||
|
|
||||||
Role[] update() default Role.NOBODY;
|
Role[] update() default Role.NOBODY;
|
||||||
|
|
||||||
Role[] read() default Role.NOBODY;
|
Role[] read() default Role.NOBODY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.accessfilter;
|
package org.hostsharing.hsadminng.service.accessfilter;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A marker interface for DTO classes which can be used by {@link JsonSerializerWithAccessFilter} and {@link JsonDeserializerWithAccessFilter}.
|
* A marker interface for DTO classes which can be used by {@link JsonSerializerWithAccessFilter} and
|
||||||
|
* {@link JsonDeserializerWithAccessFilter}.
|
||||||
*/
|
*/
|
||||||
public interface AccessMappings extends Serializable {
|
public interface AccessMappings extends Serializable {
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,22 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.accessfilter;
|
package org.hostsharing.hsadminng.service.accessfilter;
|
||||||
|
|
||||||
|
import static com.google.common.base.Verify.verify;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.security.SecurityUtils;
|
import org.hostsharing.hsadminng.security.SecurityUtils;
|
||||||
import org.hostsharing.hsadminng.service.IdToDtoResolver;
|
import org.hostsharing.hsadminng.service.IdToDtoResolver;
|
||||||
import org.hostsharing.hsadminng.service.dto.MembershipDTO;
|
import org.hostsharing.hsadminng.service.dto.MembershipDTO;
|
||||||
import org.hostsharing.hsadminng.service.util.ReflectionUtil;
|
import org.hostsharing.hsadminng.service.util.ReflectionUtil;
|
||||||
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
||||||
|
|
||||||
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import static com.google.common.base.Verify.verify;
|
|
||||||
|
|
||||||
abstract class JSonAccessFilter<T> {
|
abstract class JSonAccessFilter<T> {
|
||||||
|
|
||||||
private final ApplicationContext ctx;
|
private final ApplicationContext ctx;
|
||||||
final T dto;
|
final T dto;
|
||||||
final Field selfIdField;
|
final Field selfIdField;
|
||||||
@ -67,7 +70,7 @@ abstract class JSonAccessFilter<T> {
|
|||||||
final Class<? extends IdToDtoResolver> parentDtoLoader = parentIdAnnot.resolver();
|
final Class<? extends IdToDtoResolver> parentDtoLoader = parentIdAnnot.resolver();
|
||||||
final Class<IdToDtoResolver> rawType = IdToDtoResolver.class;
|
final Class<IdToDtoResolver> rawType = IdToDtoResolver.class;
|
||||||
|
|
||||||
final Class<?> parentDtoClass = ReflectionUtil.<T>determineGenericInterfaceParameter(parentDtoLoader, rawType, 0);
|
final Class<?> parentDtoClass = ReflectionUtil.<T> determineGenericInterfaceParameter(parentDtoLoader, rawType, 0);
|
||||||
final Long parentId = ReflectionUtil.getValue(dto, parentIdField);
|
final Long parentId = ReflectionUtil.getValue(dto, parentIdField);
|
||||||
final Role roleOnParent = SecurityUtils.getLoginUserRoleFor(parentDtoClass, parentId);
|
final Role roleOnParent = SecurityUtils.getLoginUserRoleFor(parentDtoClass, parentId);
|
||||||
|
|
||||||
@ -77,23 +80,37 @@ abstract class JSonAccessFilter<T> {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected Object loadDto(final Class<? extends IdToDtoResolver> resolverClass, final Long id) {
|
protected Object loadDto(final Class<? extends IdToDtoResolver> resolverClass, final Long id) {
|
||||||
verify(id != null, "id must not be null for " + resolverClass.getSimpleName());
|
verify(id != null, "id must not be null for " + resolverClass.getSimpleName());
|
||||||
|
|
||||||
final AutowireCapableBeanFactory beanFactory = ctx.getAutowireCapableBeanFactory();
|
final AutowireCapableBeanFactory beanFactory = ctx.getAutowireCapableBeanFactory();
|
||||||
verify(beanFactory != null, "no bean factory found, probably missing mock configuration for ApplicationContext, e.g. given(...)");
|
verify(
|
||||||
|
beanFactory != null,
|
||||||
|
"no bean factory found, probably missing mock configuration for ApplicationContext, e.g. given(...)");
|
||||||
|
|
||||||
final IdToDtoResolver<MembershipDTO> resolverBean = beanFactory.createBean(resolverClass);
|
final IdToDtoResolver<MembershipDTO> resolverBean = beanFactory.createBean(resolverClass);
|
||||||
verify(resolverBean != null, "no " + resolverClass.getSimpleName() + " bean created, probably missing mock configuration for AutowireCapableBeanFactory, e.g. given(...)");
|
verify(
|
||||||
|
resolverBean != null,
|
||||||
|
"no " + resolverClass.getSimpleName()
|
||||||
|
+ " bean created, probably missing mock configuration for AutowireCapableBeanFactory, e.g. given(...)");
|
||||||
|
|
||||||
return resolverBean.findOne(id).orElseThrow(() -> new BadRequestAlertException("Can't resolve entity ID " + id + " via " + resolverClass, resolverClass.getSimpleName(), "isNotFound"));
|
return resolverBean.findOne(id)
|
||||||
|
.orElseThrow(
|
||||||
|
() -> new BadRequestAlertException(
|
||||||
|
"Can't resolve entity ID " + id + " via " + resolverClass,
|
||||||
|
resolverClass.getSimpleName(),
|
||||||
|
"isNotFound"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Field determineFieldWithAnnotation(final Class<?> dtoClass, final Class<? extends Annotation> idAnnotationClass) {
|
private static Field determineFieldWithAnnotation(
|
||||||
|
final Class<?> dtoClass,
|
||||||
|
final Class<? extends Annotation> idAnnotationClass) {
|
||||||
Field parentIdField = null;
|
Field parentIdField = null;
|
||||||
for (Field field : dtoClass.getDeclaredFields()) {
|
for (Field field : dtoClass.getDeclaredFields()) {
|
||||||
if (field.isAnnotationPresent(idAnnotationClass)) {
|
if (field.isAnnotationPresent(idAnnotationClass)) {
|
||||||
if (parentIdField != null) {
|
if (parentIdField != null) {
|
||||||
throw new AssertionError("multiple @" + idAnnotationClass.getSimpleName() + " detected in " + field.getDeclaringClass().getSimpleName());
|
throw new AssertionError(
|
||||||
|
"multiple @" + idAnnotationClass.getSimpleName() + " detected in "
|
||||||
|
+ field.getDeclaringClass().getSimpleName());
|
||||||
}
|
}
|
||||||
parentIdField = field;
|
parentIdField = field;
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.accessfilter;
|
package org.hostsharing.hsadminng.service.accessfilter;
|
||||||
|
|
||||||
|
import static org.hostsharing.hsadminng.service.util.ReflectionUtil.unchecked;
|
||||||
|
|
||||||
|
import org.hostsharing.hsadminng.service.util.ReflectionUtil;
|
||||||
|
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonParser;
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
import com.fasterxml.jackson.core.TreeNode;
|
import com.fasterxml.jackson.core.TreeNode;
|
||||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
import com.fasterxml.jackson.databind.node.*;
|
import com.fasterxml.jackson.databind.node.*;
|
||||||
|
|
||||||
import org.apache.commons.lang3.NotImplementedException;
|
import org.apache.commons.lang3.NotImplementedException;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.hostsharing.hsadminng.service.util.ReflectionUtil;
|
|
||||||
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@ -16,9 +21,8 @@ import java.time.LocalDate;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.hostsharing.hsadminng.service.util.ReflectionUtil.unchecked;
|
/**
|
||||||
|
* Actual implementation of JSON deserialization, where {link JSonDeserializerWithAccessFilter}
|
||||||
/** Actual implementation of JSON deserialization, where {link JSonDeserializerWithAccessFilter}
|
|
||||||
* is a stateless bean, {@link JSonDeserializationWithAccessFilter} exists only during the actual
|
* is a stateless bean, {@link JSonDeserializationWithAccessFilter} exists only during the actual
|
||||||
* deserialization and contains a deserialization state.
|
* deserialization and contains a deserialization state.
|
||||||
*
|
*
|
||||||
@ -29,7 +33,11 @@ public class JSonDeserializationWithAccessFilter<T> extends JSonAccessFilter<T>
|
|||||||
private final TreeNode treeNode;
|
private final TreeNode treeNode;
|
||||||
private final Set<Field> updatingFields = new HashSet<>();
|
private final Set<Field> updatingFields = new HashSet<>();
|
||||||
|
|
||||||
public JSonDeserializationWithAccessFilter(final ApplicationContext ctx, final JsonParser jsonParser, final DeserializationContext deserializationContext, Class<T> dtoClass) {
|
public JSonDeserializationWithAccessFilter(
|
||||||
|
final ApplicationContext ctx,
|
||||||
|
final JsonParser jsonParser,
|
||||||
|
final DeserializationContext deserializationContext,
|
||||||
|
Class<T> dtoClass) {
|
||||||
super(ctx, unchecked(dtoClass::newInstance));
|
super(ctx, unchecked(dtoClass::newInstance));
|
||||||
this.treeNode = unchecked(() -> jsonParser.getCodec().readTree(jsonParser));
|
this.treeNode = unchecked(() -> jsonParser.getCodec().readTree(jsonParser));
|
||||||
}
|
}
|
||||||
@ -68,9 +76,9 @@ public class JSonDeserializationWithAccessFilter<T> extends JSonAccessFilter<T>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Field field : currentDto.getClass().getDeclaredFields()) {
|
for (Field field : currentDto.getClass().getDeclaredFields()) {
|
||||||
if (field.isAnnotationPresent(AccessFor.class) ) {
|
if (field.isAnnotationPresent(AccessFor.class)) {
|
||||||
boolean updatingField = updatingFields.contains(field);
|
boolean updatingField = updatingFields.contains(field);
|
||||||
if (updatingField && !isActuallyUpdated(field, dto, currentDto) ) {
|
if (updatingField && !isActuallyUpdated(field, dto, currentDto)) {
|
||||||
updatingFields.remove(field);
|
updatingFields.remove(field);
|
||||||
updatingField = false;
|
updatingField = false;
|
||||||
}
|
}
|
||||||
@ -106,9 +114,13 @@ public class JSonDeserializationWithAccessFilter<T> extends JSonAccessFilter<T>
|
|||||||
return ((DoubleNode) fieldNode).asDouble();
|
return ((DoubleNode) fieldNode).asDouble();
|
||||||
}
|
}
|
||||||
if (fieldNode instanceof ArrayNode && LocalDate.class.isAssignableFrom(fieldClass)) {
|
if (fieldNode instanceof ArrayNode && LocalDate.class.isAssignableFrom(fieldClass)) {
|
||||||
return LocalDate.of(((ArrayNode) fieldNode).get(0).asInt(), ((ArrayNode) fieldNode).get(1).asInt(), ((ArrayNode) fieldNode).get(2).asInt());
|
return LocalDate.of(
|
||||||
|
((ArrayNode) fieldNode).get(0).asInt(),
|
||||||
|
((ArrayNode) fieldNode).get(1).asInt(),
|
||||||
|
((ArrayNode) fieldNode).get(2).asInt());
|
||||||
}
|
}
|
||||||
throw new NotImplementedException("JSon node type not implemented: " + fieldNode.getClass() + " -> " + fieldName + ": " + fieldClass);
|
throw new NotImplementedException(
|
||||||
|
"JSon node type not implemented: " + fieldNode.getClass() + " -> " + fieldName + ": " + fieldClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeValueToDto(final T dto, final Field field, final Object value) {
|
private void writeValueToDto(final T dto, final Field field, final Object value) {
|
||||||
@ -135,23 +147,35 @@ public class JSonDeserializationWithAccessFilter<T> extends JSonAccessFilter<T>
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkAccessToWrittenFields(final T currentDto) {
|
private void checkAccessToWrittenFields(final T currentDto) {
|
||||||
updatingFields.forEach(field -> {
|
updatingFields.forEach(
|
||||||
// TODO this ugly code needs cleanup
|
field -> {
|
||||||
if (!field.equals(selfIdField)) {
|
// TODO this ugly code needs cleanup
|
||||||
final Role role = getLoginUserRole();
|
if (!field.equals(selfIdField)) {
|
||||||
if (isInitAccess()) {
|
final Role role = getLoginUserRole();
|
||||||
if (!role.isAllowedToInit(field)) {
|
if (isInitAccess()) {
|
||||||
if (!field.equals(parentIdField)) {
|
if (!role.isAllowedToInit(field)) {
|
||||||
throw new BadRequestAlertException("Initialization of field " + toDisplay(field) + " prohibited for current user role " + role, toDisplay(field), "initializationProhibited");
|
if (!field.equals(parentIdField)) {
|
||||||
} else {
|
throw new BadRequestAlertException(
|
||||||
throw new BadRequestAlertException("Referencing field " + toDisplay(field) + " prohibited for current user role " + role, toDisplay(field), "referencingProhibited");
|
"Initialization of field " + toDisplay(field) + " prohibited for current user role "
|
||||||
|
+ role,
|
||||||
|
toDisplay(field),
|
||||||
|
"initializationProhibited");
|
||||||
|
} else {
|
||||||
|
throw new BadRequestAlertException(
|
||||||
|
"Referencing field " + toDisplay(field) + " prohibited for current user role "
|
||||||
|
+ role,
|
||||||
|
toDisplay(field),
|
||||||
|
"referencingProhibited");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (!Role.toBeIgnoredForUpdates(field) && !getLoginUserRole().isAllowedToUpdate(field)) {
|
||||||
|
throw new BadRequestAlertException(
|
||||||
|
"Update of field " + toDisplay(field) + " prohibited for current user role " + role,
|
||||||
|
toDisplay(field),
|
||||||
|
"updateProhibited");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ( !Role.toBeIgnoredForUpdates(field) && !getLoginUserRole().isAllowedToUpdate(field)) {
|
});
|
||||||
throw new BadRequestAlertException("Update of field " + toDisplay(field) + " prohibited for current user role " + role, toDisplay(field), "updateProhibited");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInitAccess() {
|
private boolean isInitAccess() {
|
||||||
@ -159,6 +183,6 @@ public class JSonDeserializationWithAccessFilter<T> extends JSonAccessFilter<T>
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isActuallyUpdated(final Field field, final T dto, T currentDto) {
|
private boolean isActuallyUpdated(final Field field, final T dto, T currentDto) {
|
||||||
return 0 != ObjectUtils.compare(ReflectionUtil.getValue(dto, field), ReflectionUtil.getValue(currentDto, field));
|
return 0 != ObjectUtils.compare(ReflectionUtil.getValue(dto, field), ReflectionUtil.getValue(currentDto, field));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.accessfilter;
|
package org.hostsharing.hsadminng.service.accessfilter;
|
||||||
|
|
||||||
|
import org.hostsharing.hsadminng.service.util.ReflectionUtil;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||||
|
|
||||||
import org.apache.commons.lang3.NotImplementedException;
|
import org.apache.commons.lang3.NotImplementedException;
|
||||||
import org.hostsharing.hsadminng.service.util.ReflectionUtil;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -12,20 +14,23 @@ import java.lang.reflect.Field;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
||||||
/** Actual implementation of JSON serialization, where {link JsonSerializerWithAccessFilter}
|
/**
|
||||||
|
* Actual implementation of JSON serialization, where {link JsonSerializerWithAccessFilter}
|
||||||
* is a stateless bean, {@link JSonSerializationWithAccessFilter} exists only during the actual
|
* is a stateless bean, {@link JSonSerializationWithAccessFilter} exists only during the actual
|
||||||
* serialization and contains a serialization state.
|
* serialization and contains a serialization state.
|
||||||
*
|
*
|
||||||
* @param <T> DTO class to serialize
|
* @param <T> DTO class to serialize
|
||||||
*/
|
*/
|
||||||
public class JSonSerializationWithAccessFilter<T> extends JSonAccessFilter<T> {
|
public class JSonSerializationWithAccessFilter<T> extends JSonAccessFilter<T> {
|
||||||
|
|
||||||
private final JsonGenerator jsonGenerator;
|
private final JsonGenerator jsonGenerator;
|
||||||
private final SerializerProvider serializerProvider;
|
private final SerializerProvider serializerProvider;
|
||||||
|
|
||||||
public JSonSerializationWithAccessFilter(final ApplicationContext ctx,
|
public JSonSerializationWithAccessFilter(
|
||||||
final JsonGenerator jsonGenerator,
|
final ApplicationContext ctx,
|
||||||
final SerializerProvider serializerProvider,
|
final JsonGenerator jsonGenerator,
|
||||||
final T dto) {
|
final SerializerProvider serializerProvider,
|
||||||
|
final T dto) {
|
||||||
super(ctx, dto);
|
super(ctx, dto);
|
||||||
this.jsonGenerator = jsonGenerator;
|
this.jsonGenerator = jsonGenerator;
|
||||||
this.serializerProvider = serializerProvider;
|
this.serializerProvider = serializerProvider;
|
||||||
@ -45,10 +50,10 @@ public class JSonSerializationWithAccessFilter<T> extends JSonAccessFilter<T> {
|
|||||||
if (getLoginUserRole().isAllowedToRead(field)) {
|
if (getLoginUserRole().isAllowedToRead(field)) {
|
||||||
final String fieldName = field.getName();
|
final String fieldName = field.getName();
|
||||||
// TODO: maybe replace by serializerProvider.defaultSerialize...()?
|
// TODO: maybe replace by serializerProvider.defaultSerialize...()?
|
||||||
// But that makes it difficult for parallel structure with the deserializer (clumsy API).
|
// But that makes it difficult for parallel structure with the deserializer (clumsy API).
|
||||||
// Alternatively extract the supported types to subclasses of some abstract class and
|
// Alternatively extract the supported types to subclasses of some abstract class and
|
||||||
// here as well as in the deserializer just access the matching implementation through a map.
|
// here as well as in the deserializer just access the matching implementation through a map.
|
||||||
// Or even completely switch from Jackson to GSON?
|
// Or even completely switch from Jackson to GSON?
|
||||||
final Object fieldValue = ReflectionUtil.getValue(dto, field);
|
final Object fieldValue = ReflectionUtil.getValue(dto, field);
|
||||||
if (fieldValue == null) {
|
if (fieldValue == null) {
|
||||||
jsonGenerator.writeNullField(fieldName);
|
jsonGenerator.writeNullField(fieldName);
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.accessfilter;
|
package org.hostsharing.hsadminng.service.accessfilter;
|
||||||
|
|
||||||
|
import org.hostsharing.hsadminng.service.util.ReflectionUtil;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonParser;
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
import com.fasterxml.jackson.databind.JsonDeserializer;
|
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||||
import org.hostsharing.hsadminng.service.util.ReflectionUtil;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
public abstract class JsonDeserializerWithAccessFilter<T extends AccessMappings> extends JsonDeserializer<T> {
|
public abstract class JsonDeserializerWithAccessFilter<T extends AccessMappings> extends JsonDeserializer<T> {
|
||||||
@ -15,10 +18,12 @@ public abstract class JsonDeserializerWithAccessFilter<T extends AccessMappings>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T deserialize(final JsonParser jsonParser,
|
public T deserialize(
|
||||||
final DeserializationContext deserializationContext) {
|
final JsonParser jsonParser,
|
||||||
|
final DeserializationContext deserializationContext) {
|
||||||
|
|
||||||
final Class<T> dtoClass = ReflectionUtil.determineGenericClassParameter(this.getClass(), JsonDeserializerWithAccessFilter.class, 0);
|
final Class<T> dtoClass = ReflectionUtil
|
||||||
|
.determineGenericClassParameter(this.getClass(), JsonDeserializerWithAccessFilter.class, 0);
|
||||||
return new JSonDeserializationWithAccessFilter<>(ctx, jsonParser, deserializationContext, dtoClass).deserialize();
|
return new JSonDeserializationWithAccessFilter<>(ctx, jsonParser, deserializationContext, dtoClass).deserialize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.accessfilter;
|
package org.hostsharing.hsadminng.service.accessfilter;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||||
|
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/** A base class for a Spring bean for JSON serialization with field-based access filters.
|
/**
|
||||||
|
* A base class for a Spring bean for JSON serialization with field-based access filters.
|
||||||
* Where {@link JSonSerializationWithAccessFilter} is the actual stateful implementation and
|
* Where {@link JSonSerializationWithAccessFilter} is the actual stateful implementation and
|
||||||
* it's instances only exist during the process of serialization, this class is a stateless just
|
* it's instances only exist during the process of serialization, this class is a stateless just
|
||||||
* used for service and context injection.
|
* used for service and context injection.
|
||||||
@ -23,8 +26,10 @@ public abstract class JsonSerializerWithAccessFilter<T extends AccessMappings> e
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(final T dto, final JsonGenerator jsonGenerator,
|
public void serialize(
|
||||||
final SerializerProvider serializerProvider) throws IOException {
|
final T dto,
|
||||||
|
final JsonGenerator jsonGenerator,
|
||||||
|
final SerializerProvider serializerProvider) throws IOException {
|
||||||
|
|
||||||
new JSonSerializationWithAccessFilter<>(ctx, jsonGenerator, serializerProvider, dto).serialize();
|
new JSonSerializationWithAccessFilter<>(ctx, jsonGenerator, serializerProvider, dto).serialize();
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.accessfilter;
|
package org.hostsharing.hsadminng.service.accessfilter;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.service.IdToDtoResolver;
|
import org.hostsharing.hsadminng.service.IdToDtoResolver;
|
||||||
@ -11,9 +12,10 @@ import java.lang.annotation.*;
|
|||||||
* @see AccessFor
|
* @see AccessFor
|
||||||
*/
|
*/
|
||||||
@Documented
|
@Documented
|
||||||
@Target({ElementType.FIELD})
|
@Target({ ElementType.FIELD })
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface ParentId {
|
public @interface ParentId {
|
||||||
|
|
||||||
/// The service which can load the referenced DTO.
|
/// The service which can load the referenced DTO.
|
||||||
Class<? extends IdToDtoResolver<?>> resolver();
|
Class<? extends IdToDtoResolver<?>> resolver();
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.accessfilter;
|
package org.hostsharing.hsadminng.service.accessfilter;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
import static com.google.common.base.Verify.verify;
|
import static com.google.common.base.Verify.verify;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These enum values are on the one hand used to define the minimum role required to grant access to resources,
|
* These enum values are on the one hand used to define the minimum role required to grant access to resources,
|
||||||
* but on the other hand also for the roles users can be assigned to.
|
* but on the other hand also for the roles users can be assigned to.
|
||||||
@ -46,6 +47,7 @@ public enum Role {
|
|||||||
* This role is for financial contacts of a customer, e.g. for accessing billing data.
|
* This role is for financial contacts of a customer, e.g. for accessing billing data.
|
||||||
*/
|
*/
|
||||||
FINANCIAL_CONTACT(22) {
|
FINANCIAL_CONTACT(22) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean covers(final Role role) {
|
public boolean covers(final Role role) {
|
||||||
if (role == ACTUAL_CUSTOMER_USER) {
|
if (role == ACTUAL_CUSTOMER_USER) {
|
||||||
@ -60,7 +62,6 @@ public enum Role {
|
|||||||
*/
|
*/
|
||||||
TECHNICAL_CONTACT(22),
|
TECHNICAL_CONTACT(22),
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This meta-role is to specify that any kind of customer contact can get access to the resource.
|
* This meta-role is to specify that any kind of customer contact can get access to the resource.
|
||||||
*/
|
*/
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.accessfilter;
|
package org.hostsharing.hsadminng.service.accessfilter;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.service.IdToDtoResolver;
|
import org.hostsharing.hsadminng.service.IdToDtoResolver;
|
||||||
@ -13,9 +14,10 @@ import java.lang.annotation.*;
|
|||||||
* @see AccessFor
|
* @see AccessFor
|
||||||
*/
|
*/
|
||||||
@Documented
|
@Documented
|
||||||
@Target({ElementType.FIELD})
|
@Target({ ElementType.FIELD })
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface SelfId {
|
public @interface SelfId {
|
||||||
|
|
||||||
/// The service which can load the referenced DTO.
|
/// The service which can load the referenced DTO.
|
||||||
Class<? extends IdToDtoResolver<?>> resolver();
|
Class<? extends IdToDtoResolver<?>> resolver();
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.dto;
|
package org.hostsharing.hsadminng.service.dto;
|
||||||
|
|
||||||
|
import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
|
||||||
|
|
||||||
|
import io.github.jhipster.service.filter.BigDecimalFilter;
|
||||||
|
import io.github.jhipster.service.filter.Filter;
|
||||||
|
import io.github.jhipster.service.filter.LocalDateFilter;
|
||||||
|
import io.github.jhipster.service.filter.LongFilter;
|
||||||
|
import io.github.jhipster.service.filter.StringFilter;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
|
|
||||||
import io.github.jhipster.service.filter.BooleanFilter;
|
|
||||||
import io.github.jhipster.service.filter.DoubleFilter;
|
|
||||||
import io.github.jhipster.service.filter.Filter;
|
|
||||||
import io.github.jhipster.service.filter.FloatFilter;
|
|
||||||
import io.github.jhipster.service.filter.IntegerFilter;
|
|
||||||
import io.github.jhipster.service.filter.LongFilter;
|
|
||||||
import io.github.jhipster.service.filter.StringFilter;
|
|
||||||
import io.github.jhipster.service.filter.BigDecimalFilter;
|
|
||||||
import io.github.jhipster.service.filter.LocalDateFilter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Criteria class for the Asset entity. This class is used in AssetResource to
|
* Criteria class for the Asset entity. This class is used in AssetResource to
|
||||||
@ -22,6 +21,7 @@ import io.github.jhipster.service.filter.LocalDateFilter;
|
|||||||
* fix type specific filters.
|
* fix type specific filters.
|
||||||
*/
|
*/
|
||||||
public class AssetCriteria implements Serializable {
|
public class AssetCriteria implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for filtering AssetAction
|
* Class for filtering AssetAction
|
||||||
*/
|
*/
|
||||||
@ -100,7 +100,6 @@ public class AssetCriteria implements Serializable {
|
|||||||
this.membershipId = membershipId;
|
this.membershipId = membershipId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
if (this == o) {
|
||||||
@ -110,27 +109,25 @@ public class AssetCriteria implements Serializable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final AssetCriteria that = (AssetCriteria) o;
|
final AssetCriteria that = (AssetCriteria) o;
|
||||||
return
|
return Objects.equals(id, that.id) &&
|
||||||
Objects.equals(id, that.id) &&
|
Objects.equals(documentDate, that.documentDate) &&
|
||||||
Objects.equals(documentDate, that.documentDate) &&
|
Objects.equals(valueDate, that.valueDate) &&
|
||||||
Objects.equals(valueDate, that.valueDate) &&
|
Objects.equals(action, that.action) &&
|
||||||
Objects.equals(action, that.action) &&
|
Objects.equals(amount, that.amount) &&
|
||||||
Objects.equals(amount, that.amount) &&
|
Objects.equals(remark, that.remark) &&
|
||||||
Objects.equals(remark, that.remark) &&
|
Objects.equals(membershipId, that.membershipId);
|
||||||
Objects.equals(membershipId, that.membershipId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(
|
return Objects.hash(
|
||||||
id,
|
id,
|
||||||
documentDate,
|
documentDate,
|
||||||
valueDate,
|
valueDate,
|
||||||
action,
|
action,
|
||||||
amount,
|
amount,
|
||||||
remark,
|
remark,
|
||||||
membershipId
|
membershipId);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -143,7 +140,7 @@ public class AssetCriteria implements Serializable {
|
|||||||
(amount != null ? "amount=" + amount + ", " : "") +
|
(amount != null ? "amount=" + amount + ", " : "") +
|
||||||
(remark != null ? "remark=" + remark + ", " : "") +
|
(remark != null ? "remark=" + remark + ", " : "") +
|
||||||
(membershipId != null ? "membershipId=" + membershipId + ", " : "") +
|
(membershipId != null ? "membershipId=" + membershipId + ", " : "") +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,42 +1,45 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.dto;
|
package org.hostsharing.hsadminng.service.dto;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
|
import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
|
||||||
import org.hostsharing.hsadminng.service.AssetService;
|
import org.hostsharing.hsadminng.service.AssetService;
|
||||||
import org.hostsharing.hsadminng.service.MembershipService;
|
import org.hostsharing.hsadminng.service.MembershipService;
|
||||||
import org.hostsharing.hsadminng.service.accessfilter.*;
|
import org.hostsharing.hsadminng.service.accessfilter.*;
|
||||||
|
|
||||||
import org.springframework.boot.jackson.JsonComponent;
|
import org.springframework.boot.jackson.JsonComponent;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import javax.validation.constraints.Size;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A DTO for the Asset entity.
|
* A DTO for the Asset entity.
|
||||||
*/
|
*/
|
||||||
public class AssetDTO implements Serializable, AccessMappings {
|
public class AssetDTO implements Serializable, AccessMappings {
|
||||||
|
|
||||||
@SelfId(resolver = AssetService.class)
|
@SelfId(resolver = AssetService.class)
|
||||||
@AccessFor(read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private LocalDate documentDate;
|
private LocalDate documentDate;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private LocalDate valueDate;
|
private LocalDate valueDate;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private AssetAction action;
|
private AssetAction action;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private BigDecimal amount;
|
private BigDecimal amount;
|
||||||
|
|
||||||
@Size(max = 160)
|
@Size(max = 160)
|
||||||
@ -44,10 +47,10 @@ public class AssetDTO implements Serializable, AccessMappings {
|
|||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
@ParentId(resolver = MembershipService.class)
|
@ParentId(resolver = MembershipService.class)
|
||||||
@AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private Long membershipId;
|
private Long membershipId;
|
||||||
|
|
||||||
@AccessFor(update = Role.IGNORED, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(update = Role.IGNORED, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private String membershipDisplayLabel;
|
private String membershipDisplayLabel;
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
@ -138,15 +141,15 @@ public class AssetDTO implements Serializable, AccessMappings {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "AssetDTO{" +
|
return "AssetDTO{" +
|
||||||
"id=" + getId() +
|
"id=" + getId() +
|
||||||
", documentDate='" + getDocumentDate() + "'" +
|
", documentDate='" + getDocumentDate() + "'" +
|
||||||
", valueDate='" + getValueDate() + "'" +
|
", valueDate='" + getValueDate() + "'" +
|
||||||
", action='" + getAction() + "'" +
|
", action='" + getAction() + "'" +
|
||||||
", amount=" + getAmount() +
|
", amount=" + getAmount() +
|
||||||
", remark='" + getRemark() + "'" +
|
", remark='" + getRemark() + "'" +
|
||||||
", membership=" + getMembershipId() +
|
", membership=" + getMembershipId() +
|
||||||
", membershipDisplayLabel='" + getMembershipDisplayLabel() + "'" +
|
", membershipDisplayLabel='" + getMembershipDisplayLabel() + "'" +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonComponent
|
@JsonComponent
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.dto;
|
package org.hostsharing.hsadminng.service.dto;
|
||||||
|
|
||||||
import io.github.jhipster.service.filter.*;
|
|
||||||
import org.hostsharing.hsadminng.domain.enumeration.CustomerKind;
|
import org.hostsharing.hsadminng.domain.enumeration.CustomerKind;
|
||||||
import org.hostsharing.hsadminng.domain.enumeration.VatRegion;
|
import org.hostsharing.hsadminng.domain.enumeration.VatRegion;
|
||||||
|
|
||||||
|
import io.github.jhipster.service.filter.*;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@ -16,11 +18,13 @@ import java.util.Objects;
|
|||||||
* fix type specific filters.
|
* fix type specific filters.
|
||||||
*/
|
*/
|
||||||
public class CustomerCriteria implements Serializable {
|
public class CustomerCriteria implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for filtering CustomerKind
|
* Class for filtering CustomerKind
|
||||||
*/
|
*/
|
||||||
public static class CustomerKindFilter extends Filter<CustomerKind> {
|
public static class CustomerKindFilter extends Filter<CustomerKind> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for filtering VatRegion
|
* Class for filtering VatRegion
|
||||||
*/
|
*/
|
||||||
@ -209,7 +213,6 @@ public class CustomerCriteria implements Serializable {
|
|||||||
this.sepamandateId = sepamandateId;
|
this.sepamandateId = sepamandateId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
if (this == o) {
|
||||||
@ -219,49 +222,47 @@ public class CustomerCriteria implements Serializable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final CustomerCriteria that = (CustomerCriteria) o;
|
final CustomerCriteria that = (CustomerCriteria) o;
|
||||||
return
|
return Objects.equals(id, that.id) &&
|
||||||
Objects.equals(id, that.id) &&
|
Objects.equals(reference, that.reference) &&
|
||||||
Objects.equals(reference, that.reference) &&
|
Objects.equals(prefix, that.prefix) &&
|
||||||
Objects.equals(prefix, that.prefix) &&
|
Objects.equals(name, that.name) &&
|
||||||
Objects.equals(name, that.name) &&
|
Objects.equals(kind, that.kind) &&
|
||||||
Objects.equals(kind, that.kind) &&
|
Objects.equals(birthDate, that.birthDate) &&
|
||||||
Objects.equals(birthDate, that.birthDate) &&
|
Objects.equals(birthPlace, that.birthPlace) &&
|
||||||
Objects.equals(birthPlace, that.birthPlace) &&
|
Objects.equals(registrationCourt, that.registrationCourt) &&
|
||||||
Objects.equals(registrationCourt, that.registrationCourt) &&
|
Objects.equals(registrationNumber, that.registrationNumber) &&
|
||||||
Objects.equals(registrationNumber, that.registrationNumber) &&
|
Objects.equals(vatRegion, that.vatRegion) &&
|
||||||
Objects.equals(vatRegion, that.vatRegion) &&
|
Objects.equals(vatNumber, that.vatNumber) &&
|
||||||
Objects.equals(vatNumber, that.vatNumber) &&
|
Objects.equals(contractualSalutation, that.contractualSalutation) &&
|
||||||
Objects.equals(contractualSalutation, that.contractualSalutation) &&
|
Objects.equals(contractualAddress, that.contractualAddress) &&
|
||||||
Objects.equals(contractualAddress, that.contractualAddress) &&
|
Objects.equals(billingSalutation, that.billingSalutation) &&
|
||||||
Objects.equals(billingSalutation, that.billingSalutation) &&
|
Objects.equals(billingAddress, that.billingAddress) &&
|
||||||
Objects.equals(billingAddress, that.billingAddress) &&
|
Objects.equals(remark, that.remark) &&
|
||||||
Objects.equals(remark, that.remark) &&
|
Objects.equals(membershipId, that.membershipId) &&
|
||||||
Objects.equals(membershipId, that.membershipId) &&
|
Objects.equals(sepamandateId, that.sepamandateId);
|
||||||
Objects.equals(sepamandateId, that.sepamandateId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(
|
return Objects.hash(
|
||||||
id,
|
id,
|
||||||
reference,
|
reference,
|
||||||
prefix,
|
prefix,
|
||||||
name,
|
name,
|
||||||
kind,
|
kind,
|
||||||
birthDate,
|
birthDate,
|
||||||
birthPlace,
|
birthPlace,
|
||||||
registrationCourt,
|
registrationCourt,
|
||||||
registrationNumber,
|
registrationNumber,
|
||||||
vatRegion,
|
vatRegion,
|
||||||
vatNumber,
|
vatNumber,
|
||||||
contractualSalutation,
|
contractualSalutation,
|
||||||
contractualAddress,
|
contractualAddress,
|
||||||
billingSalutation,
|
billingSalutation,
|
||||||
billingAddress,
|
billingAddress,
|
||||||
remark,
|
remark,
|
||||||
membershipId,
|
membershipId,
|
||||||
sepamandateId
|
sepamandateId);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -285,7 +286,7 @@ public class CustomerCriteria implements Serializable {
|
|||||||
(remark != null ? "remark=" + remark + ", " : "") +
|
(remark != null ? "remark=" + remark + ", " : "") +
|
||||||
(membershipId != null ? "membershipId=" + membershipId + ", " : "") +
|
(membershipId != null ? "membershipId=" + membershipId + ", " : "") +
|
||||||
(sepamandateId != null ? "sepamandateId=" + sepamandateId + ", " : "") +
|
(sepamandateId != null ? "sepamandateId=" + sepamandateId + ", " : "") +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,23 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.dto;
|
package org.hostsharing.hsadminng.service.dto;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.enumeration.CustomerKind;
|
import org.hostsharing.hsadminng.domain.enumeration.CustomerKind;
|
||||||
import org.hostsharing.hsadminng.domain.enumeration.VatRegion;
|
import org.hostsharing.hsadminng.domain.enumeration.VatRegion;
|
||||||
import org.hostsharing.hsadminng.service.CustomerService;
|
import org.hostsharing.hsadminng.service.CustomerService;
|
||||||
import org.hostsharing.hsadminng.service.accessfilter.*;
|
import org.hostsharing.hsadminng.service.accessfilter.*;
|
||||||
|
|
||||||
import org.springframework.boot.jackson.JsonComponent;
|
import org.springframework.boot.jackson.JsonComponent;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A DTO for the Customer entity.
|
* A DTO for the Customer entity.
|
||||||
*/
|
*/
|
||||||
public class CustomerDTO implements AccessMappings, FluentBuilder<CustomerDTO> {
|
public class CustomerDTO implements AccessMappings, FluentBuilder<CustomerDTO> {
|
||||||
|
|
||||||
@SelfId(resolver = CustomerService.class)
|
@SelfId(resolver = CustomerService.class)
|
||||||
@AccessFor(read = Role.ANY_CUSTOMER_USER)
|
@AccessFor(read = Role.ANY_CUSTOMER_USER)
|
||||||
@ -41,27 +44,27 @@ public class CustomerDTO implements AccessMappings, FluentBuilder<CustomerDTO>
|
|||||||
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = Role.CONTRACTUAL_CONTACT)
|
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = Role.CONTRACTUAL_CONTACT)
|
||||||
private CustomerKind kind;
|
private CustomerKind kind;
|
||||||
|
|
||||||
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private LocalDate birthDate;
|
private LocalDate birthDate;
|
||||||
|
|
||||||
@Size(max = 80)
|
@Size(max = 80)
|
||||||
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private String birthPlace;
|
private String birthPlace;
|
||||||
|
|
||||||
@Size(max = 80)
|
@Size(max = 80)
|
||||||
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private String registrationCourt;
|
private String registrationCourt;
|
||||||
|
|
||||||
@Size(max = 80)
|
@Size(max = 80)
|
||||||
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private String registrationNumber;
|
private String registrationNumber;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private VatRegion vatRegion;
|
private VatRegion vatRegion;
|
||||||
|
|
||||||
@Size(max = 40)
|
@Size(max = 40)
|
||||||
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private String vatNumber;
|
private String vatNumber;
|
||||||
|
|
||||||
@Size(max = 80)
|
@Size(max = 80)
|
||||||
@ -74,18 +77,21 @@ public class CustomerDTO implements AccessMappings, FluentBuilder<CustomerDTO>
|
|||||||
private String contractualAddress;
|
private String contractualAddress;
|
||||||
|
|
||||||
@Size(max = 80)
|
@Size(max = 80)
|
||||||
@AccessFor(init = Role.ADMIN, update = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}, read = Role.CONTRACTUAL_CONTACT)
|
@AccessFor(
|
||||||
|
init = Role.ADMIN,
|
||||||
|
update = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT },
|
||||||
|
read = Role.CONTRACTUAL_CONTACT)
|
||||||
private String billingSalutation;
|
private String billingSalutation;
|
||||||
|
|
||||||
@Size(max = 400)
|
@Size(max = 400)
|
||||||
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private String billingAddress;
|
private String billingAddress;
|
||||||
|
|
||||||
@Size(max = 160)
|
@Size(max = 160)
|
||||||
@AccessFor(init = Role.ADMIN, update = Role.SUPPORTER, read = Role.SUPPORTER)
|
@AccessFor(init = Role.ADMIN, update = Role.SUPPORTER, read = Role.SUPPORTER)
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
@AccessFor(init=Role.ANYBODY, update=Role.ANYBODY, read = Role.ANY_CUSTOMER_USER)
|
@AccessFor(init = Role.ANYBODY, update = Role.ANYBODY, read = Role.ANY_CUSTOMER_USER)
|
||||||
private String displayLabel;
|
private String displayLabel;
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
@ -248,23 +254,23 @@ public class CustomerDTO implements AccessMappings, FluentBuilder<CustomerDTO>
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "CustomerDTO{" +
|
return "CustomerDTO{" +
|
||||||
"id=" + getId() +
|
"id=" + getId() +
|
||||||
", reference=" + getReference() +
|
", reference=" + getReference() +
|
||||||
", prefix='" + getPrefix() + "'" +
|
", prefix='" + getPrefix() + "'" +
|
||||||
", name='" + getName() + "'" +
|
", name='" + getName() + "'" +
|
||||||
", kind='" + getKind() + "'" +
|
", kind='" + getKind() + "'" +
|
||||||
", birthDate='" + getBirthDate() + "'" +
|
", birthDate='" + getBirthDate() + "'" +
|
||||||
", birthPlace='" + getBirthPlace() + "'" +
|
", birthPlace='" + getBirthPlace() + "'" +
|
||||||
", registrationCourt='" + getRegistrationCourt() + "'" +
|
", registrationCourt='" + getRegistrationCourt() + "'" +
|
||||||
", registrationNumber='" + getRegistrationNumber() + "'" +
|
", registrationNumber='" + getRegistrationNumber() + "'" +
|
||||||
", vatRegion='" + getVatRegion() + "'" +
|
", vatRegion='" + getVatRegion() + "'" +
|
||||||
", vatNumber='" + getVatNumber() + "'" +
|
", vatNumber='" + getVatNumber() + "'" +
|
||||||
", contractualSalutation='" + getContractualSalutation() + "'" +
|
", contractualSalutation='" + getContractualSalutation() + "'" +
|
||||||
", contractualAddress='" + getContractualAddress() + "'" +
|
", contractualAddress='" + getContractualAddress() + "'" +
|
||||||
", billingSalutation='" + getBillingSalutation() + "'" +
|
", billingSalutation='" + getBillingSalutation() + "'" +
|
||||||
", billingAddress='" + getBillingAddress() + "'" +
|
", billingAddress='" + getBillingAddress() + "'" +
|
||||||
", remark='" + getRemark() + "'" +
|
", remark='" + getRemark() + "'" +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonComponent
|
@JsonComponent
|
||||||
@ -283,4 +289,3 @@ public class CustomerDTO implements AccessMappings, FluentBuilder<CustomerDTO>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.dto;
|
package org.hostsharing.hsadminng.service.dto;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -17,18 +18,18 @@ public interface FluentBuilder<T> {
|
|||||||
*
|
*
|
||||||
* <h3>Example</h3>
|
* <h3>Example</h3>
|
||||||
* {code
|
* {code
|
||||||
* // adding a fluent builder to your class
|
* // adding a fluent builder to your class
|
||||||
* class YourClass implements FluentBuilder<YourClass> {
|
* class YourClass implements FluentBuilder<YourClass> {
|
||||||
* public int someField;
|
* public int someField;
|
||||||
* public String anotherField;
|
* public String anotherField;
|
||||||
* // ...
|
* // ...
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* // using the fluent builder somewhere else
|
* // using the fluent builder somewhere else
|
||||||
* someMethod( new YourClass().with( it -> {
|
* someMethod( new YourClass().with( it -> {
|
||||||
* it.someField = 5;
|
* it.someField = 5;
|
||||||
* it.anotherField = "Hello";
|
* it.anotherField = "Hello";
|
||||||
* }));
|
* }));
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* @param builderFunction statements to apply to 'this'
|
* @param builderFunction statements to apply to 'this'
|
||||||
@ -37,10 +38,9 @@ public interface FluentBuilder<T> {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
default T with(
|
default T with(
|
||||||
Consumer<T> builderFunction) {
|
Consumer<T> builderFunction) {
|
||||||
builderFunction.accept((T) this);
|
builderFunction.accept((T) this);
|
||||||
return (T) this;
|
return (T) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.dto;
|
package org.hostsharing.hsadminng.service.dto;
|
||||||
|
|
||||||
import io.github.jhipster.service.filter.Filter;
|
import io.github.jhipster.service.filter.Filter;
|
||||||
@ -110,7 +111,6 @@ public class MembershipCriteria implements Serializable {
|
|||||||
this.customerId = customerId;
|
this.customerId = customerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
if (this == o) {
|
||||||
@ -120,31 +120,29 @@ public class MembershipCriteria implements Serializable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final MembershipCriteria that = (MembershipCriteria) o;
|
final MembershipCriteria that = (MembershipCriteria) o;
|
||||||
return
|
return Objects.equals(id, that.id) &&
|
||||||
Objects.equals(id, that.id) &&
|
Objects.equals(admissionDocumentDate, that.admissionDocumentDate) &&
|
||||||
Objects.equals(admissionDocumentDate, that.admissionDocumentDate) &&
|
Objects.equals(cancellationDocumentDate, that.cancellationDocumentDate) &&
|
||||||
Objects.equals(cancellationDocumentDate, that.cancellationDocumentDate) &&
|
Objects.equals(memberFromDate, that.memberFromDate) &&
|
||||||
Objects.equals(memberFromDate, that.memberFromDate) &&
|
Objects.equals(memberUntilDate, that.memberUntilDate) &&
|
||||||
Objects.equals(memberUntilDate, that.memberUntilDate) &&
|
Objects.equals(remark, that.remark) &&
|
||||||
Objects.equals(remark, that.remark) &&
|
Objects.equals(shareId, that.shareId) &&
|
||||||
Objects.equals(shareId, that.shareId) &&
|
Objects.equals(assetId, that.assetId) &&
|
||||||
Objects.equals(assetId, that.assetId) &&
|
Objects.equals(customerId, that.customerId);
|
||||||
Objects.equals(customerId, that.customerId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(
|
return Objects.hash(
|
||||||
id,
|
id,
|
||||||
admissionDocumentDate,
|
admissionDocumentDate,
|
||||||
cancellationDocumentDate,
|
cancellationDocumentDate,
|
||||||
memberFromDate,
|
memberFromDate,
|
||||||
memberUntilDate,
|
memberUntilDate,
|
||||||
remark,
|
remark,
|
||||||
shareId,
|
shareId,
|
||||||
assetId,
|
assetId,
|
||||||
customerId
|
customerId);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -159,7 +157,7 @@ public class MembershipCriteria implements Serializable {
|
|||||||
(shareId != null ? "shareId=" + shareId + ", " : "") +
|
(shareId != null ? "shareId=" + shareId + ", " : "") +
|
||||||
(assetId != null ? "assetId=" + assetId + ", " : "") +
|
(assetId != null ? "assetId=" + assetId + ", " : "") +
|
||||||
(customerId != null ? "customerId=" + customerId + ", " : "") +
|
(customerId != null ? "customerId=" + customerId + ", " : "") +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,37 +1,40 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.dto;
|
package org.hostsharing.hsadminng.service.dto;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.service.CustomerService;
|
import org.hostsharing.hsadminng.service.CustomerService;
|
||||||
import org.hostsharing.hsadminng.service.MembershipService;
|
import org.hostsharing.hsadminng.service.MembershipService;
|
||||||
import org.hostsharing.hsadminng.service.accessfilter.*;
|
import org.hostsharing.hsadminng.service.accessfilter.*;
|
||||||
|
|
||||||
import org.springframework.boot.jackson.JsonComponent;
|
import org.springframework.boot.jackson.JsonComponent;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import javax.validation.constraints.Size;
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A DTO for the Membership entity.
|
* A DTO for the Membership entity.
|
||||||
*/
|
*/
|
||||||
public class MembershipDTO implements AccessMappings, FluentBuilder<MembershipDTO> {
|
public class MembershipDTO implements AccessMappings, FluentBuilder<MembershipDTO> {
|
||||||
|
|
||||||
@SelfId(resolver = MembershipService.class)
|
@SelfId(resolver = MembershipService.class)
|
||||||
@AccessFor(read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private LocalDate admissionDocumentDate;
|
private LocalDate admissionDocumentDate;
|
||||||
|
|
||||||
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private LocalDate cancellationDocumentDate;
|
private LocalDate cancellationDocumentDate;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private LocalDate memberFromDate;
|
private LocalDate memberFromDate;
|
||||||
|
|
||||||
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private LocalDate memberUntilDate;
|
private LocalDate memberUntilDate;
|
||||||
|
|
||||||
@Size(max = 160)
|
@Size(max = 160)
|
||||||
@ -39,10 +42,10 @@ public class MembershipDTO implements AccessMappings, FluentBuilder<MembershipDT
|
|||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
@ParentId(resolver = CustomerService.class)
|
@ParentId(resolver = CustomerService.class)
|
||||||
@AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private Long customerId;
|
private Long customerId;
|
||||||
|
|
||||||
@AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private String customerPrefix;
|
private String customerPrefix;
|
||||||
|
|
||||||
@AccessFor(init = Role.ANYBODY, update = Role.ANYBODY, read = Role.FINANCIAL_CONTACT)
|
@AccessFor(init = Role.ANYBODY, update = Role.ANYBODY, read = Role.FINANCIAL_CONTACT)
|
||||||
@ -155,15 +158,15 @@ public class MembershipDTO implements AccessMappings, FluentBuilder<MembershipDT
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "MembershipDTO{" +
|
return "MembershipDTO{" +
|
||||||
"id=" + getId() +
|
"id=" + getId() +
|
||||||
", admissionDocumentDate='" + getAdmissionDocumentDate() + "'" +
|
", admissionDocumentDate='" + getAdmissionDocumentDate() + "'" +
|
||||||
", cancellationDocumentDate='" + getCancellationDocumentDate() + "'" +
|
", cancellationDocumentDate='" + getCancellationDocumentDate() + "'" +
|
||||||
", memberFromDate='" + getMemberFromDate() + "'" +
|
", memberFromDate='" + getMemberFromDate() + "'" +
|
||||||
", memberUntilDate='" + getMemberUntilDate() + "'" +
|
", memberUntilDate='" + getMemberUntilDate() + "'" +
|
||||||
", remark='" + getRemark() + "'" +
|
", remark='" + getRemark() + "'" +
|
||||||
", customer=" + getCustomerId() +
|
", customer=" + getCustomerId() +
|
||||||
", customer='" + getCustomerPrefix() + "'" +
|
", customer='" + getCustomerPrefix() + "'" +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonComponent
|
@JsonComponent
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.dto;
|
package org.hostsharing.hsadminng.service.dto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A DTO representing a password change required data - current and new password.
|
* A DTO representing a password change required data - current and new password.
|
||||||
*/
|
*/
|
||||||
public class PasswordChangeDTO {
|
public class PasswordChangeDTO {
|
||||||
|
|
||||||
private String currentPassword;
|
private String currentPassword;
|
||||||
private String newPassword;
|
private String newPassword;
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.dto;
|
package org.hostsharing.hsadminng.service.dto;
|
||||||
|
|
||||||
import io.github.jhipster.service.filter.Filter;
|
import io.github.jhipster.service.filter.Filter;
|
||||||
@ -130,7 +131,6 @@ public class SepaMandateCriteria implements Serializable {
|
|||||||
this.customerId = customerId;
|
this.customerId = customerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
if (this == o) {
|
||||||
@ -140,35 +140,33 @@ public class SepaMandateCriteria implements Serializable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final SepaMandateCriteria that = (SepaMandateCriteria) o;
|
final SepaMandateCriteria that = (SepaMandateCriteria) o;
|
||||||
return
|
return Objects.equals(id, that.id) &&
|
||||||
Objects.equals(id, that.id) &&
|
Objects.equals(reference, that.reference) &&
|
||||||
Objects.equals(reference, that.reference) &&
|
Objects.equals(iban, that.iban) &&
|
||||||
Objects.equals(iban, that.iban) &&
|
Objects.equals(bic, that.bic) &&
|
||||||
Objects.equals(bic, that.bic) &&
|
Objects.equals(grantingDocumentDate, that.grantingDocumentDate) &&
|
||||||
Objects.equals(grantingDocumentDate, that.grantingDocumentDate) &&
|
Objects.equals(revokationDocumentDate, that.revokationDocumentDate) &&
|
||||||
Objects.equals(revokationDocumentDate, that.revokationDocumentDate) &&
|
Objects.equals(validFromDate, that.validFromDate) &&
|
||||||
Objects.equals(validFromDate, that.validFromDate) &&
|
Objects.equals(validUntilDate, that.validUntilDate) &&
|
||||||
Objects.equals(validUntilDate, that.validUntilDate) &&
|
Objects.equals(lastUsedDate, that.lastUsedDate) &&
|
||||||
Objects.equals(lastUsedDate, that.lastUsedDate) &&
|
Objects.equals(remark, that.remark) &&
|
||||||
Objects.equals(remark, that.remark) &&
|
Objects.equals(customerId, that.customerId);
|
||||||
Objects.equals(customerId, that.customerId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(
|
return Objects.hash(
|
||||||
id,
|
id,
|
||||||
reference,
|
reference,
|
||||||
iban,
|
iban,
|
||||||
bic,
|
bic,
|
||||||
grantingDocumentDate,
|
grantingDocumentDate,
|
||||||
revokationDocumentDate,
|
revokationDocumentDate,
|
||||||
validFromDate,
|
validFromDate,
|
||||||
validUntilDate,
|
validUntilDate,
|
||||||
lastUsedDate,
|
lastUsedDate,
|
||||||
remark,
|
remark,
|
||||||
customerId
|
customerId);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -185,7 +183,7 @@ public class SepaMandateCriteria implements Serializable {
|
|||||||
(lastUsedDate != null ? "lastUsedDate=" + lastUsedDate + ", " : "") +
|
(lastUsedDate != null ? "lastUsedDate=" + lastUsedDate + ", " : "") +
|
||||||
(remark != null ? "remark=" + remark + ", " : "") +
|
(remark != null ? "remark=" + remark + ", " : "") +
|
||||||
(customerId != null ? "customerId=" + customerId + ", " : "") +
|
(customerId != null ? "customerId=" + customerId + ", " : "") +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,53 +1,72 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.dto;
|
package org.hostsharing.hsadminng.service.dto;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.service.CustomerService;
|
import org.hostsharing.hsadminng.service.CustomerService;
|
||||||
import org.hostsharing.hsadminng.service.SepaMandateService;
|
import org.hostsharing.hsadminng.service.SepaMandateService;
|
||||||
import org.hostsharing.hsadminng.service.accessfilter.*;
|
import org.hostsharing.hsadminng.service.accessfilter.*;
|
||||||
|
|
||||||
import org.springframework.boot.jackson.JsonComponent;
|
import org.springframework.boot.jackson.JsonComponent;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import javax.validation.constraints.Size;
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A DTO for the SepaMandate entity.
|
* A DTO for the SepaMandate entity.
|
||||||
*/
|
*/
|
||||||
public class SepaMandateDTO implements AccessMappings, FluentBuilder<SepaMandateDTO> {
|
public class SepaMandateDTO implements AccessMappings, FluentBuilder<SepaMandateDTO> {
|
||||||
|
|
||||||
@SelfId(resolver = SepaMandateService.class)
|
@SelfId(resolver = SepaMandateService.class)
|
||||||
@AccessFor(read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Size(max = 40)
|
@Size(max = 40)
|
||||||
@AccessFor(init = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(
|
||||||
|
init = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT },
|
||||||
|
read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private String reference;
|
private String reference;
|
||||||
|
|
||||||
@Size(max = 34)
|
@Size(max = 34)
|
||||||
@AccessFor(init = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(
|
||||||
|
init = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT },
|
||||||
|
read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private String iban;
|
private String iban;
|
||||||
|
|
||||||
@Size(max = 11)
|
@Size(max = 11)
|
||||||
@AccessFor(init = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(
|
||||||
|
init = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT },
|
||||||
|
read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private String bic;
|
private String bic;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@AccessFor(init = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(
|
||||||
|
init = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT },
|
||||||
|
read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private LocalDate grantingDocumentDate;
|
private LocalDate grantingDocumentDate;
|
||||||
|
|
||||||
@AccessFor(init = Role.ADMIN, update = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(
|
||||||
|
init = Role.ADMIN,
|
||||||
|
update = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT },
|
||||||
|
read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private LocalDate revokationDocumentDate;
|
private LocalDate revokationDocumentDate;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@AccessFor(init = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(
|
||||||
|
init = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT },
|
||||||
|
read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private LocalDate validFromDate;
|
private LocalDate validFromDate;
|
||||||
|
|
||||||
@AccessFor(init = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}, update = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(
|
||||||
|
init = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT },
|
||||||
|
update = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT },
|
||||||
|
read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private LocalDate validUntilDate;
|
private LocalDate validUntilDate;
|
||||||
|
|
||||||
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private LocalDate lastUsedDate;
|
private LocalDate lastUsedDate;
|
||||||
|
|
||||||
@Size(max = 160)
|
@Size(max = 160)
|
||||||
@ -55,10 +74,12 @@ public class SepaMandateDTO implements AccessMappings, FluentBuilder<SepaMandate
|
|||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
@ParentId(resolver = CustomerService.class)
|
@ParentId(resolver = CustomerService.class)
|
||||||
@AccessFor(init = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(
|
||||||
|
init = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT },
|
||||||
|
read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private Long customerId;
|
private Long customerId;
|
||||||
|
|
||||||
@AccessFor(update = Role.IGNORED, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(update = Role.IGNORED, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private String customerDisplayLabel;
|
private String customerDisplayLabel;
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
@ -181,19 +202,19 @@ public class SepaMandateDTO implements AccessMappings, FluentBuilder<SepaMandate
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SepaMandateDTO{" +
|
return "SepaMandateDTO{" +
|
||||||
"id=" + getId() +
|
"id=" + getId() +
|
||||||
", reference='" + getReference() + "'" +
|
", reference='" + getReference() + "'" +
|
||||||
", iban='" + getIban() + "'" +
|
", iban='" + getIban() + "'" +
|
||||||
", bic='" + getBic() + "'" +
|
", bic='" + getBic() + "'" +
|
||||||
", grantingDocumentDate='" + getGrantingDocumentDate() + "'" +
|
", grantingDocumentDate='" + getGrantingDocumentDate() + "'" +
|
||||||
", revokationDocumentDate='" + getRevokationDocumentDate() + "'" +
|
", revokationDocumentDate='" + getRevokationDocumentDate() + "'" +
|
||||||
", validFromDate='" + getValidFromDate() + "'" +
|
", validFromDate='" + getValidFromDate() + "'" +
|
||||||
", validUntilDate='" + getValidUntilDate() + "'" +
|
", validUntilDate='" + getValidUntilDate() + "'" +
|
||||||
", lastUsedDate='" + getLastUsedDate() + "'" +
|
", lastUsedDate='" + getLastUsedDate() + "'" +
|
||||||
", remark='" + getRemark() + "'" +
|
", remark='" + getRemark() + "'" +
|
||||||
", customer=" + getCustomerId() +
|
", customer=" + getCustomerId() +
|
||||||
", customerDisplayLabel='" + getCustomerDisplayLabel() + "'" +
|
", customerDisplayLabel='" + getCustomerDisplayLabel() + "'" +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonComponent
|
@JsonComponent
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.dto;
|
package org.hostsharing.hsadminng.service.dto;
|
||||||
|
|
||||||
|
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
|
||||||
|
|
||||||
|
import io.github.jhipster.service.filter.Filter;
|
||||||
|
import io.github.jhipster.service.filter.IntegerFilter;
|
||||||
|
import io.github.jhipster.service.filter.LocalDateFilter;
|
||||||
|
import io.github.jhipster.service.filter.LongFilter;
|
||||||
|
import io.github.jhipster.service.filter.StringFilter;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
|
|
||||||
import io.github.jhipster.service.filter.BooleanFilter;
|
|
||||||
import io.github.jhipster.service.filter.DoubleFilter;
|
|
||||||
import io.github.jhipster.service.filter.Filter;
|
|
||||||
import io.github.jhipster.service.filter.FloatFilter;
|
|
||||||
import io.github.jhipster.service.filter.IntegerFilter;
|
|
||||||
import io.github.jhipster.service.filter.LongFilter;
|
|
||||||
import io.github.jhipster.service.filter.StringFilter;
|
|
||||||
import io.github.jhipster.service.filter.LocalDateFilter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Criteria class for the Share entity. This class is used in ShareResource to
|
* Criteria class for the Share entity. This class is used in ShareResource to
|
||||||
@ -21,6 +21,7 @@ import io.github.jhipster.service.filter.LocalDateFilter;
|
|||||||
* fix type specific filters.
|
* fix type specific filters.
|
||||||
*/
|
*/
|
||||||
public class ShareCriteria implements Serializable {
|
public class ShareCriteria implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for filtering ShareAction
|
* Class for filtering ShareAction
|
||||||
*/
|
*/
|
||||||
@ -99,7 +100,6 @@ public class ShareCriteria implements Serializable {
|
|||||||
this.membershipId = membershipId;
|
this.membershipId = membershipId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
if (this == o) {
|
||||||
@ -109,27 +109,25 @@ public class ShareCriteria implements Serializable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final ShareCriteria that = (ShareCriteria) o;
|
final ShareCriteria that = (ShareCriteria) o;
|
||||||
return
|
return Objects.equals(id, that.id) &&
|
||||||
Objects.equals(id, that.id) &&
|
Objects.equals(documentDate, that.documentDate) &&
|
||||||
Objects.equals(documentDate, that.documentDate) &&
|
Objects.equals(valueDate, that.valueDate) &&
|
||||||
Objects.equals(valueDate, that.valueDate) &&
|
Objects.equals(action, that.action) &&
|
||||||
Objects.equals(action, that.action) &&
|
Objects.equals(quantity, that.quantity) &&
|
||||||
Objects.equals(quantity, that.quantity) &&
|
Objects.equals(remark, that.remark) &&
|
||||||
Objects.equals(remark, that.remark) &&
|
Objects.equals(membershipId, that.membershipId);
|
||||||
Objects.equals(membershipId, that.membershipId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(
|
return Objects.hash(
|
||||||
id,
|
id,
|
||||||
documentDate,
|
documentDate,
|
||||||
valueDate,
|
valueDate,
|
||||||
action,
|
action,
|
||||||
quantity,
|
quantity,
|
||||||
remark,
|
remark,
|
||||||
membershipId
|
membershipId);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -142,7 +140,7 @@ public class ShareCriteria implements Serializable {
|
|||||||
(quantity != null ? "quantity=" + quantity + ", " : "") +
|
(quantity != null ? "quantity=" + quantity + ", " : "") +
|
||||||
(remark != null ? "remark=" + remark + ", " : "") +
|
(remark != null ? "remark=" + remark + ", " : "") +
|
||||||
(membershipId != null ? "membershipId=" + membershipId + ", " : "") +
|
(membershipId != null ? "membershipId=" + membershipId + ", " : "") +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,41 +1,44 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.dto;
|
package org.hostsharing.hsadminng.service.dto;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
|
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
|
||||||
import org.hostsharing.hsadminng.service.MembershipService;
|
import org.hostsharing.hsadminng.service.MembershipService;
|
||||||
import org.hostsharing.hsadminng.service.ShareService;
|
import org.hostsharing.hsadminng.service.ShareService;
|
||||||
import org.hostsharing.hsadminng.service.accessfilter.*;
|
import org.hostsharing.hsadminng.service.accessfilter.*;
|
||||||
|
|
||||||
import org.springframework.boot.jackson.JsonComponent;
|
import org.springframework.boot.jackson.JsonComponent;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import javax.validation.constraints.Size;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A DTO for the Share entity.
|
* A DTO for the Share entity.
|
||||||
*/
|
*/
|
||||||
public class ShareDTO implements Serializable, AccessMappings {
|
public class ShareDTO implements Serializable, AccessMappings {
|
||||||
|
|
||||||
@SelfId(resolver = ShareService.class)
|
@SelfId(resolver = ShareService.class)
|
||||||
@AccessFor(read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private LocalDate documentDate;
|
private LocalDate documentDate;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private LocalDate valueDate;
|
private LocalDate valueDate;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private ShareAction action;
|
private ShareAction action;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private Integer quantity;
|
private Integer quantity;
|
||||||
|
|
||||||
@Size(max = 160)
|
@Size(max = 160)
|
||||||
@ -43,10 +46,10 @@ public class ShareDTO implements Serializable, AccessMappings {
|
|||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
@ParentId(resolver = MembershipService.class)
|
@ParentId(resolver = MembershipService.class)
|
||||||
@AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(init = Role.ADMIN, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private Long membershipId;
|
private Long membershipId;
|
||||||
|
|
||||||
@AccessFor(update = Role.IGNORED, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
@AccessFor(update = Role.IGNORED, read = { Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT })
|
||||||
private String membershipDisplayLabel;
|
private String membershipDisplayLabel;
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
@ -137,15 +140,15 @@ public class ShareDTO implements Serializable, AccessMappings {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ShareDTO{" +
|
return "ShareDTO{" +
|
||||||
"id=" + getId() +
|
"id=" + getId() +
|
||||||
", documentDate='" + getDocumentDate() + "'" +
|
", documentDate='" + getDocumentDate() + "'" +
|
||||||
", valueDate='" + getValueDate() + "'" +
|
", valueDate='" + getValueDate() + "'" +
|
||||||
", action='" + getAction() + "'" +
|
", action='" + getAction() + "'" +
|
||||||
", quantity=" + getQuantity() +
|
", quantity=" + getQuantity() +
|
||||||
", remark='" + getRemark() + "'" +
|
", remark='" + getRemark() + "'" +
|
||||||
", membership=" + getMembershipId() +
|
", membership=" + getMembershipId() +
|
||||||
", membershipDisplayLabel='" + getMembershipDisplayLabel() + "'" +
|
", membershipDisplayLabel='" + getMembershipDisplayLabel() + "'" +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonComponent
|
@JsonComponent
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.dto;
|
package org.hostsharing.hsadminng.service.dto;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.config.Constants;
|
import org.hostsharing.hsadminng.config.Constants;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.Authority;
|
import org.hostsharing.hsadminng.domain.Authority;
|
||||||
import org.hostsharing.hsadminng.domain.User;
|
import org.hostsharing.hsadminng.domain.User;
|
||||||
|
|
||||||
import javax.validation.constraints.Email;
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.constraints.Email;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A DTO representing a user, with his authorities.
|
* A DTO representing a user, with his authorities.
|
||||||
*/
|
*/
|
||||||
@ -70,9 +70,10 @@ public class UserDTO {
|
|||||||
this.createdDate = user.getCreatedDate();
|
this.createdDate = user.getCreatedDate();
|
||||||
this.lastModifiedBy = user.getLastModifiedBy();
|
this.lastModifiedBy = user.getLastModifiedBy();
|
||||||
this.lastModifiedDate = user.getLastModifiedDate();
|
this.lastModifiedDate = user.getLastModifiedDate();
|
||||||
this.authorities = user.getAuthorities().stream()
|
this.authorities = user.getAuthorities()
|
||||||
.map(Authority::getName)
|
.stream()
|
||||||
.collect(Collectors.toSet());
|
.map(Authority::getName)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
@ -182,18 +183,18 @@ public class UserDTO {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "UserDTO{" +
|
return "UserDTO{" +
|
||||||
"login='" + login + '\'' +
|
"login='" + login + '\'' +
|
||||||
", firstName='" + firstName + '\'' +
|
", firstName='" + firstName + '\'' +
|
||||||
", lastName='" + lastName + '\'' +
|
", lastName='" + lastName + '\'' +
|
||||||
", email='" + email + '\'' +
|
", email='" + email + '\'' +
|
||||||
", imageUrl='" + imageUrl + '\'' +
|
", imageUrl='" + imageUrl + '\'' +
|
||||||
", activated=" + activated +
|
", activated=" + activated +
|
||||||
", langKey='" + langKey + '\'' +
|
", langKey='" + langKey + '\'' +
|
||||||
", createdBy=" + createdBy +
|
", createdBy=" + createdBy +
|
||||||
", createdDate=" + createdDate +
|
", createdDate=" + createdDate +
|
||||||
", lastModifiedBy='" + lastModifiedBy + '\'' +
|
", lastModifiedBy='" + lastModifiedBy + '\'' +
|
||||||
", lastModifiedDate=" + lastModifiedDate +
|
", lastModifiedDate=" + lastModifiedDate +
|
||||||
", authorities=" + authorities +
|
", authorities=" + authorities +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.mapper;
|
package org.hostsharing.hsadminng.service.mapper;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.Asset;
|
import org.hostsharing.hsadminng.domain.Asset;
|
||||||
import org.hostsharing.hsadminng.service.dto.AssetDTO;
|
import org.hostsharing.hsadminng.service.dto.AssetDTO;
|
||||||
|
|
||||||
import org.mapstruct.AfterMapping;
|
import org.mapstruct.AfterMapping;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
||||||
@ -10,7 +12,7 @@ import org.mapstruct.MappingTarget;
|
|||||||
/**
|
/**
|
||||||
* Mapper for the entity Asset and its DTO AssetDTO.
|
* Mapper for the entity Asset and its DTO AssetDTO.
|
||||||
*/
|
*/
|
||||||
@Mapper(componentModel = "spring", uses = {MembershipMapper.class})
|
@Mapper(componentModel = "spring", uses = { MembershipMapper.class })
|
||||||
public interface AssetMapper extends EntityMapper<AssetDTO, Asset> {
|
public interface AssetMapper extends EntityMapper<AssetDTO, Asset> {
|
||||||
|
|
||||||
@Mapping(source = "membership.id", target = "membershipId")
|
@Mapping(source = "membership.id", target = "membershipId")
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.mapper;
|
package org.hostsharing.hsadminng.service.mapper;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.Customer;
|
import org.hostsharing.hsadminng.domain.Customer;
|
||||||
import org.hostsharing.hsadminng.service.dto.CustomerDTO;
|
import org.hostsharing.hsadminng.service.dto.CustomerDTO;
|
||||||
|
|
||||||
import org.mapstruct.AfterMapping;
|
import org.mapstruct.AfterMapping;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
||||||
@ -14,8 +16,8 @@ import org.mapstruct.MappingTarget;
|
|||||||
public interface CustomerMapper extends EntityMapper<CustomerDTO, Customer> {
|
public interface CustomerMapper extends EntityMapper<CustomerDTO, Customer> {
|
||||||
|
|
||||||
static String displayLabel(Customer customer) {
|
static String displayLabel(Customer customer) {
|
||||||
return customer.getName()
|
return customer.getName()
|
||||||
+ " [" + customer.getReference() + ":" + customer.getPrefix() +"]";
|
+ " [" + customer.getReference() + ":" + customer.getPrefix() + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mapping(target = "displayLabel", ignore = true)
|
@Mapping(target = "displayLabel", ignore = true)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.mapper;
|
package org.hostsharing.hsadminng.service.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -9,13 +10,13 @@ import java.util.List;
|
|||||||
* @param <E> - Entity type parameter.
|
* @param <E> - Entity type parameter.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public interface EntityMapper <D, E> {
|
public interface EntityMapper<D, E> {
|
||||||
|
|
||||||
E toEntity(D dto);
|
E toEntity(D dto);
|
||||||
|
|
||||||
D toDto(E entity);
|
D toDto(E entity);
|
||||||
|
|
||||||
List <E> toEntity(List<D> dtoList);
|
List<E> toEntity(List<D> dtoList);
|
||||||
|
|
||||||
List <D> toDto(List<E> entityList);
|
List<D> toDto(List<E> entityList);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.mapper;
|
package org.hostsharing.hsadminng.service.mapper;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.Customer;
|
import org.hostsharing.hsadminng.domain.Customer;
|
||||||
import org.hostsharing.hsadminng.domain.Membership;
|
import org.hostsharing.hsadminng.domain.Membership;
|
||||||
import org.hostsharing.hsadminng.service.dto.MembershipDTO;
|
import org.hostsharing.hsadminng.service.dto.MembershipDTO;
|
||||||
|
|
||||||
import org.mapstruct.AfterMapping;
|
import org.mapstruct.AfterMapping;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
||||||
@ -13,14 +15,14 @@ import java.util.Objects;
|
|||||||
/**
|
/**
|
||||||
* Mapper for the entity Membership and its DTO MembershipDTO.
|
* Mapper for the entity Membership and its DTO MembershipDTO.
|
||||||
*/
|
*/
|
||||||
@Mapper(componentModel = "spring", uses = {CustomerMapper.class})
|
@Mapper(componentModel = "spring", uses = { CustomerMapper.class })
|
||||||
public interface MembershipMapper extends EntityMapper<MembershipDTO, Membership> {
|
public interface MembershipMapper extends EntityMapper<MembershipDTO, Membership> {
|
||||||
|
|
||||||
static String displayLabel(final Membership entity) {
|
static String displayLabel(final Membership entity) {
|
||||||
final Customer customer = entity.getCustomer();
|
final Customer customer = entity.getCustomer();
|
||||||
return CustomerMapper.displayLabel(customer) + " "
|
return CustomerMapper.displayLabel(customer) + " "
|
||||||
+ Objects.toString(entity.getMemberFromDate(), "") + " - "
|
+ Objects.toString(entity.getMemberFromDate(), "") + " - "
|
||||||
+ Objects.toString(entity.getMemberUntilDate(), "...");
|
+ Objects.toString(entity.getMemberUntilDate(), "...");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mapping(source = "customer.id", target = "customerId")
|
@Mapping(source = "customer.id", target = "customerId")
|
||||||
@ -30,7 +32,7 @@ public interface MembershipMapper extends EntityMapper<MembershipDTO, Membership
|
|||||||
MembershipDTO toDto(Membership membership);
|
MembershipDTO toDto(Membership membership);
|
||||||
|
|
||||||
// TODO BLOG HOWTO: multi-field display reference for selection lists
|
// TODO BLOG HOWTO: multi-field display reference for selection lists
|
||||||
// also change the filed in the option list in *-update.html
|
// also change the filed in the option list in *-update.html
|
||||||
@AfterMapping
|
@AfterMapping
|
||||||
default void setMembershipDisplayLabel(final @MappingTarget MembershipDTO dto, final Membership entity) {
|
default void setMembershipDisplayLabel(final @MappingTarget MembershipDTO dto, final Membership entity) {
|
||||||
dto.setDisplayLabel(displayLabel(entity));
|
dto.setDisplayLabel(displayLabel(entity));
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.mapper;
|
package org.hostsharing.hsadminng.service.mapper;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.SepaMandate;
|
import org.hostsharing.hsadminng.domain.SepaMandate;
|
||||||
import org.hostsharing.hsadminng.service.dto.SepaMandateDTO;
|
import org.hostsharing.hsadminng.service.dto.SepaMandateDTO;
|
||||||
|
|
||||||
import org.mapstruct.AfterMapping;
|
import org.mapstruct.AfterMapping;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
||||||
@ -10,7 +12,7 @@ import org.mapstruct.MappingTarget;
|
|||||||
/**
|
/**
|
||||||
* Mapper for the entity SepaMandate and its DTO SepaMandateDTO.
|
* Mapper for the entity SepaMandate and its DTO SepaMandateDTO.
|
||||||
*/
|
*/
|
||||||
@Mapper(componentModel = "spring", uses = {CustomerMapper.class})
|
@Mapper(componentModel = "spring", uses = { CustomerMapper.class })
|
||||||
public interface SepaMandateMapper extends EntityMapper<SepaMandateDTO, SepaMandate> {
|
public interface SepaMandateMapper extends EntityMapper<SepaMandateDTO, SepaMandate> {
|
||||||
|
|
||||||
@Mapping(source = "customer.id", target = "customerId")
|
@Mapping(source = "customer.id", target = "customerId")
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.mapper;
|
package org.hostsharing.hsadminng.service.mapper;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.Share;
|
import org.hostsharing.hsadminng.domain.Share;
|
||||||
import org.hostsharing.hsadminng.service.dto.ShareDTO;
|
import org.hostsharing.hsadminng.service.dto.ShareDTO;
|
||||||
|
|
||||||
import org.mapstruct.AfterMapping;
|
import org.mapstruct.AfterMapping;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
||||||
@ -10,7 +12,7 @@ import org.mapstruct.MappingTarget;
|
|||||||
/**
|
/**
|
||||||
* Mapper for the entity Share and its DTO ShareDTO.
|
* Mapper for the entity Share and its DTO ShareDTO.
|
||||||
*/
|
*/
|
||||||
@Mapper(componentModel = "spring", uses = {MembershipMapper.class})
|
@Mapper(componentModel = "spring", uses = { MembershipMapper.class })
|
||||||
public interface ShareMapper extends EntityMapper<ShareDTO, Share> {
|
public interface ShareMapper extends EntityMapper<ShareDTO, Share> {
|
||||||
|
|
||||||
@Mapping(source = "membership.id", target = "membershipId")
|
@Mapping(source = "membership.id", target = "membershipId")
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.mapper;
|
package org.hostsharing.hsadminng.service.mapper;
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.Authority;
|
import org.hostsharing.hsadminng.domain.Authority;
|
||||||
@ -20,9 +21,9 @@ public class UserMapper {
|
|||||||
|
|
||||||
public List<UserDTO> usersToUserDTOs(List<User> users) {
|
public List<UserDTO> usersToUserDTOs(List<User> users) {
|
||||||
return users.stream()
|
return users.stream()
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.map(this::userToUserDTO)
|
.map(this::userToUserDTO)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserDTO userToUserDTO(User user) {
|
public UserDTO userToUserDTO(User user) {
|
||||||
@ -31,9 +32,9 @@ public class UserMapper {
|
|||||||
|
|
||||||
public List<User> userDTOsToUsers(List<UserDTO> userDTOs) {
|
public List<User> userDTOsToUsers(List<UserDTO> userDTOs) {
|
||||||
return userDTOs.stream()
|
return userDTOs.stream()
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.map(this::userDTOToUser)
|
.map(this::userDTOToUser)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public User userDTOToUser(UserDTO userDTO) {
|
public User userDTOToUser(UserDTO userDTO) {
|
||||||
@ -55,11 +56,10 @@ public class UserMapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Set<Authority> authoritiesFromStrings(Set<String> authoritiesAsString) {
|
private Set<Authority> authoritiesFromStrings(Set<String> authoritiesAsString) {
|
||||||
Set<Authority> authorities = new HashSet<>();
|
Set<Authority> authorities = new HashSet<>();
|
||||||
|
|
||||||
if(authoritiesAsString != null){
|
if (authoritiesAsString != null) {
|
||||||
authorities = authoritiesAsString.stream().map(string -> {
|
authorities = authoritiesAsString.stream().map(string -> {
|
||||||
Authority auth = new Authority();
|
Authority auth = new Authority();
|
||||||
auth.setName(string);
|
auth.setName(string);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.util;
|
package org.hostsharing.hsadminng.service.util;
|
||||||
|
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
@ -45,8 +46,8 @@ public final class RandomUtil {
|
|||||||
*
|
*
|
||||||
* @return the generated enum value
|
* @return the generated enum value
|
||||||
*/
|
*/
|
||||||
public static <E extends Enum<E>> E generateEnumValue(final Class<E> enumType) {
|
public static <E extends Enum<E>> E generateEnumValue(final Class<E> enumType) {
|
||||||
final E[] enumValues = enumType.getEnumConstants();
|
final E[] enumValues = enumType.getEnumConstants();
|
||||||
return enumValues[RandomUtils.nextInt(0, enumValues.length-1)];
|
return enumValues[RandomUtils.nextInt(0, enumValues.length - 1)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.service.util;
|
package org.hostsharing.hsadminng.service.util;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
|
||||||
public class ReflectionUtil {
|
public class ReflectionUtil {
|
||||||
|
|
||||||
public static Field getField(final Class<?> aClass, final String fieldName) {
|
public static Field getField(final Class<?> aClass, final String fieldName) {
|
||||||
@ -38,24 +38,32 @@ public class ReflectionUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches the annotations of 'clazz' for an implemented interface 'rawInterface' and returns the class of the actual generics parameter at the specified index.
|
* Searches the annotations of 'clazz' for an implemented interface 'rawInterface' and returns the class of the actual
|
||||||
|
* generics parameter at the specified index.
|
||||||
*
|
*
|
||||||
* @param clazz a class which implements the generic interface 'rawInterface'
|
* @param clazz a class which implements the generic interface 'rawInterface'
|
||||||
* @param rawInterface a generic interface
|
* @param rawInterface a generic interface
|
||||||
* @param paramIndex the index of the generics parameter within 'rawInterface'
|
* @param paramIndex the index of the generics parameter within 'rawInterface'
|
||||||
* @param <T> the expected class of the generics parameter at position 'index' in 'rawInterface'
|
* @param <T> the expected class of the generics parameter at position 'index' in 'rawInterface'
|
||||||
* @return the actual generics parameter
|
* @return the actual generics parameter
|
||||||
*/
|
*/
|
||||||
public static <T> Class<T> determineGenericInterfaceParameter(final Class<?> clazz, final Class<?> rawInterface, final int paramIndex) {
|
public static <T> Class<T> determineGenericInterfaceParameter(
|
||||||
|
final Class<?> clazz,
|
||||||
|
final Class<?> rawInterface,
|
||||||
|
final int paramIndex) {
|
||||||
final Class<T> found = determineGenericInterfaceParameterImpl(clazz, rawInterface, paramIndex);
|
final Class<T> found = determineGenericInterfaceParameterImpl(clazz, rawInterface, paramIndex);
|
||||||
if (found == null) {
|
if (found == null) {
|
||||||
throw new AssertionError(clazz.getSimpleName() + " expected to implement " + rawInterface.getSimpleName() + "<...>");
|
throw new AssertionError(
|
||||||
|
clazz.getSimpleName() + " expected to implement " + rawInterface.getSimpleName() + "<...>");
|
||||||
}
|
}
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static <T> Class<T> determineGenericInterfaceParameterImpl(final Class<?> clazz, final Class<?> rawInterface, final int paramIndex) {
|
private static <T> Class<T> determineGenericInterfaceParameterImpl(
|
||||||
|
final Class<?> clazz,
|
||||||
|
final Class<?> rawInterface,
|
||||||
|
final int paramIndex) {
|
||||||
for (Type genericInterface : clazz.getGenericInterfaces()) {
|
for (Type genericInterface : clazz.getGenericInterfaces()) {
|
||||||
if (genericInterface instanceof ParameterizedType) {
|
if (genericInterface instanceof ParameterizedType) {
|
||||||
final ParameterizedType parameterizedType = (ParameterizedType) genericInterface;
|
final ParameterizedType parameterizedType = (ParameterizedType) genericInterface;
|
||||||
@ -80,15 +88,19 @@ public class ReflectionUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches the annotations of 'clazz' for an extended class 'rawClass' and returns the class of the actual generics parameter at the specified index.
|
* Searches the annotations of 'clazz' for an extended class 'rawClass' and returns the class of the actual generics
|
||||||
|
* parameter at the specified index.
|
||||||
*
|
*
|
||||||
* @param clazz a class which implements the generic interface 'rawClass'
|
* @param clazz a class which implements the generic interface 'rawClass'
|
||||||
* @param rawClass a generic class
|
* @param rawClass a generic class
|
||||||
* @param paramIndex the index of the generics parameter within 'rawClass'
|
* @param paramIndex the index of the generics parameter within 'rawClass'
|
||||||
* @param <T> the expected class of the generics parameter at position 'index' in 'rawClass'
|
* @param <T> the expected class of the generics parameter at position 'index' in 'rawClass'
|
||||||
* @return the actual generics parameter
|
* @return the actual generics parameter
|
||||||
*/
|
*/
|
||||||
public static <T> Class<T> determineGenericClassParameter(final Class<?> clazz, final Class<?> rawClass, final int paramIndex) {
|
public static <T> Class<T> determineGenericClassParameter(
|
||||||
|
final Class<?> clazz,
|
||||||
|
final Class<?> rawClass,
|
||||||
|
final int paramIndex) {
|
||||||
final Class<T> found = determineGenericClassParameterImpl(clazz, rawClass, paramIndex);
|
final Class<T> found = determineGenericClassParameterImpl(clazz, rawClass, paramIndex);
|
||||||
if (found == null) {
|
if (found == null) {
|
||||||
throw new AssertionError(clazz.getSimpleName() + " expected to extend " + rawClass.getSimpleName() + "<...>");
|
throw new AssertionError(clazz.getSimpleName() + " expected to extend " + rawClass.getSimpleName() + "<...>");
|
||||||
@ -97,7 +109,10 @@ public class ReflectionUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static <T> Class<T> determineGenericClassParameterImpl(final Class<?> clazz, final Class<?> rawClass, final int paramIndex) {
|
private static <T> Class<T> determineGenericClassParameterImpl(
|
||||||
|
final Class<?> clazz,
|
||||||
|
final Class<?> rawClass,
|
||||||
|
final int paramIndex) {
|
||||||
final Type genericClass = clazz.getGenericSuperclass();
|
final Type genericClass = clazz.getGenericSuperclass();
|
||||||
if (genericClass instanceof ParameterizedType) {
|
if (genericClass instanceof ParameterizedType) {
|
||||||
final ParameterizedType parameterizedType = (ParameterizedType) genericClass;
|
final ParameterizedType parameterizedType = (ParameterizedType) genericClass;
|
||||||
@ -118,6 +133,7 @@ public class ReflectionUtil {
|
|||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface ThrowingSupplier<T> {
|
public interface ThrowingSupplier<T> {
|
||||||
|
|
||||||
T get() throws Exception;
|
T get() throws Exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.web.rest;
|
package org.hostsharing.hsadminng.web.rest;
|
||||||
|
|
||||||
|
|
||||||
import org.hostsharing.hsadminng.domain.User;
|
import org.hostsharing.hsadminng.domain.User;
|
||||||
import org.hostsharing.hsadminng.repository.UserRepository;
|
import org.hostsharing.hsadminng.repository.UserRepository;
|
||||||
import org.hostsharing.hsadminng.security.SecurityUtils;
|
import org.hostsharing.hsadminng.security.SecurityUtils;
|
||||||
@ -18,9 +18,10 @@ import org.slf4j.LoggerFactory;
|
|||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* REST controller for managing the current user's account.
|
* REST controller for managing the current user's account.
|
||||||
@ -45,7 +46,7 @@ public class AccountResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST /register : register the user.
|
* POST /register : register the user.
|
||||||
*
|
*
|
||||||
* @param managedUserVM the managed user View Model
|
* @param managedUserVM the managed user View Model
|
||||||
* @throws InvalidPasswordException 400 (Bad Request) if the password is incorrect
|
* @throws InvalidPasswordException 400 (Bad Request) if the password is incorrect
|
||||||
@ -63,7 +64,7 @@ public class AccountResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GET /activate : activate the registered user.
|
* GET /activate : activate the registered user.
|
||||||
*
|
*
|
||||||
* @param key the activation key
|
* @param key the activation key
|
||||||
* @throws RuntimeException 500 (Internal Server Error) if the user couldn't be activated
|
* @throws RuntimeException 500 (Internal Server Error) if the user couldn't be activated
|
||||||
@ -77,7 +78,7 @@ public class AccountResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GET /authenticate : check if the user is authenticated, and return its login.
|
* GET /authenticate : check if the user is authenticated, and return its login.
|
||||||
*
|
*
|
||||||
* @param request the HTTP request
|
* @param request the HTTP request
|
||||||
* @return the login if the user is authenticated
|
* @return the login if the user is authenticated
|
||||||
@ -89,7 +90,7 @@ public class AccountResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GET /account : get the current user.
|
* GET /account : get the current user.
|
||||||
*
|
*
|
||||||
* @return the current user
|
* @return the current user
|
||||||
* @throws RuntimeException 500 (Internal Server Error) if the user couldn't be returned
|
* @throws RuntimeException 500 (Internal Server Error) if the user couldn't be returned
|
||||||
@ -97,12 +98,12 @@ public class AccountResource {
|
|||||||
@GetMapping("/account")
|
@GetMapping("/account")
|
||||||
public UserDTO getAccount() {
|
public UserDTO getAccount() {
|
||||||
return userService.getUserWithAuthorities()
|
return userService.getUserWithAuthorities()
|
||||||
.map(UserDTO::new)
|
.map(UserDTO::new)
|
||||||
.orElseThrow(() -> new InternalServerErrorException("User could not be found"));
|
.orElseThrow(() -> new InternalServerErrorException("User could not be found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST /account : update the current user information.
|
* POST /account : update the current user information.
|
||||||
*
|
*
|
||||||
* @param userDTO the current user information
|
* @param userDTO the current user information
|
||||||
* @throws EmailAlreadyUsedException 400 (Bad Request) if the email is already used
|
* @throws EmailAlreadyUsedException 400 (Bad Request) if the email is already used
|
||||||
@ -110,7 +111,8 @@ public class AccountResource {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/account")
|
@PostMapping("/account")
|
||||||
public void saveAccount(@Valid @RequestBody UserDTO userDTO) {
|
public void saveAccount(@Valid @RequestBody UserDTO userDTO) {
|
||||||
String userLogin = SecurityUtils.getCurrentUserLogin().orElseThrow(() -> new InternalServerErrorException("Current user login not found"));
|
String userLogin = SecurityUtils.getCurrentUserLogin()
|
||||||
|
.orElseThrow(() -> new InternalServerErrorException("Current user login not found"));
|
||||||
Optional<User> existingUser = userRepository.findOneByEmailIgnoreCase(userDTO.getEmail());
|
Optional<User> existingUser = userRepository.findOneByEmailIgnoreCase(userDTO.getEmail());
|
||||||
if (existingUser.isPresent() && (!existingUser.get().getLogin().equalsIgnoreCase(userLogin))) {
|
if (existingUser.isPresent() && (!existingUser.get().getLogin().equalsIgnoreCase(userLogin))) {
|
||||||
throw new EmailAlreadyUsedException();
|
throw new EmailAlreadyUsedException();
|
||||||
@ -119,12 +121,16 @@ public class AccountResource {
|
|||||||
if (!user.isPresent()) {
|
if (!user.isPresent()) {
|
||||||
throw new InternalServerErrorException("User could not be found");
|
throw new InternalServerErrorException("User could not be found");
|
||||||
}
|
}
|
||||||
userService.updateUser(userDTO.getFirstName(), userDTO.getLastName(), userDTO.getEmail(),
|
userService.updateUser(
|
||||||
userDTO.getLangKey(), userDTO.getImageUrl());
|
userDTO.getFirstName(),
|
||||||
|
userDTO.getLastName(),
|
||||||
|
userDTO.getEmail(),
|
||||||
|
userDTO.getLangKey(),
|
||||||
|
userDTO.getImageUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST /account/change-password : changes the current user's password
|
* POST /account/change-password : changes the current user's password
|
||||||
*
|
*
|
||||||
* @param passwordChangeDto current and new password
|
* @param passwordChangeDto current and new password
|
||||||
* @throws InvalidPasswordException 400 (Bad Request) if the new password is incorrect
|
* @throws InvalidPasswordException 400 (Bad Request) if the new password is incorrect
|
||||||
@ -138,21 +144,20 @@ public class AccountResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST /account/reset-password/init : Send an email to reset the password of the user
|
* POST /account/reset-password/init : Send an email to reset the password of the user
|
||||||
*
|
*
|
||||||
* @param mail the mail of the user
|
* @param mail the mail of the user
|
||||||
* @throws EmailNotFoundException 400 (Bad Request) if the email address is not registered
|
* @throws EmailNotFoundException 400 (Bad Request) if the email address is not registered
|
||||||
*/
|
*/
|
||||||
@PostMapping(path = "/account/reset-password/init")
|
@PostMapping(path = "/account/reset-password/init")
|
||||||
public void requestPasswordReset(@RequestBody String mail) {
|
public void requestPasswordReset(@RequestBody String mail) {
|
||||||
mailService.sendPasswordResetMail(
|
mailService.sendPasswordResetMail(
|
||||||
userService.requestPasswordReset(mail)
|
userService.requestPasswordReset(mail)
|
||||||
.orElseThrow(EmailNotFoundException::new)
|
.orElseThrow(EmailNotFoundException::new));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST /account/reset-password/finish : Finish to reset the password of the user
|
* POST /account/reset-password/finish : Finish to reset the password of the user
|
||||||
*
|
*
|
||||||
* @param keyAndPassword the generated key and the new password
|
* @param keyAndPassword the generated key and the new password
|
||||||
* @throws InvalidPasswordException 400 (Bad Request) if the password is incorrect
|
* @throws InvalidPasswordException 400 (Bad Request) if the password is incorrect
|
||||||
@ -163,8 +168,7 @@ public class AccountResource {
|
|||||||
if (!checkPasswordLength(keyAndPassword.getNewPassword())) {
|
if (!checkPasswordLength(keyAndPassword.getNewPassword())) {
|
||||||
throw new InvalidPasswordException();
|
throw new InvalidPasswordException();
|
||||||
}
|
}
|
||||||
Optional<User> user =
|
Optional<User> user = userService.completePasswordReset(keyAndPassword.getNewPassword(), keyAndPassword.getKey());
|
||||||
userService.completePasswordReset(keyAndPassword.getNewPassword(), keyAndPassword.getKey());
|
|
||||||
|
|
||||||
if (!user.isPresent()) {
|
if (!user.isPresent()) {
|
||||||
throw new InternalServerErrorException("No user was found for this reset key");
|
throw new InternalServerErrorException("No user was found for this reset key");
|
||||||
@ -173,7 +177,7 @@ public class AccountResource {
|
|||||||
|
|
||||||
private static boolean checkPasswordLength(String password) {
|
private static boolean checkPasswordLength(String password) {
|
||||||
return !StringUtils.isEmpty(password) &&
|
return !StringUtils.isEmpty(password) &&
|
||||||
password.length() >= ManagedUserVM.PASSWORD_MIN_LENGTH &&
|
password.length() >= ManagedUserVM.PASSWORD_MIN_LENGTH &&
|
||||||
password.length() <= ManagedUserVM.PASSWORD_MAX_LENGTH;
|
password.length() <= ManagedUserVM.PASSWORD_MAX_LENGTH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
// Licensed under Apache-2.0
|
||||||
package org.hostsharing.hsadminng.web.rest;
|
package org.hostsharing.hsadminng.web.rest;
|
||||||
|
|
||||||
import io.github.jhipster.web.util.ResponseUtil;
|
|
||||||
import org.hostsharing.hsadminng.service.AssetQueryService;
|
import org.hostsharing.hsadminng.service.AssetQueryService;
|
||||||
import org.hostsharing.hsadminng.service.AssetService;
|
import org.hostsharing.hsadminng.service.AssetService;
|
||||||
import org.hostsharing.hsadminng.service.dto.AssetCriteria;
|
import org.hostsharing.hsadminng.service.dto.AssetCriteria;
|
||||||
@ -8,6 +8,9 @@ import org.hostsharing.hsadminng.service.dto.AssetDTO;
|
|||||||
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
||||||
import org.hostsharing.hsadminng.web.rest.util.HeaderUtil;
|
import org.hostsharing.hsadminng.web.rest.util.HeaderUtil;
|
||||||
import org.hostsharing.hsadminng.web.rest.util.PaginationUtil;
|
import org.hostsharing.hsadminng.web.rest.util.PaginationUtil;
|
||||||
|
|
||||||
|
import io.github.jhipster.web.util.ResponseUtil;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@ -16,12 +19,13 @@ import org.springframework.http.HttpHeaders;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* REST controller for managing Asset.
|
* REST controller for managing Asset.
|
||||||
*/
|
*/
|
||||||
@ -43,10 +47,11 @@ public class AssetResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST /assets : Create a new asset.
|
* POST /assets : Create a new asset.
|
||||||
*
|
*
|
||||||
* @param assetDTO the assetDTO to create
|
* @param assetDTO the assetDTO to create
|
||||||
* @return the ResponseEntity with status 201 (Created) and with body the new assetDTO, or with status 400 (Bad Request) if the asset has already an ID
|
* @return the ResponseEntity with status 201 (Created) and with body the new assetDTO, or with status 400 (Bad Request) if
|
||||||
|
* the asset has already an ID
|
||||||
* @throws URISyntaxException if the Location URI syntax is incorrect
|
* @throws URISyntaxException if the Location URI syntax is incorrect
|
||||||
*/
|
*/
|
||||||
@PostMapping("/assets")
|
@PostMapping("/assets")
|
||||||
@ -57,17 +62,17 @@ public class AssetResource {
|
|||||||
}
|
}
|
||||||
AssetDTO result = assetService.save(assetDTO);
|
AssetDTO result = assetService.save(assetDTO);
|
||||||
return ResponseEntity.created(new URI("/api/assets/" + result.getId()))
|
return ResponseEntity.created(new URI("/api/assets/" + result.getId()))
|
||||||
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
|
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
|
||||||
.body(result);
|
.body(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PUT /assets : Updates an existing asset.
|
* PUT /assets : Updates an existing asset.
|
||||||
*
|
*
|
||||||
* @param assetDTO the assetDTO to update
|
* @param assetDTO the assetDTO to update
|
||||||
* @return the ResponseEntity with status 200 (OK) and with body the updated assetDTO,
|
* @return the ResponseEntity with status 200 (OK) and with body the updated assetDTO,
|
||||||
* or with status 400 (Bad Request) if the assetDTO is not valid,
|
* or with status 400 (Bad Request) if the assetDTO is not valid,
|
||||||
* or with status 500 (Internal Server Error) if the assetDTO couldn't be updated
|
* or with status 500 (Internal Server Error) if the assetDTO couldn't be updated
|
||||||
* @throws URISyntaxException if the Location URI syntax is incorrect
|
* @throws URISyntaxException if the Location URI syntax is incorrect
|
||||||
*/
|
*/
|
||||||
@PutMapping("/assets")
|
@PutMapping("/assets")
|
||||||
@ -78,7 +83,7 @@ public class AssetResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GET /assets : get all the assets.
|
* GET /assets : get all the assets.
|
||||||
*
|
*
|
||||||
* @param pageable the pagination information
|
* @param pageable the pagination information
|
||||||
* @param criteria the criterias which the requested entities should match
|
* @param criteria the criterias which the requested entities should match
|
||||||
@ -93,11 +98,11 @@ public class AssetResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GET /assets/count : count all the assets.
|
* GET /assets/count : count all the assets.
|
||||||
*
|
*
|
||||||
* @param criteria the criterias which the requested entities should match
|
* @param criteria the criterias which the requested entities should match
|
||||||
* @return the ResponseEntity with status 200 (OK) and the count in body
|
* @return the ResponseEntity with status 200 (OK) and the count in body
|
||||||
*/
|
*/
|
||||||
@GetMapping("/assets/count")
|
@GetMapping("/assets/count")
|
||||||
public ResponseEntity<Long> countAssets(AssetCriteria criteria) {
|
public ResponseEntity<Long> countAssets(AssetCriteria criteria) {
|
||||||
log.debug("REST request to count Assets by criteria: {}", criteria);
|
log.debug("REST request to count Assets by criteria: {}", criteria);
|
||||||
@ -105,7 +110,7 @@ public class AssetResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GET /assets/:id : get the "id" asset.
|
* GET /assets/:id : get the "id" asset.
|
||||||
*
|
*
|
||||||
* @param id the id of the assetDTO to retrieve
|
* @param id the id of the assetDTO to retrieve
|
||||||
* @return the ResponseEntity with status 200 (OK) and with body the assetDTO, or with status 404 (Not Found)
|
* @return the ResponseEntity with status 200 (OK) and with body the assetDTO, or with status 404 (Not Found)
|
||||||
@ -118,7 +123,7 @@ public class AssetResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DELETE /assets/:id : delete the "id" asset.
|
* DELETE /assets/:id : delete the "id" asset.
|
||||||
*
|
*
|
||||||
* @param id the id of the assetDTO to delete
|
* @param id the id of the assetDTO to delete
|
||||||
* @return the ResponseEntity with status 200 (OK)
|
* @return the ResponseEntity with status 200 (OK)
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user