2
0

Fix default type for new sites & site UI updating.

This commit is contained in:
Maarten Billemont
2018-07-29 15:10:45 -04:00
parent 928b617ed0
commit fe63a2756a
11 changed files with 62 additions and 33 deletions

View File

@@ -46,6 +46,11 @@ public interface MPUser<S extends MPSite<?>> extends Comparable<MPUser<?>> {
void setAlgorithm(MPAlgorithm algorithm);
@Nullable
default MPResultType getDefaultType() {
return null;
}
@Nullable
byte[] getKeyID();

View File

@@ -44,19 +44,20 @@ public abstract class MPBasicSite<U extends MPUser<?>, Q extends MPQuestion> ext
private MPResultType resultType;
private MPResultType loginType;
protected MPBasicSite(final U user, final String siteName, final MPAlgorithm algorithm) {
this( user, siteName, algorithm, null, null, null );
protected MPBasicSite(final U user, final String siteName) {
this( user, siteName, null, null, null, null );
}
protected MPBasicSite(final U user, final String siteName, final MPAlgorithm algorithm,
@Nullable final UnsignedInteger counter,
protected MPBasicSite(final U user, final String siteName,
@Nullable final MPAlgorithm algorithm, @Nullable final UnsignedInteger counter,
@Nullable final MPResultType resultType, @Nullable final MPResultType loginType) {
this.user = user;
this.siteName = siteName;
this.algorithm = algorithm;
this.counter = (counter == null)? algorithm.mpw_default_counter(): counter;
this.resultType = (resultType == null)? algorithm.mpw_default_result_type(): resultType;
this.loginType = (loginType == null)? algorithm.mpw_default_login_type(): loginType;
this.algorithm = (algorithm != null)? algorithm: this.user.getAlgorithm();
this.counter = (counter != null)? counter: this.algorithm.mpw_default_counter();
this.resultType = (resultType != null)? resultType:
ifNotNullElse( this.user.getDefaultType(), this.algorithm.mpw_default_result_type() );
this.loginType = (loginType != null)? loginType: this.algorithm.mpw_default_login_type();
}
@Nonnull
@@ -73,7 +74,7 @@ public abstract class MPBasicSite<U extends MPUser<?>, Q extends MPQuestion> ext
@Override
public void setAlgorithm(final MPAlgorithm algorithm) {
if (Objects.equals(this.algorithm, algorithm))
if (Objects.equals( this.algorithm, algorithm ))
return;
this.algorithm = algorithm;
@@ -88,7 +89,7 @@ public abstract class MPBasicSite<U extends MPUser<?>, Q extends MPQuestion> ext
@Override
public void setCounter(final UnsignedInteger counter) {
if (Objects.equals(this.counter, counter))
if (Objects.equals( this.counter, counter ))
return;
this.counter = counter;
@@ -103,7 +104,7 @@ public abstract class MPBasicSite<U extends MPUser<?>, Q extends MPQuestion> ext
@Override
public void setResultType(final MPResultType resultType) {
if (Objects.equals(this.resultType, resultType))
if (Objects.equals( this.resultType, resultType ))
return;
this.resultType = resultType;
@@ -118,7 +119,7 @@ public abstract class MPBasicSite<U extends MPUser<?>, Q extends MPQuestion> ext
@Override
public void setLoginType(@Nullable final MPResultType loginType) {
if (Objects.equals(this.loginType, loginType))
if (Objects.equals( this.loginType, loginType ))
return;
this.loginType = ifNotNullElse( loginType, getAlgorithm().mpw_default_login_type() );

View File

@@ -45,14 +45,8 @@ public class MPFileSite extends MPBasicSite<MPFileUser, MPFileQuestion> {
private String loginState;
public MPFileSite(final MPFileUser user, final String name) {
this( user, name, null, null, null );
}
public MPFileSite(final MPFileUser user, final String name,
@Nullable final MPAlgorithm algorithm, @Nullable final UnsignedInteger counter,
@Nullable final MPResultType resultType) {
this( user, name, algorithm, counter, resultType, null,
null, null, null, 0, new Instant() );
this( user, name, null, null, null, null, null, null,
null, 0, new Instant() );
}
protected MPFileSite(final MPFileUser user, final String name,
@@ -60,8 +54,7 @@ public class MPFileSite extends MPBasicSite<MPFileUser, MPFileQuestion> {
@Nullable final MPResultType resultType, @Nullable final String resultState,
@Nullable final MPResultType loginType, @Nullable final String loginState,
@Nullable final String url, final int uses, final ReadableInstant lastUsed) {
super( user, name, (algorithm == null)? user.getAlgorithm(): algorithm, counter,
(resultType == null)? user.getDefaultType(): resultType, loginType );
super( user, name, algorithm, counter, resultType, loginType );
this.resultState = resultState;
this.loginState = loginState;

View File

@@ -135,6 +135,7 @@ public class MPFileUser extends MPBasicUser<MPFileSite> {
setChanged();
}
@Override
public MPResultType getDefaultType() {
return defaultType;
}