Skip to content

Commit 47b1df0

Browse files
committed
fixes after review
1 parent 1810062 commit 47b1df0

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/main/java/com/odysseusinc/arachne/datanode/config/HibernateValidatorJpaConfig.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ protected void customizeVendorProperties(Map<String, Object> vendorProperties) {
5252

5353
super.customizeVendorProperties(vendorProperties);
5454
if (Objects.nonNull(validator)) {
55+
/*
56+
This is required since Hibernate uses it's own validator factory by default
57+
which instantiates validator from constructor rather than getting it from application context.
58+
As custom validation that requires dependency injection is used for DataNode entity object
59+
then LocalSpringContextValidatorFactory should be used by hibernate and that's exactly
60+
that the following parameter does.
61+
As
62+
*/
5563
vendorProperties.put("javax.persistence.validation.factory", validator);
5664
}
5765
}

src/main/java/com/odysseusinc/arachne/datanode/model/datanode/validation/DataNodeTokenValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void initialize(NonEmptyToken nonEmptyToken) {
4343
@Override
4444
public boolean isValid(DataNode dataNode, ConstraintValidatorContext context) {
4545

46-
if (FunctionalMode.NETWORK.equals(dataNodeService.getDataNodeMode())) {
46+
if (FunctionalMode.NETWORK == dataNodeService.getDataNodeMode()) {
4747
boolean valid = Objects.nonNull(dataNode) && StringUtils.isNotBlank(dataNode.getToken());
4848
if (!valid) {
4949
context.disableDefaultConstraintViolation();

src/main/java/com/odysseusinc/arachne/datanode/service/impl/DataNodeServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public DataNode create(User user, DataNode dataNode) throws AlreadyExistsExcepti
8383
if (currentDataNode.isPresent()) {
8484
throw new AlreadyExistsException(ALREADY_EXISTS_EXCEPTION);
8585
}
86-
if (getDataNodeMode().equals(FunctionalMode.NETWORK)) {
86+
if (FunctionalMode.NETWORK == getDataNodeMode()) {
8787
dataNode = centralIntegrationService.sendDataNodeCreationRequest(user, dataNode);
8888
}
8989
return dataNodeRepository.save(dataNode);

0 commit comments

Comments
 (0)