org.springframework.data.rest.core.config.RepositoryRestConfiguration Java Examples

The following examples show how to use org.springframework.data.rest.core.config.RepositoryRestConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RestConfiguration.java    From moserp with Apache License 2.0 6 votes vote down vote up
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(true);
    provider.addIncludeFilter(new AssignableTypeFilter(IdentifiableEntity.class));
    Set<BeanDefinition> components = provider.findCandidateComponents(this.getClass().getPackage().getName());
    List<Class<?>> classes = new ArrayList<>();

    components.forEach(component -> {
        try {
            classes.add(Class.forName(component.getBeanClassName()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    });

    config.exposeIdsFor(classes.toArray(new Class[classes.size()]));
}
 
Example #2
Source File: SpringRestDataConfig.java    From microservice-kubernetes with Apache License 2.0 5 votes vote down vote up
@Bean
public RepositoryRestConfigurer repositoryRestConfigurer() {

	return new RepositoryRestConfigurerAdapter() {
		@Override
		public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
			config.exposeIdsFor(Item.class);
		}
	};
}
 
Example #3
Source File: SpringRestDataConfig.java    From microservice with Apache License 2.0 5 votes vote down vote up
@Bean
public RepositoryRestConfigurer repositoryRestConfigurer() {

	return new RepositoryRestConfigurerAdapter() {
		@Override
		public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
			config.exposeIdsFor(Order.class, Item.class, Customer.class);
		}
	};
}
 
Example #4
Source File: RepositoryConfig.java    From entref-spring-boot with MIT License 5 votes vote down vote up
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
    // expose the ids for the given model types
    config.exposeIdsFor(Person.class);
    config.exposeIdsFor(Title.class);

    // configure how we find and load repositories to let us disable them at runtime with an environment variable
    config.setRepositoryDetectionStrategy(metadata -> {
        // if it's not exported, exclude it
        if (!metadata.getRepositoryInterface().getAnnotation(RepositoryRestResource.class).exported()) {
            return false;
        }

        String className = metadata.getRepositoryInterface().getName();
        String exclusionList = env.getProperty(Constants.ENV_EXCLUDE_FILTER);

        if (exclusionList != null && !exclusionList.isEmpty()) {
            for (String exclude : exclusionList.split(",")) {
                // see if we get any hits, treating the exclusion list entry as a regex pattern
                // note: this allows us to hit 'ClassA' even if it's really 'com.package.ClassA'
                if (Pattern.compile(exclude).matcher(className).find()) {
                    // exclude if we match
                    return false;
                }
            }
        }

        // default to allowing the repository
        return true;
    });
}
 
Example #5
Source File: CustomRepositoryRestConfigurerAdapter.java    From Spring with Apache License 2.0 5 votes vote down vote up
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
    config.setBasePath("myapi");
    config.setDefaultMediaType(MediaType.APPLICATION_JSON);
    config.setDefaultPageSize(5);
    super.configureRepositoryRestConfiguration(config);
}
 
Example #6
Source File: SpringRestDataConfig.java    From microservice with Apache License 2.0 5 votes vote down vote up
@Bean
public RepositoryRestConfigurer repositoryRestConfigurer() {

	return new RepositoryRestConfigurerAdapter() {
		@Override
		public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
			config.exposeIdsFor(Customer.class);
		}
	};
}
 
Example #7
Source File: SpringRestDataConfig.java    From microservice with Apache License 2.0 5 votes vote down vote up
@Bean
public RepositoryRestConfigurer repositoryRestConfigurer() {

	return new RepositoryRestConfigurerAdapter() {
		@Override
		public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
			config.exposeIdsFor(Item.class);
		}
	};
}
 
Example #8
Source File: JournalAutoConfiguration.java    From pro-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
	if (null == journal.getApiPath())
		config.setBasePath(API_PATH);
	else
		config.setBasePath(journal.getApiPath());
}
 
Example #9
Source File: MainApp.java    From botanic-ng with Apache License 2.0 5 votes vote down vote up
@Bean
public RepositoryRestConfigurer repositoryRestConfigurer() {
	return new RepositoryRestConfigurerAdapter() {
		@Override
		public void configureRepositoryRestConfiguration(
							RepositoryRestConfiguration config) {
			config.exposeIdsFor(Plant.class, Image.class, Garden.class);
			config.setBasePath("/api");
		}
	};
}
 
Example #10
Source File: SpringDocDataRestConfiguration.java    From springdoc-openapi with Apache License 2.0 5 votes vote down vote up
/**
 * Hal provider data rest hal provider.
 *
 * @param repositoryRestConfiguration the repository rest configuration 
 * @return the data rest hal provider
 */
@Bean
@ConditionalOnMissingBean
@Primary
@Lazy(false)
DataRestHalProvider halProvider(Optional<RepositoryRestConfiguration> repositoryRestConfiguration) {
	return new DataRestHalProvider(repositoryRestConfiguration);
}
 
Example #11
Source File: JournalAutoConfiguration.java    From pro-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
	if (null == journal.getApiPath())
		config.setBasePath(API_PATH);
	else
		config.setBasePath(journal.getApiPath());
}
 
Example #12
Source File: RepositoryIdExposingConfiguration.java    From SMSC with Apache License 2.0 5 votes vote down vote up
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {

    // for this time only one solution which works completely
    config.exposeIdsFor(io.smsc.model.admin.User.class, User.class, Role.class, Authority.class, Group.class, Customer.class, Contact.class,
            Dashboard.class, DashboardBox.class, DashboardBoxType.class);
}
 
Example #13
Source File: CustomRestMvcConfiguration.java    From yugastore-java with Apache License 2.0 5 votes vote down vote up
@Bean
public RepositoryRestConfigurer repositoryRestConfigurer() {

  return new RepositoryRestConfigurerAdapter() {

    @Override
    public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
      config.setBasePath("/api/v1");
      config.exposeIdsFor(ProductMetadata.class, ProductRanking.class);
    }
  };
}
 
Example #14
Source File: BaseUriConfig.java    From spring-content with Apache License 2.0 5 votes vote down vote up
@Bean
public RepositoryRestConfigurer repositoryRestConfigurer() {
	return new RepositoryRestConfigurerAdapter() {

		@Override
		public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
			config.setBasePath("/api");
		}
	};
}
 
Example #15
Source File: SpringRestDataConfig.java    From microservice-kubernetes with Apache License 2.0 5 votes vote down vote up
@Bean
public RepositoryRestConfigurer repositoryRestConfigurer() {

	return new RepositoryRestConfigurerAdapter() {
		@Override
		public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
			config.exposeIdsFor(Customer.class);
		}
	};
}
 
Example #16
Source File: SpringRestDataConfig.java    From microservice-kubernetes with Apache License 2.0 5 votes vote down vote up
@Bean
public RepositoryRestConfigurer repositoryRestConfigurer() {

	return new RepositoryRestConfigurerAdapter() {
		@Override
		public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
			config.exposeIdsFor(Order.class, Item.class, Customer.class);
		}
	};
}
 
Example #17
Source File: DemoApplication.java    From sdn-rx with Apache License 2.0 5 votes vote down vote up
@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
	config.exposeIdsFor(MovieEntity.class, PersonEntity.class);
}
 
Example #18
Source File: BasicPropertyFactoryTest.java    From moserp with Apache License 2.0 5 votes vote down vote up
protected RepositoryRestConfiguration createConfiguration() {
    RepositoryRestConfiguration configuration = mock(RepositoryRestConfiguration.class);
    try {
        when(configuration.getBaseUri()).thenReturn(new URI("http://localhost:8080/"));
    } catch (URISyntaxException e) {
        throw new RuntimeException(e);
    }
    return configuration;
}
 
Example #19
Source File: JsonSchemaBuilderTest.java    From moserp with Apache License 2.0 5 votes vote down vote up
public void setupMocks() throws URISyntaxException {
    configuration = mock(RepositoryRestConfiguration.class);
    when(configuration.getBaseUri()).thenReturn(new URI("http://localhost:8080/"));
    mappings = mock(ResourceMappings.class);
    metaData = mock(ResourceMetadata.class);
    when(metaData.getPath()).thenReturn(new Path("valueLists"));
    PersistentEntity persistentEntity = mock(PersistentEntity.class);
    when(persistentEntities.getPersistentEntity(any())).thenReturn(persistentEntity);
    PersistentProperty persistentProperty = mock(PersistentProperty.class);
    when(persistentEntity.getPersistentProperty(any(String.class))).thenReturn(persistentProperty);
    when(entityLinks.linkFor(any())).thenReturn(BaseUriLinkBuilder.create(new URI("http://localhost:8080/")));
    moduleRegistry = mock(ModuleRegistry.class);
    when(moduleRegistry.getBaseUriForResource(anyString())).thenReturn(new RestUri("http://localhost:8080/valueLists"));
}
 
Example #20
Source File: SpringRestConfiguration.java    From galeb with Apache License 2.0 5 votes vote down vote up
private void setupCors(RepositoryRestConfiguration config) {
    String pathPatternCors = "/**";
    config.getCorsRegistry().addMapping(pathPatternCors);
    CorsConfiguration corsConfiguration = config.getCorsRegistry().getCorsConfigurations().get(pathPatternCors);
    corsConfiguration.addAllowedMethod("PATCH");
    corsConfiguration.addAllowedMethod("DELETE");
}
 
Example #21
Source File: BasicPropertyFactoryTest.java    From moserp with Apache License 2.0 5 votes vote down vote up
protected RepositoryRestConfiguration createConfiguration() {
    RepositoryRestConfiguration configuration = mock(RepositoryRestConfiguration.class);
    try {
        when(configuration.getBaseUri()).thenReturn(new URI("http://localhost:8080/"));
    } catch (URISyntaxException e) {
        throw new RuntimeException(e);
    }
    return configuration;
}
 
Example #22
Source File: ApplicationStructureBuilderTest.java    From moserp with Apache License 2.0 5 votes vote down vote up
public void setupMocks() throws URISyntaxException {
    configuration = mock(RepositoryRestConfiguration.class);
    when(configuration.getBaseUri()).thenReturn(new URI("http://localhost:8080/"));
    mappings = mock(ResourceMappings.class);
    metaData = mock(ResourceMetadata.class);
    when(metaData.getPath()).thenReturn(new Path("valueLists"));
    PersistentEntity persistentEntity = mock(PersistentEntity.class);
    when(persistentEntities.getPersistentEntity(any())).thenReturn(persistentEntity);
    PersistentProperty persistentProperty = mock(PersistentProperty.class);
    when(persistentEntity.getPersistentProperty(any(String.class))).thenReturn(persistentProperty);
    when(entityLinks.linkFor(any())).thenReturn(BaseUriLinkBuilder.create(new URI("http://localhost:8080/")));
    moduleRegistry = mock(ModuleRegistry.class);
    when(moduleRegistry.getBaseUriForResource(anyString())).thenReturn(new RestUri("http://localhost:8080/valueLists"));
}
 
Example #23
Source File: SpringRestDataConfig.java    From microservice-consul with Apache License 2.0 5 votes vote down vote up
@Bean
public RepositoryRestConfigurer repositoryRestConfigurer() {

	return new RepositoryRestConfigurerAdapter() {
		@Override
		public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
			config.exposeIdsFor(Customer.class);
		}
	};
}
 
Example #24
Source File: ApplicationStructureController.java    From moserp with Apache License 2.0 5 votes vote down vote up
@Autowired
public ApplicationStructureController(ApplicationStructureBuilder applicationStructureBuilder, RepositoryRestConfiguration configuration, Repositories repositories, ResourceMappings mappings) {
    Assert.notNull(applicationStructureBuilder, "ApplicationStructureBuilder must not be null!");
    Assert.notNull(configuration, "RepositoryRestConfiguration must not be null!");
    Assert.notNull(repositories, "Repositories must not be null!");
    Assert.notNull(mappings, "ResourceMappings must not be null!");

    this.applicationStructureBuilder = applicationStructureBuilder;
    this.configuration = configuration;
    this.repositories = repositories;
    this.mappings = mappings;
}
 
Example #25
Source File: SpringRestDataConfig.java    From microservice-consul with Apache License 2.0 5 votes vote down vote up
@Bean
public RepositoryRestConfigurer repositoryRestConfigurer() {

	return new RepositoryRestConfigurerAdapter() {
		@Override
		public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
			config.exposeIdsFor(Item.class);
		}
	};
}
 
Example #26
Source File: SpringRestDataConfig.java    From microservice-consul with Apache License 2.0 5 votes vote down vote up
@Bean
public RepositoryRestConfigurer repositoryRestConfigurer() {

	return new RepositoryRestConfigurerAdapter() {
		@Override
		public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
			config.exposeIdsFor(Order.class, Item.class, Customer.class);
		}
	};
}
 
Example #27
Source File: CustomRestMvcConfiguration.java    From spring-data-jpa-demo with Apache License 2.0 5 votes vote down vote up
/**
 * Repository rest configurer repository rest configurer.
 *
 * @return the repository rest configurer
 */
@Bean
public RepositoryRestConfigurer repositoryRestConfigurer() {
    return new RepositoryRestConfigurer() {
        @Override
        public void configureRepositoryRestConfiguration(RepositoryRestConfiguration configuration) {
            configuration.exposeIdsFor(Dept.class, Employee.class);
        }
    };
}
 
Example #28
Source File: MvcConfig.java    From holdmail with Apache License 2.0 5 votes vote down vote up
@Bean
public RepositoryRestConfigurer repositoryRestConfigurer() {

    return new RepositoryRestConfigurerAdapter() {

        @Override
        public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
            config.setDefaultPageSize(150);
        }
    };
}
 
Example #29
Source File: SpringRestDataConfig.java    From microservice-kafka with Apache License 2.0 5 votes vote down vote up
@Bean
public RepositoryRestConfigurer repositoryRestConfigurer() {

	return new RepositoryRestConfigurerAdapter() {
		@Override
		public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
			config.exposeIdsFor(Order.class, Item.class, Customer.class);
		}
	};
}
 
Example #30
Source File: SpringRestDataConfig.java    From microservice-atom with Apache License 2.0 5 votes vote down vote up
@Bean
public RepositoryRestConfigurer repositoryRestConfigurer() {

	return new RepositoryRestConfigurerAdapter() {
		@Override
		public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
			config.exposeIdsFor(Order.class, Item.class, Customer.class);
		}
	};
}