administrationConfigs = newLinkedHashSet();
+ for (String configurationsBasePackage : configurationsBasePackages()) {
+ administrationConfigs.addAll(classScanner.scan(configurationsBasePackage));
+ }
+
+ return administrationConfigs;
+ }
+
+ private String[] configurationsBasePackages() {
+ return tokenizeToStringArray(basePackage, CONFIG_LOCATION_DELIMITERS);
+ }
+
+ private String beanName(Class type) {
+ return nameGenerator.generateBeanNameDecapitalized(type);
+ }
+
+ @Override
+ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
+ }
}
\ No newline at end of file
diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/config/context/LightAdminRepositoryRestConfigurer.java b/lightadmin-core/src/main/java/org/lightadmin/core/config/context/LightAdminRepositoryRestConfigurer.java
new file mode 100644
index 00000000..f8e77c71
--- /dev/null
+++ b/lightadmin-core/src/main/java/org/lightadmin/core/config/context/LightAdminRepositoryRestConfigurer.java
@@ -0,0 +1,83 @@
+/**
+ *
+ */
+package org.lightadmin.core.config.context;
+
+import org.lightadmin.core.config.LightAdminConfiguration;
+import org.lightadmin.core.config.domain.GlobalAdministrationConfiguration;
+import org.lightadmin.core.web.json.LightAdminJacksonModule;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.ListableBeanFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
+import org.springframework.data.rest.core.event.ValidatingRepositoryEventListener;
+import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer;
+import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurerAdapter;
+import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;
+import org.springframework.validation.Validator;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+/**
+ * {@link RepositoryRestConfigurer} for LightAdmin
.
+ *
+ * Spring Data Web requires the configurations to be moved out of {@link RepositoryRestMvcConfiguration}
+ * and are configured through RepositoryRestConfigurer
beans
+ * configured in the context. That's why these configurations are moved out from
+ * {@link LightAdminRepositoryRestMvcConfiguration} and placed in a separate
+ * RepositoryRestConfigurer
class, which is then configured as a
+ * bean in the LightAdminRepositoryRestMvcConfiguration
.
+ *
+ * @author Gazi Rahman
+ *
+ */
+@Configuration
+public class LightAdminRepositoryRestConfigurer extends RepositoryRestConfigurerAdapter
+ implements RepositoryRestConfigurer {
+ private static Logger logger = LoggerFactory.getLogger(LightAdminRepositoryRestConfigurer.class);
+
+ @Autowired
+ private ListableBeanFactory beanFactory;
+
+ /**
+ *
+ */
+ public LightAdminRepositoryRestConfigurer() {
+ logger.debug("LightAdminRepositoryRestConfigurer instantiated");
+ }
+
+ @Override
+ public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
+ config.setDefaultPageSize(10);
+ config.setBasePath(lightAdminConfiguration().getApplicationRestBasePath());
+ config.exposeIdsFor(globalAdministrationConfiguration().getAllDomainTypesAsArray());
+ config.setReturnBodyOnCreate(true);
+ config.setReturnBodyOnUpdate(true);
+ }
+
+ @Override
+ public void configureValidatingRepositoryEventListener(ValidatingRepositoryEventListener validatingListener) {
+ validatingListener.addValidator("beforeCreate", validator());
+ validatingListener.addValidator("beforeSave", validator());
+ }
+
+ @Override
+ public void configureJacksonObjectMapper(ObjectMapper objectMapper) {
+ objectMapper.registerModule(new LightAdminJacksonModule(globalAdministrationConfiguration()));
+ }
+
+ private GlobalAdministrationConfiguration globalAdministrationConfiguration() {
+ return beanFactory.getBean(GlobalAdministrationConfiguration.class);
+ }
+
+ private LightAdminConfiguration lightAdminConfiguration() {
+ return beanFactory.getBean(LightAdminConfiguration.class);
+ }
+
+ private Validator validator() {
+ return beanFactory.getBean("validator", Validator.class);
+ }
+
+}
diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/config/context/LightAdminRepositoryRestMvcConfiguration.java b/lightadmin-core/src/main/java/org/lightadmin/core/config/context/LightAdminRepositoryRestMvcConfiguration.java
index e643bb56..7488ca83 100644
--- a/lightadmin-core/src/main/java/org/lightadmin/core/config/context/LightAdminRepositoryRestMvcConfiguration.java
+++ b/lightadmin-core/src/main/java/org/lightadmin/core/config/context/LightAdminRepositoryRestMvcConfiguration.java
@@ -1,185 +1,165 @@
-/*
- * Copyright 2012-2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.lightadmin.core.config.context;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.lightadmin.core.config.LightAdminConfiguration;
-import org.lightadmin.core.config.bootstrap.RepositoriesFactoryBean;
-import org.lightadmin.core.config.domain.GlobalAdministrationConfiguration;
-import org.lightadmin.core.persistence.repository.event.FileManipulationRepositoryEventListener;
-import org.lightadmin.core.persistence.repository.invoker.DynamicRepositoryInvokerFactory;
-import org.lightadmin.core.persistence.support.DynamicDomainObjectMerger;
-import org.lightadmin.core.storage.FileResourceStorage;
-import org.lightadmin.core.web.json.DomainTypeToJsonMetadataConverter;
-import org.lightadmin.core.web.json.LightAdminJacksonModule;
-import org.lightadmin.core.web.support.*;
-import org.springframework.beans.BeanInstantiationException;
-import org.springframework.beans.factory.ListableBeanFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.repository.support.Repositories;
-import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
-import org.springframework.data.rest.core.event.ValidatingRepositoryEventListener;
-import org.springframework.data.rest.core.invoke.RepositoryInvokerFactory;
-import org.springframework.data.rest.core.support.DomainObjectMerger;
-import org.springframework.data.rest.webmvc.RepositoryRestController;
-import org.springframework.data.rest.webmvc.config.PersistentEntityResourceAssemblerArgumentResolver;
-import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;
-import org.springframework.validation.Validator;
-import org.springframework.web.method.support.HandlerMethodArgumentResolver;
-import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
-
-import java.util.List;
-
-import static com.google.common.collect.Lists.newLinkedList;
-import static org.springframework.beans.PropertyAccessorFactory.forDirectFieldAccess;
-import static org.springframework.util.ClassUtils.isAssignableValue;
-
-@Configuration
-@ComponentScan(basePackages = {"org.lightadmin.core.web"},
- includeFilters = @ComponentScan.Filter(RepositoryRestController.class), useDefaultFilters = false)
-public class LightAdminRepositoryRestMvcConfiguration extends RepositoryRestMvcConfiguration {
-
- @Autowired
- private ListableBeanFactory beanFactory;
-
- @Bean
- public DomainEntityLinks domainEntityLinks() {
- return new DomainEntityLinks(globalAdministrationConfiguration(), backendIdConverterRegistry(), lightAdminConfiguration());
- }
-
- @Bean
- public DynamicRepositoryEntityLinks dynamicRepositoryEntityLinks() {
- return DynamicRepositoryEntityLinks.wrap(super.entityLinks());
- }
-
- @Bean
- public DynamicPersistentEntityResourceProcessor dynamicPersistentEntityResourceProcessor() {
- return new DynamicPersistentEntityResourceProcessor(globalAdministrationConfiguration(), fileResourceStorage(), dynamicRepositoryEntityLinks(), domainEntityLinks(), resourceMappings());
- }
-
- @Bean
- public DomainTypeToJsonMetadataConverter domainTypeToJsonMetadataConverter() {
- return new DomainTypeToJsonMetadataConverter(globalAdministrationConfiguration(), entityLinks());
- }
-
- @Bean
- public Repositories repositories() {
- try {
- return new RepositoriesFactoryBean(beanFactory).getObject();
- } catch (Exception e) {
- throw new BeanInstantiationException(Repositories.class, "Repositories bean instantiation problem!", e);
- }
- }
-
- @Bean
- public DomainObjectMerger domainObjectMerger() throws Exception {
- return new DynamicDomainObjectMerger(repositories(), defaultConversionService(), globalAdministrationConfiguration());
- }
-
- @Bean
- public RepositoryInvokerFactory repositoryInvokerFactory() {
- RepositoryInvokerFactory repositoryInvokerFactory = super.repositoryInvokerFactory();
-
- return new DynamicRepositoryInvokerFactory(repositories(), repositoryInvokerFactory);
- }
-
- @Bean
- public ConfigurationHandlerMethodArgumentResolver configurationHandlerMethodArgumentResolver() {
- return new ConfigurationHandlerMethodArgumentResolver(globalAdministrationConfiguration(), resourceMetadataHandlerMethodArgumentResolver());
- }
-
- @Bean
- @Autowired
- public FileManipulationRepositoryEventListener domainRepositoryEventListener(GlobalAdministrationConfiguration configuration, FileResourceStorage fileResourceStorage) {
- return new FileManipulationRepositoryEventListener(configuration, fileResourceStorage);
- }
-
- @Override
- protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
- config.setDefaultPageSize(10);
- config.setBaseUri(lightAdminConfiguration().getApplicationRestBaseUrl());
- config.exposeIdsFor(globalAdministrationConfiguration().getAllDomainTypesAsArray());
- config.setReturnBodyOnCreate(true);
- config.setReturnBodyOnUpdate(true);
- }
-
- @Override
- public RequestMappingHandlerAdapter repositoryExporterHandlerAdapter() {
- RequestMappingHandlerAdapter requestMappingHandlerAdapter = super.repositoryExporterHandlerAdapter();
- configureRepositoryExporterHandlerAdapter(requestMappingHandlerAdapter);
- return requestMappingHandlerAdapter;
- }
-
- @Override
- protected void configureValidatingRepositoryEventListener(ValidatingRepositoryEventListener validatingListener) {
- validatingListener.addValidator("beforeCreate", validator());
- validatingListener.addValidator("beforeSave", validator());
- }
-
- @Override
- public void addArgumentResolvers(List argumentResolvers) {
- super.addArgumentResolvers(argumentResolvers);
- argumentResolvers.add(configurationHandlerMethodArgumentResolver());
- }
-
- @Override
- protected void configureJacksonObjectMapper(ObjectMapper objectMapper) {
- objectMapper.registerModule(new LightAdminJacksonModule(globalAdministrationConfiguration()));
- }
-
- @SuppressWarnings("unchecked")
- private void configureRepositoryExporterHandlerAdapter(RequestMappingHandlerAdapter requestMappingHandlerAdapter) {
- List defaultArgumentResolvers = (List) forDirectFieldAccess(requestMappingHandlerAdapter).getPropertyValue("argumentResolvers");
-
- List argumentResolvers = decorateArgumentResolvers(defaultArgumentResolvers);
-
- argumentResolvers.add(configurationHandlerMethodArgumentResolver());
-
- forDirectFieldAccess(requestMappingHandlerAdapter).setPropertyValue("argumentResolvers", argumentResolvers);
- }
-
- private List decorateArgumentResolvers(List argumentResolvers) {
- List result = newLinkedList();
- for (HandlerMethodArgumentResolver argumentResolver : argumentResolvers) {
- if (isAssignableValue(PersistentEntityResourceAssemblerArgumentResolver.class, argumentResolver)) {
- PersistentEntityResourceAssemblerArgumentResolver persistentEntityResourceAssemblerArgumentResolver = (PersistentEntityResourceAssemblerArgumentResolver) argumentResolver;
- result.add(new DynamicPersistentEntityResourceAssemblerArgumentResolver(persistentEntityResourceAssemblerArgumentResolver));
- continue;
- }
- result.add(argumentResolver);
- }
- return result;
- }
-
- private GlobalAdministrationConfiguration globalAdministrationConfiguration() {
- return beanFactory.getBean(GlobalAdministrationConfiguration.class);
- }
-
- private FileResourceStorage fileResourceStorage() {
- return beanFactory.getBean(FileResourceStorage.class);
- }
-
- private Validator validator() {
- return beanFactory.getBean("validator", Validator.class);
- }
-
- private LightAdminConfiguration lightAdminConfiguration() {
- return beanFactory.getBean(LightAdminConfiguration.class);
- }
+/*
+ * Copyright 2012-2014 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.lightadmin.core.config.context;
+
+import org.lightadmin.core.config.LightAdminConfiguration;
+import org.lightadmin.core.config.bootstrap.RepositoriesFactoryBean;
+import org.lightadmin.core.config.domain.GlobalAdministrationConfiguration;
+import org.lightadmin.core.persistence.repository.event.FileManipulationRepositoryEventListener;
+import org.lightadmin.core.persistence.repository.invoker.DynamicRepositoryInvokerFactory;
+import org.lightadmin.core.persistence.support.DynamicDomainObjectMerger;
+import org.lightadmin.core.storage.FileResourceStorage;
+import org.lightadmin.core.web.json.DomainTypeToJsonMetadataConverter;
+import org.lightadmin.core.web.support.*;
+import org.springframework.beans.BeanInstantiationException;
+import org.springframework.beans.factory.ListableBeanFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.convert.ConversionService;
+import org.springframework.data.repository.support.Repositories;
+import org.springframework.data.repository.support.RepositoryInvokerFactory;
+import org.springframework.data.rest.core.support.DomainObjectMerger;
+import org.springframework.data.rest.webmvc.RepositoryRestController;
+import org.springframework.data.rest.webmvc.config.PersistentEntityResourceAssemblerArgumentResolver;
+import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer;
+import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;
+import org.springframework.data.rest.webmvc.mapping.LinkCollector;
+import org.springframework.web.method.support.HandlerMethodArgumentResolver;
+import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
+
+import java.util.List;
+
+import static com.google.common.collect.Lists.newLinkedList;
+import static org.springframework.beans.PropertyAccessorFactory.forDirectFieldAccess;
+import static org.springframework.util.ClassUtils.isAssignableValue;
+
+@Configuration
+@ComponentScan(basePackages = {"org.lightadmin.core.web"},
+ includeFilters = @ComponentScan.Filter(RepositoryRestController.class), useDefaultFilters = false)
+public class LightAdminRepositoryRestMvcConfiguration extends RepositoryRestMvcConfiguration {
+
+ @Autowired
+ private ListableBeanFactory beanFactory;
+
+ @Bean
+ public DomainEntityLinks domainEntityLinks() {
+ return new DomainEntityLinks(globalAdministrationConfiguration(), backendIdConverterRegistry(), lightAdminConfiguration());
+ }
+
+ @Override
+ public DynamicRepositoryEntityLinks entityLinks() {
+ return new DynamicRepositoryEntityLinks(super.entityLinks());
+ }
+
+ @Bean
+ public DynamicPersistentEntityResourceProcessor dynamicPersistentEntityResourceProcessor() {
+ return new DynamicPersistentEntityResourceProcessor(globalAdministrationConfiguration(),
+ fileResourceStorage(), entityLinks(), domainEntityLinks(),
+ resourceMappings(), associationLinks());
+ }
+
+ @Bean
+ public DomainTypeToJsonMetadataConverter domainTypeToJsonMetadataConverter() {
+ return new DomainTypeToJsonMetadataConverter(globalAdministrationConfiguration(), entityLinks());
+ }
+
+ @Bean
+ public Repositories repositories() {
+ try {
+ return new RepositoriesFactoryBean(beanFactory).getObject();
+ } catch (Exception e) {
+ throw new BeanInstantiationException(Repositories.class, "Repositories bean instantiation problem!", e);
+ }
+ }
+
+ @Bean
+ public DomainObjectMerger domainObjectMerger() throws Exception {
+ return new DynamicDomainObjectMerger(repositories(), defaultConversionService(), globalAdministrationConfiguration());
+ }
+
+ @Override
+ public RepositoryInvokerFactory repositoryInvokerFactory(@Qualifier ConversionService defaultConversionService) {
+ RepositoryInvokerFactory repositoryInvokerFactory = super.repositoryInvokerFactory(defaultConversionService);
+
+ return new DynamicRepositoryInvokerFactory(repositories(), repositoryInvokerFactory);
+ }
+
+ @Bean
+ public ConfigurationHandlerMethodArgumentResolver configurationHandlerMethodArgumentResolver() {
+ return new ConfigurationHandlerMethodArgumentResolver(globalAdministrationConfiguration(), resourceMetadataHandlerMethodArgumentResolver());
+ }
+
+ @Bean
+ @Autowired
+ public FileManipulationRepositoryEventListener domainRepositoryEventListener(GlobalAdministrationConfiguration configuration, FileResourceStorage fileResourceStorage) {
+ return new FileManipulationRepositoryEventListener(configuration, fileResourceStorage);
+ }
+
+ @Bean
+ public RepositoryRestConfigurer lightAdminRepositoryRestConfigurer() {
+ return new LightAdminRepositoryRestConfigurer();
+ }
+
+ @Override
+ public RequestMappingHandlerAdapter repositoryExporterHandlerAdapter() {
+ RequestMappingHandlerAdapter requestMappingHandlerAdapter = super.repositoryExporterHandlerAdapter();
+ configureRepositoryExporterHandlerAdapter(requestMappingHandlerAdapter);
+ return requestMappingHandlerAdapter;
+ }
+
+ @Override
+ public void addArgumentResolvers(List argumentResolvers) {
+ super.addArgumentResolvers(argumentResolvers);
+ argumentResolvers.add(configurationHandlerMethodArgumentResolver());
+ }
+
+ @Override
+ protected LinkCollector linkCollector() {
+ return new LightAdminLinkCollector(persistentEntities(), selfLinkProvider(), associationLinks());
+ }
+
+ @SuppressWarnings("unchecked")
+ private void configureRepositoryExporterHandlerAdapter(RequestMappingHandlerAdapter requestMappingHandlerAdapter) {
+ List defaultArgumentResolvers = (List) forDirectFieldAccess(requestMappingHandlerAdapter).getPropertyValue("argumentResolvers");
+
+ List argumentResolvers = decorateArgumentResolvers(defaultArgumentResolvers);
+
+ argumentResolvers.add(configurationHandlerMethodArgumentResolver());
+
+ forDirectFieldAccess(requestMappingHandlerAdapter).setPropertyValue("argumentResolvers", argumentResolvers);
+ }
+
+ private List decorateArgumentResolvers(List argumentResolvers) {
+ List result = newLinkedList();
+ result.addAll(argumentResolvers);
+ return result;
+ }
+
+ private GlobalAdministrationConfiguration globalAdministrationConfiguration() {
+ return beanFactory.getBean(GlobalAdministrationConfiguration.class);
+ }
+
+ private FileResourceStorage fileResourceStorage() {
+ return beanFactory.getBean(FileResourceStorage.class);
+ }
+
+ private LightAdminConfiguration lightAdminConfiguration() {
+ return beanFactory.getBean(LightAdminConfiguration.class);
+ }
}
\ No newline at end of file
diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/config/context/LightAdminSecurityConfiguration.java b/lightadmin-core/src/main/java/org/lightadmin/core/config/context/LightAdminSecurityConfiguration.java
index 732790a0..0b129707 100644
--- a/lightadmin-core/src/main/java/org/lightadmin/core/config/context/LightAdminSecurityConfiguration.java
+++ b/lightadmin-core/src/main/java/org/lightadmin/core/config/context/LightAdminSecurityConfiguration.java
@@ -1,211 +1,213 @@
-/*
- * Copyright 2012-2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.lightadmin.core.config.context;
-
-import org.lightadmin.core.config.LightAdminConfiguration;
-import org.lightadmin.core.web.security.LightAdminRequestCache;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.support.PropertiesLoaderUtils;
-import org.springframework.security.access.AccessDecisionVoter;
-import org.springframework.security.access.ConfigAttribute;
-import org.springframework.security.access.SecurityConfig;
-import org.springframework.security.access.vote.AffirmativeBased;
-import org.springframework.security.access.vote.RoleVoter;
-import org.springframework.security.authentication.AuthenticationManager;
-import org.springframework.security.authentication.AuthenticationProvider;
-import org.springframework.security.authentication.ProviderManager;
-import org.springframework.security.authentication.RememberMeAuthenticationProvider;
-import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
-import org.springframework.security.authentication.encoding.ShaPasswordEncoder;
-import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.security.provisioning.InMemoryUserDetailsManager;
-import org.springframework.security.web.DefaultSecurityFilterChain;
-import org.springframework.security.web.FilterChainProxy;
-import org.springframework.security.web.SecurityFilterChain;
-import org.springframework.security.web.access.AccessDeniedHandlerImpl;
-import org.springframework.security.web.access.ExceptionTranslationFilter;
-import org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource;
-import org.springframework.security.web.access.intercept.FilterInvocationSecurityMetadataSource;
-import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;
-import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
-import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
-import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
-import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
-import org.springframework.security.web.authentication.logout.LogoutFilter;
-import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler;
-import org.springframework.security.web.authentication.rememberme.AbstractRememberMeServices;
-import org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter;
-import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices;
-import org.springframework.security.web.context.HttpSessionSecurityContextRepository;
-import org.springframework.security.web.context.SecurityContextPersistenceFilter;
-import org.springframework.security.web.savedrequest.RequestCache;
-import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
-import org.springframework.security.web.util.matcher.AnyRequestMatcher;
-import org.springframework.security.web.util.matcher.RequestMatcher;
-
-import javax.servlet.Filter;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Properties;
-
-import static com.google.common.collect.Lists.newArrayList;
-import static com.google.common.collect.Maps.newLinkedHashMap;
-import static java.util.Arrays.asList;
-
-@Configuration
-public class LightAdminSecurityConfiguration {
-
- private static final String REMEMBER_ME_DIGEST_KEY = "LightAdmin";
- private static final String ROLE_ADMIN = "ROLE_ADMIN";
-
- private static final String[] PUBLIC_RESOURCES = {
- "/images/**", "/scripts/**", "/styles/**",
- "/rest/**/file",
- "/login", "/page-not-found", "/access-denied",
- "/dynamic/logo"
- };
-
- @Value("classpath:users.properties")
- private Resource usersResource;
-
- @Autowired
- private LightAdminConfiguration lightAdminConfiguration;
-
- @Bean
- @Autowired
- public FilterChainProxy springSecurityFilterChain(Filter filterSecurityInterceptor, Filter authenticationFilter, Filter rememberMeAuthenticationFilter, Filter logoutFilter, Filter exceptionTranslationFilter, Filter securityContextPersistenceFilter) {
- List filterChains = newArrayList();
- for (String pattern : PUBLIC_RESOURCES) {
- filterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher(applicationUrl(pattern))));
- }
-
- filterChains.add(new DefaultSecurityFilterChain(AnyRequestMatcher.INSTANCE, securityContextPersistenceFilter, exceptionTranslationFilter, logoutFilter, authenticationFilter, rememberMeAuthenticationFilter, filterSecurityInterceptor));
-
- return new FilterChainProxy(filterChains);
- }
-
- @Bean
- @Autowired
- public Filter filterSecurityInterceptor(AuthenticationManager authenticationManager) throws Exception {
- FilterSecurityInterceptor filter = new FilterSecurityInterceptor();
- filter.setAuthenticationManager(authenticationManager);
- filter.setAccessDecisionManager(new AffirmativeBased(asList((AccessDecisionVoter) new RoleVoter())));
- filter.setSecurityMetadataSource(securityMetadataSource());
- filter.afterPropertiesSet();
- return filter;
- }
-
- private FilterInvocationSecurityMetadataSource securityMetadataSource() {
- LinkedHashMap> map = newLinkedHashMap();
- map.put(AnyRequestMatcher.INSTANCE, asList((ConfigAttribute) new SecurityConfig(ROLE_ADMIN)));
- return new DefaultFilterInvocationSecurityMetadataSource(map);
- }
-
- @Bean
- @Autowired
- public Filter authenticationFilter(AuthenticationManager authenticationManager, RequestCache requestCache) {
- UsernamePasswordAuthenticationFilter authenticationFilter = new UsernamePasswordAuthenticationFilter();
- authenticationFilter.setFilterProcessesUrl(applicationUrl("/j_spring_security_check"));
- authenticationFilter.setAuthenticationManager(authenticationManager);
- SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
- successHandler.setRequestCache(requestCache);
- authenticationFilter.setAuthenticationSuccessHandler(successHandler);
- authenticationFilter.setAuthenticationFailureHandler(new SimpleUrlAuthenticationFailureHandler(applicationUrl("/login?login_error=1")));
- return authenticationFilter;
- }
-
- @Bean
- public Filter exceptionTranslationFilter(RequestCache requestCache) {
- AccessDeniedHandlerImpl accessDeniedHandler = new AccessDeniedHandlerImpl();
- accessDeniedHandler.setErrorPage(applicationUrl("/access-denied"));
- LoginUrlAuthenticationEntryPoint authenticationEntryPoint = new LoginUrlAuthenticationEntryPoint(applicationUrl("/login"));
- ExceptionTranslationFilter exceptionTranslationFilter = new ExceptionTranslationFilter(authenticationEntryPoint, requestCache);
- exceptionTranslationFilter.setAccessDeniedHandler(accessDeniedHandler);
- return exceptionTranslationFilter;
- }
-
- @Bean
- public Filter logoutFilter() {
- SecurityContextLogoutHandler logoutHandler = new SecurityContextLogoutHandler();
- logoutHandler.setInvalidateHttpSession(false);
- LogoutFilter logoutFilter = new LogoutFilter(applicationUrl("/"), logoutHandler);
- logoutFilter.setFilterProcessesUrl(applicationUrl("/logout"));
- return logoutFilter;
- }
-
- @Bean
- public Filter securityContextPersistenceFilter() {
- HttpSessionSecurityContextRepository repo = new HttpSessionSecurityContextRepository();
- repo.setSpringSecurityContextKey(keyWithNamespace(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY));
- return new SecurityContextPersistenceFilter(repo);
- }
-
- @Bean
- public Filter rememberMeAuthenticationFilter(AuthenticationManager authenticationManager, UserDetailsService userDetailsService) {
- TokenBasedRememberMeServices rememberMeServices = new TokenBasedRememberMeServices(REMEMBER_ME_DIGEST_KEY, userDetailsService);
- rememberMeServices.setCookieName(keyWithNamespace(AbstractRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY));
- return new RememberMeAuthenticationFilter(authenticationManager, rememberMeServices);
- }
-
- @Bean
- public RequestCache requestCache() {
- return new LightAdminRequestCache();
- }
-
- @Bean
- @Autowired
- public AuthenticationManager authenticationManager(AuthenticationProvider authenticationProvider, AuthenticationProvider rememberMeAuthenticationProvider) {
- return new ProviderManager(asList(authenticationProvider, rememberMeAuthenticationProvider));
- }
-
- @Bean
- @Autowired
- public AuthenticationProvider authenticationProvider(UserDetailsService usersService) throws Exception {
- DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
- provider.setPasswordEncoder(new ShaPasswordEncoder());
- provider.setUserDetailsService(usersService);
- provider.afterPropertiesSet();
- return provider;
- }
-
- @Bean
- @Primary
- public UserDetailsService userDetailsService() throws IOException {
- Properties usersPproperties = PropertiesLoaderUtils.loadProperties(usersResource);
- return new InMemoryUserDetailsManager(usersPproperties);
- }
-
- @Bean
- public AuthenticationProvider rememberMeAuthenticationProvider() {
- return new RememberMeAuthenticationProvider(REMEMBER_ME_DIGEST_KEY);
- }
-
- private String applicationUrl(String path) {
- return lightAdminConfiguration.getApplicationUrl(path);
- }
-
- private String keyWithNamespace(String key) {
- return "lightadmin:" + key;
- }
-
-}
+/*
+ * Copyright 2012-2014 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.lightadmin.core.config.context;
+
+import org.lightadmin.core.config.LightAdminConfiguration;
+import org.lightadmin.core.web.security.LightAdminRequestCache;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.support.PropertiesLoaderUtils;
+import org.springframework.security.access.AccessDecisionVoter;
+import org.springframework.security.access.ConfigAttribute;
+import org.springframework.security.access.SecurityConfig;
+import org.springframework.security.access.vote.AffirmativeBased;
+import org.springframework.security.access.vote.RoleVoter;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.authentication.AuthenticationProvider;
+import org.springframework.security.authentication.ProviderManager;
+import org.springframework.security.authentication.RememberMeAuthenticationProvider;
+import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
+import org.springframework.security.authentication.encoding.ShaPasswordEncoder;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.provisioning.InMemoryUserDetailsManager;
+import org.springframework.security.web.DefaultSecurityFilterChain;
+import org.springframework.security.web.FilterChainProxy;
+import org.springframework.security.web.SecurityFilterChain;
+import org.springframework.security.web.access.AccessDeniedHandlerImpl;
+import org.springframework.security.web.access.ExceptionTranslationFilter;
+import org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource;
+import org.springframework.security.web.access.intercept.FilterInvocationSecurityMetadataSource;
+import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;
+import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
+import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
+import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
+import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
+import org.springframework.security.web.authentication.logout.LogoutFilter;
+import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler;
+import org.springframework.security.web.authentication.rememberme.AbstractRememberMeServices;
+import org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter;
+import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices;
+import org.springframework.security.web.context.HttpSessionSecurityContextRepository;
+import org.springframework.security.web.context.SecurityContextPersistenceFilter;
+import org.springframework.security.web.savedrequest.RequestCache;
+import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
+import org.springframework.security.web.util.matcher.AnyRequestMatcher;
+import org.springframework.security.web.util.matcher.RequestMatcher;
+
+import javax.servlet.Filter;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Properties;
+
+import static com.google.common.collect.Lists.newArrayList;
+import static com.google.common.collect.Maps.newLinkedHashMap;
+import static java.util.Arrays.asList;
+
+@Configuration
+public class LightAdminSecurityConfiguration {
+
+ private static final String REMEMBER_ME_DIGEST_KEY = "LightAdmin";
+ private static final String ROLE_ADMIN = "ROLE_ADMIN";
+
+ private static final String[] PUBLIC_RESOURCES = {
+ "/images/**", "/scripts/**", "/styles/**",
+ "/rest/**/file",
+ "/login", "/page-not-found", "/access-denied",
+ "/dynamic/logo"
+ };
+
+ @Value("classpath:users.properties")
+ private Resource usersResource;
+
+ @Autowired
+ private LightAdminConfiguration lightAdminConfiguration;
+
+ @Bean
+ @Autowired
+ public FilterChainProxy springSecurityFilterChain(Filter filterSecurityInterceptor, Filter authenticationFilter, Filter rememberMeAuthenticationFilter, Filter logoutFilter, Filter exceptionTranslationFilter, Filter securityContextPersistenceFilter) {
+ List filterChains = newArrayList();
+ for (String pattern : PUBLIC_RESOURCES) {
+ filterChains.add(new DefaultSecurityFilterChain(new AntPathRequestMatcher(applicationUrl(pattern))));
+ }
+
+ filterChains.add(new DefaultSecurityFilterChain(AnyRequestMatcher.INSTANCE, securityContextPersistenceFilter, exceptionTranslationFilter, logoutFilter, authenticationFilter, rememberMeAuthenticationFilter, filterSecurityInterceptor));
+
+ return new FilterChainProxy(filterChains);
+ }
+
+ @Bean
+ @Autowired
+ public Filter filterSecurityInterceptor(AuthenticationManager authenticationManager) throws Exception {
+ FilterSecurityInterceptor filter = new FilterSecurityInterceptor();
+ filter.setAuthenticationManager(authenticationManager);
+ List> decisionVoters = asList((AccessDecisionVoter>) new RoleVoter());
+ AffirmativeBased accessDecisionManager = new AffirmativeBased(decisionVoters);
+ filter.setAccessDecisionManager(accessDecisionManager);
+ filter.setSecurityMetadataSource(securityMetadataSource());
+ filter.afterPropertiesSet();
+ return filter;
+ }
+
+ private FilterInvocationSecurityMetadataSource securityMetadataSource() {
+ LinkedHashMap> map = newLinkedHashMap();
+ map.put(AnyRequestMatcher.INSTANCE, asList((ConfigAttribute) new SecurityConfig(ROLE_ADMIN)));
+ return new DefaultFilterInvocationSecurityMetadataSource(map);
+ }
+
+ @Bean
+ @Autowired
+ public Filter authenticationFilter(AuthenticationManager authenticationManager, RequestCache requestCache) {
+ UsernamePasswordAuthenticationFilter authenticationFilter = new UsernamePasswordAuthenticationFilter();
+ authenticationFilter.setFilterProcessesUrl(applicationUrl("/j_spring_security_check"));
+ authenticationFilter.setAuthenticationManager(authenticationManager);
+ SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
+ successHandler.setRequestCache(requestCache);
+ authenticationFilter.setAuthenticationSuccessHandler(successHandler);
+ authenticationFilter.setAuthenticationFailureHandler(new SimpleUrlAuthenticationFailureHandler(applicationUrl("/login?login_error=1")));
+ return authenticationFilter;
+ }
+
+ @Bean
+ public Filter exceptionTranslationFilter(RequestCache requestCache) {
+ AccessDeniedHandlerImpl accessDeniedHandler = new AccessDeniedHandlerImpl();
+ accessDeniedHandler.setErrorPage(applicationUrl("/access-denied"));
+ LoginUrlAuthenticationEntryPoint authenticationEntryPoint = new LoginUrlAuthenticationEntryPoint(applicationUrl("/login"));
+ ExceptionTranslationFilter exceptionTranslationFilter = new ExceptionTranslationFilter(authenticationEntryPoint, requestCache);
+ exceptionTranslationFilter.setAccessDeniedHandler(accessDeniedHandler);
+ return exceptionTranslationFilter;
+ }
+
+ @Bean
+ public Filter logoutFilter() {
+ SecurityContextLogoutHandler logoutHandler = new SecurityContextLogoutHandler();
+ logoutHandler.setInvalidateHttpSession(false);
+ LogoutFilter logoutFilter = new LogoutFilter(applicationUrl("/"), logoutHandler);
+ logoutFilter.setFilterProcessesUrl(applicationUrl("/logout"));
+ return logoutFilter;
+ }
+
+ @Bean
+ public Filter securityContextPersistenceFilter() {
+ HttpSessionSecurityContextRepository repo = new HttpSessionSecurityContextRepository();
+ repo.setSpringSecurityContextKey(keyWithNamespace(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY));
+ return new SecurityContextPersistenceFilter(repo);
+ }
+
+ @Bean
+ public Filter rememberMeAuthenticationFilter(AuthenticationManager authenticationManager, UserDetailsService userDetailsService) {
+ TokenBasedRememberMeServices rememberMeServices = new TokenBasedRememberMeServices(REMEMBER_ME_DIGEST_KEY, userDetailsService);
+ rememberMeServices.setCookieName(keyWithNamespace(AbstractRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY));
+ return new RememberMeAuthenticationFilter(authenticationManager, rememberMeServices);
+ }
+
+ @Bean
+ public RequestCache requestCache() {
+ return new LightAdminRequestCache();
+ }
+
+ @Bean
+ @Autowired
+ public AuthenticationManager authenticationManager(AuthenticationProvider authenticationProvider, AuthenticationProvider rememberMeAuthenticationProvider) {
+ return new ProviderManager(asList(authenticationProvider, rememberMeAuthenticationProvider));
+ }
+
+ @Bean
+ @Autowired
+ public AuthenticationProvider authenticationProvider(UserDetailsService usersService) throws Exception {
+ DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
+ provider.setPasswordEncoder(new ShaPasswordEncoder());
+ provider.setUserDetailsService(usersService);
+ provider.afterPropertiesSet();
+ return provider;
+ }
+
+ @Bean
+ @Primary
+ public UserDetailsService userDetailsService() throws IOException {
+ Properties usersPproperties = PropertiesLoaderUtils.loadProperties(usersResource);
+ return new InMemoryUserDetailsManager(usersPproperties);
+ }
+
+ @Bean
+ public AuthenticationProvider rememberMeAuthenticationProvider() {
+ return new RememberMeAuthenticationProvider(REMEMBER_ME_DIGEST_KEY);
+ }
+
+ private String applicationUrl(String path) {
+ return lightAdminConfiguration.getApplicationUrl(path);
+ }
+
+ private String keyWithNamespace(String key) {
+ return "lightadmin:" + key;
+ }
+
+}
diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/config/domain/unit/DomainConfigurationUnitType.java b/lightadmin-core/src/main/java/org/lightadmin/core/config/domain/unit/DomainConfigurationUnitType.java
index 33ddd47a..b6d46b2d 100644
--- a/lightadmin-core/src/main/java/org/lightadmin/core/config/domain/unit/DomainConfigurationUnitType.java
+++ b/lightadmin-core/src/main/java/org/lightadmin/core/config/domain/unit/DomainConfigurationUnitType.java
@@ -1,55 +1,60 @@
-/*
- * Copyright 2012-2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.lightadmin.core.config.domain.unit;
-
-import static java.lang.String.format;
-
-public enum DomainConfigurationUnitType {
-
- SCREEN_CONTEXT("screenContext"),
- CONFIGURATION("configuration"),
- LIST_VIEW("listView"),
- SHOW_VIEW("showView"),
- FORM_VIEW("formView"),
- QUICK_VIEW("quickView"),
- SCOPES("scopes"),
- FILTERS("filters"),
- SIDEBARS("sidebars");
-
- private final String name;
-
- private DomainConfigurationUnitType(final String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public static DomainConfigurationUnitType forName(String name) {
- for (DomainConfigurationUnitType domainConfigurationUnitType : values()) {
- if (domainConfigurationUnitType.getName().equals(name)) {
- return domainConfigurationUnitType;
- }
- }
- throw new IllegalArgumentException(format("Configuration Unit for name %s not defined!", name));
- }
-
- @Override
- public String toString() {
- return getName();
- }
+/*
+ * Copyright 2012-2014 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.lightadmin.core.config.domain.unit;
+
+import static java.lang.String.format;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonValue;
+
+public enum DomainConfigurationUnitType {
+
+ SCREEN_CONTEXT("screenContext"),
+ CONFIGURATION("configuration"),
+ LIST_VIEW("listView"),
+ SHOW_VIEW("showView"),
+ FORM_VIEW("formView"),
+ QUICK_VIEW("quickView"),
+ SCOPES("scopes"),
+ FILTERS("filters"),
+ SIDEBARS("sidebars");
+
+ private final String name;
+
+ private DomainConfigurationUnitType(final String name) {
+ this.name = name;
+ }
+
+ @JsonValue
+ public String getName() {
+ return name;
+ }
+
+ @JsonCreator
+ public static DomainConfigurationUnitType forName(String name) {
+ for (DomainConfigurationUnitType domainConfigurationUnitType : values()) {
+ if (domainConfigurationUnitType.getName().equals(name)) {
+ return domainConfigurationUnitType;
+ }
+ }
+ throw new IllegalArgumentException(format("Configuration Unit for name %s not defined!", name));
+ }
+
+ @Override
+ public String toString() {
+ return getName();
+ }
}
\ No newline at end of file
diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvoker.java b/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvoker.java
index 7747c811..0b19154f 100644
--- a/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvoker.java
+++ b/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvoker.java
@@ -1,35 +1,35 @@
-/*
- * Copyright 2012-2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.lightadmin.core.persistence.repository.invoker;
-
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.domain.Sort;
-import org.springframework.data.jpa.domain.Specification;
-import org.springframework.data.rest.core.invoke.RepositoryInvoker;
-
-import java.util.List;
-
-public interface DynamicRepositoryInvoker extends RepositoryInvoker {
-
- Page findAll(Specification spec, Pageable pageable);
-
- List findAll(Specification spec, Sort sort);
-
- List findAll(Specification spec);
-
- long count(Specification spec);
+/*
+ * Copyright 2012-2014 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.lightadmin.core.persistence.repository.invoker;
+
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.data.repository.support.RepositoryInvoker;
+
+import java.util.List;
+
+public interface DynamicRepositoryInvoker extends RepositoryInvoker {
+
+ Page findAll(Specification spec, Pageable pageable);
+
+ List findAll(Specification spec, Sort sort);
+
+ List findAll(Specification spec);
+
+ long count(Specification spec);
}
\ No newline at end of file
diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvokerFactory.java b/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvokerFactory.java
index a58a6faf..5dc08726 100644
--- a/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvokerFactory.java
+++ b/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvokerFactory.java
@@ -1,40 +1,40 @@
-/*
- * Copyright 2012-2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.lightadmin.core.persistence.repository.invoker;
-
-import org.lightadmin.core.persistence.repository.DynamicJpaRepository;
-import org.springframework.data.repository.support.Repositories;
-import org.springframework.data.rest.core.invoke.RepositoryInvoker;
-import org.springframework.data.rest.core.invoke.RepositoryInvokerFactory;
-
-public class DynamicRepositoryInvokerFactory implements RepositoryInvokerFactory {
-
- private final RepositoryInvokerFactory delegate;
- private final Repositories repositories;
-
- public DynamicRepositoryInvokerFactory(Repositories repositories, RepositoryInvokerFactory repositoryInvokerFactory) {
- this.repositories = repositories;
- this.delegate = repositoryInvokerFactory;
- }
-
- @Override
- public RepositoryInvoker getInvokerFor(Class> domainType) {
- DynamicJpaRepository dynamicJpaRepository = (DynamicJpaRepository) repositories.getRepositoryFor(domainType);
- RepositoryInvoker repositoryInvoker = delegate.getInvokerFor(domainType);
-
- return new DynamicRepositoryInvokerWrapper(dynamicJpaRepository, repositoryInvoker);
- }
+/*
+ * Copyright 2012-2014 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.lightadmin.core.persistence.repository.invoker;
+
+import org.lightadmin.core.persistence.repository.DynamicJpaRepository;
+import org.springframework.data.repository.support.Repositories;
+import org.springframework.data.repository.support.RepositoryInvoker;
+import org.springframework.data.repository.support.RepositoryInvokerFactory;
+
+public class DynamicRepositoryInvokerFactory implements RepositoryInvokerFactory {
+
+ private final RepositoryInvokerFactory delegate;
+ private final Repositories repositories;
+
+ public DynamicRepositoryInvokerFactory(Repositories repositories, RepositoryInvokerFactory repositoryInvokerFactory) {
+ this.repositories = repositories;
+ this.delegate = repositoryInvokerFactory;
+ }
+
+ @Override
+ public RepositoryInvoker getInvokerFor(Class> domainType) {
+ DynamicJpaRepository dynamicJpaRepository = (DynamicJpaRepository) repositories.getRepositoryFor(domainType);
+ RepositoryInvoker repositoryInvoker = delegate.getInvokerFor(domainType);
+
+ return new DynamicRepositoryInvokerWrapper(dynamicJpaRepository, repositoryInvoker);
+ }
}
\ No newline at end of file
diff --git a/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvokerWrapper.java b/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvokerWrapper.java
index 75fe6f09..bd89b6f5 100644
--- a/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvokerWrapper.java
+++ b/lightadmin-core/src/main/java/org/lightadmin/core/persistence/repository/invoker/DynamicRepositoryInvokerWrapper.java
@@ -1,130 +1,117 @@
-/*
- * Copyright 2012-2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.lightadmin.core.persistence.repository.invoker;
-
-import org.lightadmin.core.persistence.repository.DynamicJpaRepository;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.domain.Sort;
-import org.springframework.data.jpa.domain.Specification;
-import org.springframework.data.rest.core.invoke.RepositoryInvoker;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Map;
-
-@SuppressWarnings("unchecked")
-public class DynamicRepositoryInvokerWrapper implements DynamicRepositoryInvoker {
-
- private final DynamicJpaRepository, ?> repository;
- private final RepositoryInvoker repositoryInvoker;
-
- public DynamicRepositoryInvokerWrapper(DynamicJpaRepository dynamicRepository, RepositoryInvoker repositoryInvoker) {
- this.repository = dynamicRepository;
- this.repositoryInvoker = repositoryInvoker;
- }
-
- @Override
- public Page findAll(Specification spec, Pageable pageable) {
- return repository.findAll(spec, pageable);
- }
-
- @Override
- public List findAll(Specification spec, Sort sort) {
- return repository.findAll(spec, sort);
- }
-
- @Override
- public List findAll(Specification spec) {
- return repository.findAll(spec);
- }
-
- @Override
- public long count(Specification spec) {
- return repository.count(spec);
- }
-
- @Override
- public T invokeSave(T object) {
- return repositoryInvoker.invokeSave(object);
- }
-
- @Override
- public T invokeFindOne(Serializable id) {
- return repositoryInvoker.invokeFindOne(id);
- }
-
- @Override
- public Iterable