Skip to content
Snippets Groups Projects
Commit 742ab9c7 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-4949 Changed Validator registration

parent 209a52e8
Branches
Tags
No related merge requests found
package de.ozgcloud.admin.settings; package de.ozgcloud.admin.settings;
import java.util.Map;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.rest.core.event.ValidatingRepositoryEventListener; import org.springframework.data.rest.core.event.ValidatingRepositoryEventListener;
import org.springframework.validation.Validator; import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer;
@Configuration @Configuration
public class ValidatorEventRegister implements InitializingBean { public class DataRestConfiguration implements RepositoryRestConfigurer {
@Autowired
ValidatingRepositoryEventListener validatingRepositoryEventListener;
@Autowired @Autowired
private Map<String, Validator> validators; private SettingsValidator settingsValidator;
@Override @Override
public void afterPropertiesSet() throws Exception { public void configureValidatingRepositoryEventListener(ValidatingRepositoryEventListener v) {
validatingRepositoryEventListener.addValidator("beforeSave", validators.get("settingsValidator")); v.addValidator("beforeSave", settingsValidator);
validatingRepositoryEventListener.addValidator("beforeCreate", validators.get("settingsValidator")); v.addValidator("beforeCreate", settingsValidator);
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment