update permissionmappings
This commit is contained in:
parent
bfc335703c
commit
aa79839a00
@ -280,6 +280,14 @@ public class PermissionManager implements UserDataProvider {
|
|||||||
Instant permissionStarts = starts;
|
Instant permissionStarts = starts;
|
||||||
Instant permissionsExpires = expires;
|
Instant permissionsExpires = expires;
|
||||||
|
|
||||||
|
if (permissionMapping.getStarts() != null) {
|
||||||
|
permissionStarts = permissionMapping.getStarts();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (permissionMapping.getExpires() != null) {
|
||||||
|
permissionsExpires = permissionMapping.getExpires();
|
||||||
|
}
|
||||||
|
|
||||||
if (permissionMapping.isLifetimeRound()) {
|
if (permissionMapping.isLifetimeRound()) {
|
||||||
permissionStarts = InstantHelper.truncate(permissionStarts,
|
permissionStarts = InstantHelper.truncate(permissionStarts,
|
||||||
permissionMapping.getLifetimeUnit());
|
permissionMapping.getLifetimeUnit());
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.bstly.we.businesslogic;
|
package de.bstly.we.businesslogic;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -90,10 +91,13 @@ public class PermissionMappingManager {
|
|||||||
*/
|
*/
|
||||||
public PermissionMapping create(Integer item, Set<String> names, Long lifetime,
|
public PermissionMapping create(Integer item, Set<String> names, Long lifetime,
|
||||||
ChronoUnit lifetimeUnit, boolean lifetimeRound, boolean addon, String product,
|
ChronoUnit lifetimeUnit, boolean lifetimeRound, boolean addon, String product,
|
||||||
String startsQuestion, String expiresQuestion) {
|
Instant starts, Instant expires, String startsQuestion, String expiresQuestion) {
|
||||||
for (String name : names) {
|
for (String name : names) {
|
||||||
Assert.isTrue(!exists(item, name), "PermissionMapping for item '" + item
|
Assert.isTrue(!exists(item, name), "PermissionMapping for item '"
|
||||||
+ "' with permission '" + name + "' already exists!");
|
+ item
|
||||||
|
+ "' with permission '"
|
||||||
|
+ name
|
||||||
|
+ "' already exists!");
|
||||||
}
|
}
|
||||||
PermissionMapping permissionMapping = new PermissionMapping();
|
PermissionMapping permissionMapping = new PermissionMapping();
|
||||||
permissionMapping.setItem(item);
|
permissionMapping.setItem(item);
|
||||||
@ -103,6 +107,8 @@ public class PermissionMappingManager {
|
|||||||
permissionMapping.setLifetimeRound(lifetimeRound);
|
permissionMapping.setLifetimeRound(lifetimeRound);
|
||||||
permissionMapping.setAddon(addon);
|
permissionMapping.setAddon(addon);
|
||||||
permissionMapping.setProduct(product);
|
permissionMapping.setProduct(product);
|
||||||
|
permissionMapping.setStarts(starts);
|
||||||
|
permissionMapping.setExpires(expires);
|
||||||
permissionMapping.setStartsQuestion(startsQuestion);
|
permissionMapping.setStartsQuestion(startsQuestion);
|
||||||
permissionMapping.setExpiresQuestion(expiresQuestion);
|
permissionMapping.setExpiresQuestion(expiresQuestion);
|
||||||
return permissionMappingRepository.save(permissionMapping);
|
return permissionMappingRepository.save(permissionMapping);
|
||||||
@ -124,8 +130,9 @@ public class PermissionMappingManager {
|
|||||||
* @param id the id
|
* @param id the id
|
||||||
*/
|
*/
|
||||||
public void delete(Long id) {
|
public void delete(Long id) {
|
||||||
Assert.isTrue(permissionMappingRepository.existsById(id),
|
Assert.isTrue(permissionMappingRepository.existsById(id), "Permission Mapping '"
|
||||||
"Permission Mapping '" + id + "' does not exists!");
|
+ id
|
||||||
|
+ "' does not exists!");
|
||||||
PermissionMapping permissionMapping = permissionMappingRepository.findById(id).get();
|
PermissionMapping permissionMapping = permissionMappingRepository.findById(id).get();
|
||||||
permissionMappingRepository.delete(permissionMapping);
|
permissionMappingRepository.delete(permissionMapping);
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,8 @@ public class PermissionMappingController extends BaseController {
|
|||||||
public Page<PermissionMapping> getPermissionMappings(
|
public Page<PermissionMapping> getPermissionMappings(
|
||||||
@RequestParam("page") Optional<Integer> pageParameter,
|
@RequestParam("page") Optional<Integer> pageParameter,
|
||||||
@RequestParam("size") Optional<Integer> sizeParameter) {
|
@RequestParam("size") Optional<Integer> sizeParameter) {
|
||||||
return permissionMappingManager.get(pageParameter.orElse(0), sizeParameter.orElse(10), "item", true);
|
return permissionMappingManager.get(pageParameter.orElse(0), sizeParameter.orElse(10),
|
||||||
|
"item", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,6 +75,7 @@ public class PermissionMappingController extends BaseController {
|
|||||||
permissionMapping.getNames(), permissionMapping.getLifetime(),
|
permissionMapping.getNames(), permissionMapping.getLifetime(),
|
||||||
permissionMapping.getLifetimeUnit(), permissionMapping.isLifetimeRound(),
|
permissionMapping.getLifetimeUnit(), permissionMapping.isLifetimeRound(),
|
||||||
permissionMapping.isAddon(), permissionMapping.getProduct(),
|
permissionMapping.isAddon(), permissionMapping.getProduct(),
|
||||||
|
permissionMapping.getStarts(), permissionMapping.getExpires(),
|
||||||
permissionMapping.getStartsQuestion(), permissionMapping.getExpiresQuestion());
|
permissionMapping.getStartsQuestion(), permissionMapping.getExpiresQuestion());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,6 +101,7 @@ public class PermissionMappingController extends BaseController {
|
|||||||
permissionMapping.getNames(), permissionMapping.getLifetime(),
|
permissionMapping.getNames(), permissionMapping.getLifetime(),
|
||||||
permissionMapping.getLifetimeUnit(), permissionMapping.isLifetimeRound(),
|
permissionMapping.getLifetimeUnit(), permissionMapping.isLifetimeRound(),
|
||||||
permissionMapping.isAddon(), permissionMapping.getProduct(),
|
permissionMapping.isAddon(), permissionMapping.getProduct(),
|
||||||
|
permissionMapping.getStarts(), permissionMapping.getExpires(),
|
||||||
permissionMapping.getStartsQuestion(), permissionMapping.getExpiresQuestion()));
|
permissionMapping.getStartsQuestion(), permissionMapping.getExpiresQuestion()));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.bstly.we.model;
|
package de.bstly.we.model;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -51,6 +52,10 @@ public class PermissionMapping {
|
|||||||
private ChronoUnit lifetimeUnit = DEFAULT_LIFETIME_UNIT;
|
private ChronoUnit lifetimeUnit = DEFAULT_LIFETIME_UNIT;
|
||||||
@Column(name = "lifetime_round", columnDefinition = "boolean default false")
|
@Column(name = "lifetime_round", columnDefinition = "boolean default false")
|
||||||
private boolean lifetimeRound;
|
private boolean lifetimeRound;
|
||||||
|
@Column(name = "starts")
|
||||||
|
private Instant starts;
|
||||||
|
@Column(name = "expires")
|
||||||
|
private Instant expires;
|
||||||
@Column(name = "starts_question")
|
@Column(name = "starts_question")
|
||||||
private String startsQuestion;
|
private String startsQuestion;
|
||||||
@Column(name = "expires_question")
|
@Column(name = "expires_question")
|
||||||
@ -200,6 +205,34 @@ public class PermissionMapping {
|
|||||||
this.lifetimeRound = lifetimeRound;
|
this.lifetimeRound = lifetimeRound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the starts
|
||||||
|
*/
|
||||||
|
public Instant getStarts() {
|
||||||
|
return starts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param starts the starts to set
|
||||||
|
*/
|
||||||
|
public void setStarts(Instant starts) {
|
||||||
|
this.starts = starts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the expires
|
||||||
|
*/
|
||||||
|
public Instant getExpires() {
|
||||||
|
return expires;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param expires the expires to set
|
||||||
|
*/
|
||||||
|
public void setExpires(Instant expires) {
|
||||||
|
this.expires = expires;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the starts question.
|
* Gets the starts question.
|
||||||
*
|
*
|
||||||
@ -243,7 +276,8 @@ public class PermissionMapping {
|
|||||||
public static class ChronoUnitConverter implements AttributeConverter<ChronoUnit, String> {
|
public static class ChronoUnitConverter implements AttributeConverter<ChronoUnit, String> {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see javax.persistence.AttributeConverter#convertToDatabaseColumn(java.lang.Object)
|
* @see javax.persistence.AttributeConverter#convertToDatabaseColumn(java.lang.
|
||||||
|
* Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String convertToDatabaseColumn(ChronoUnit chronoUnit) {
|
public String convertToDatabaseColumn(ChronoUnit chronoUnit) {
|
||||||
@ -251,7 +285,8 @@ public class PermissionMapping {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see javax.persistence.AttributeConverter#convertToEntityAttribute(java.lang.Object)
|
* @see javax.persistence.AttributeConverter#convertToEntityAttribute(java.lang.
|
||||||
|
* Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ChronoUnit convertToEntityAttribute(String value) {
|
public ChronoUnit convertToEntityAttribute(String value) {
|
||||||
|
4
pom.xml
4
pom.xml
@ -12,8 +12,8 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<java.version>11</java.version>
|
<java.version>11</java.version>
|
||||||
<log4j2.version>2.15.0</log4j2.version>
|
<log4j2.version>2.16.0</log4j2.version>
|
||||||
<revision>1.4.5-SNAPSHOT</revision>
|
<revision>1.4.6-SNAPSHOT</revision>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
Loading…
Reference in New Issue
Block a user