-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #691 from IDgis/690-unique-name-validation
unique name validation moved to service
- Loading branch information
Showing
7 changed files
with
399 additions
and
273 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
publisher-domain/src/main/java/nl/idgis/publisher/domain/query/ValidateUniqueName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package nl.idgis.publisher.domain.query; | ||
|
||
import java.util.Objects; | ||
|
||
import nl.idgis.publisher.domain.response.UniqueNameValidationResult; | ||
|
||
public class ValidateUniqueName implements DomainQuery<UniqueNameValidationResult> { | ||
|
||
private static final long serialVersionUID = -8948822157181419535L; | ||
|
||
private final String name; | ||
|
||
public ValidateUniqueName(String name) { | ||
this.name = Objects.requireNonNull(name); | ||
} | ||
|
||
public String name() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ValidateUniqueName [name=" + name + "]"; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...r-domain/src/main/java/nl/idgis/publisher/domain/response/UniqueNameValidationResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package nl.idgis.publisher.domain.response; | ||
|
||
import java.util.Objects; | ||
|
||
public class UniqueNameValidationResult implements ValidationResult { | ||
|
||
private static final long serialVersionUID = -3800481429856190153L; | ||
|
||
public enum ConflictType { | ||
LAYER, | ||
LAYERGROUP, | ||
SERVICE | ||
} | ||
|
||
private final ConflictType conflictType; | ||
|
||
private UniqueNameValidationResult(ConflictType conflictType) { | ||
this.conflictType = conflictType; | ||
} | ||
|
||
public static UniqueNameValidationResult valid() { | ||
return new UniqueNameValidationResult(null); | ||
} | ||
|
||
public static UniqueNameValidationResult conflict(ConflictType conflictType) { | ||
return new UniqueNameValidationResult(Objects.requireNonNull(conflictType, "conflict type missing")); | ||
} | ||
|
||
public boolean isValid() { | ||
return conflictType == null; | ||
} | ||
|
||
public ConflictType conflictType() { | ||
if(conflictType == null) { | ||
throw new IllegalStateException("no conflict"); | ||
} | ||
|
||
return conflictType; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "UniqueNameValidationResult [conflictType=" + conflictType + "]"; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
publisher-domain/src/main/java/nl/idgis/publisher/domain/response/ValidationResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package nl.idgis.publisher.domain.response; | ||
|
||
import java.io.Serializable; | ||
|
||
public interface ValidationResult extends Serializable { | ||
|
||
boolean isValid(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.