Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue-1143: Improving RoutingRuleForm.
- Loading branch information
1 parent
99cea4f
commit 1000f06
Showing
15 changed files
with
594 additions
and
122 deletions.
There are no files selected for viewing
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
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
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
200 changes: 132 additions & 68 deletions
200
...web-core/src/main/java/org/carlspring/strongbox/controllers/forms/FormDataController.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
60 changes: 60 additions & 0 deletions
60
...spring/strongbox/validation/configuration/routing/RoutingRuleRepositoryFormValidator.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,60 @@ | ||
package org.carlspring.strongbox.validation.configuration.routing; | ||
|
||
import org.carlspring.strongbox.forms.storage.routing.RoutingRuleRepositoryForm; | ||
import org.carlspring.strongbox.services.ConfigurationManagementService; | ||
|
||
import javax.inject.Inject; | ||
import javax.validation.ConstraintValidator; | ||
import javax.validation.ConstraintValidatorContext; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
public class RoutingRuleRepositoryFormValidator | ||
implements ConstraintValidator<RoutingRuleRepositoryFormValid, RoutingRuleRepositoryForm> | ||
{ | ||
|
||
@Inject | ||
private ConfigurationManagementService configurationManagementService; | ||
|
||
private String message; | ||
|
||
@Override | ||
public void initialize(RoutingRuleRepositoryFormValid constraintAnnotation) | ||
{ | ||
message = constraintAnnotation.message(); | ||
} | ||
|
||
@Override | ||
public boolean isValid(RoutingRuleRepositoryForm form, | ||
ConstraintValidatorContext context) | ||
{ | ||
Boolean valid = false; | ||
|
||
try | ||
{ | ||
String storageIdValue = StringUtils.trimToNull(form.getStorageId()); | ||
String repositoryIdValue = StringUtils.trimToNull(form.getRepositoryId()); | ||
|
||
if (storageIdValue == null && repositoryIdValue == null) | ||
{ | ||
context.disableDefaultConstraintViolation(); | ||
context.buildConstraintViolationWithTemplate(message) | ||
.addPropertyNode("storageId") | ||
.addConstraintViolation(); | ||
context.buildConstraintViolationWithTemplate(message) | ||
.addPropertyNode("repositoryId") | ||
.addConstraintViolation(); | ||
} | ||
else | ||
{ | ||
valid = true; | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
e.printStackTrace(); | ||
} | ||
|
||
return valid; | ||
} | ||
} |
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.