├── .github ├── PULL_REQUEST_TEMPLATE.md ├── dco.yml └── workflows │ └── project.yml ├── .gitignore ├── .mvn ├── extensions.xml ├── jvm.config └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── CONTRIBUTING.adoc ├── Jenkinsfile ├── LICENSE.txt ├── README.adoc ├── SECURITY.adoc ├── ci ├── pipeline.properties └── start-replica.sh ├── formatter.xml ├── mvnw ├── mvnw.cmd ├── pom.xml ├── settings.xml ├── spring-data-rest-core ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── springframework │ │ └── data │ │ └── rest │ │ └── core │ │ ├── AggregateReference.java │ │ ├── AssociationAggregateReference.java │ │ ├── Path.java │ │ ├── RepositoryConstraintViolationException.java │ │ ├── ResolvingAggregateReference.java │ │ ├── StringToLdapNameConverter.java │ │ ├── UriToEntityConverter.java │ │ ├── ValidationErrors.java │ │ ├── annotation │ │ ├── Description.java │ │ ├── HandleAfterCreate.java │ │ ├── HandleAfterDelete.java │ │ ├── HandleAfterLinkDelete.java │ │ ├── HandleAfterLinkSave.java │ │ ├── HandleAfterSave.java │ │ ├── HandleBeforeCreate.java │ │ ├── HandleBeforeDelete.java │ │ ├── HandleBeforeLinkDelete.java │ │ ├── HandleBeforeLinkSave.java │ │ ├── HandleBeforeSave.java │ │ ├── RepositoryEventHandler.java │ │ ├── RepositoryRestResource.java │ │ └── RestResource.java │ │ ├── config │ │ ├── EntityLookupConfiguration.java │ │ ├── EntityLookupRegistrar.java │ │ ├── EnumTranslationConfiguration.java │ │ ├── JsonSchemaFormat.java │ │ ├── MetadataConfiguration.java │ │ ├── Projection.java │ │ ├── ProjectionDefinitionConfiguration.java │ │ ├── RepositoryRestConfiguration.java │ │ ├── ResourceMapping.java │ │ └── ResourceMappingConfiguration.java │ │ ├── event │ │ ├── AbstractRepositoryEventListener.java │ │ ├── AfterCreateEvent.java │ │ ├── AfterDeleteEvent.java │ │ ├── AfterLinkDeleteEvent.java │ │ ├── AfterLinkSaveEvent.java │ │ ├── AfterSaveEvent.java │ │ ├── AnnotatedEventHandlerInvoker.java │ │ ├── BeforeCreateEvent.java │ │ ├── BeforeDeleteEvent.java │ │ ├── BeforeLinkDeleteEvent.java │ │ ├── BeforeLinkSaveEvent.java │ │ ├── BeforeSaveEvent.java │ │ ├── ExceptionEvent.java │ │ ├── LinkedEntityEvent.java │ │ ├── RepositoryEvent.java │ │ └── ValidatingRepositoryEventListener.java │ │ ├── mapping │ │ ├── AnnotationBasedResourceDescription.java │ │ ├── CollectionResourceMapping.java │ │ ├── ComposableFilter.java │ │ ├── ConfigurableHttpMethods.java │ │ ├── ConfigurationApplyingSupportedHttpMethodsAdapter.java │ │ ├── CrudMethodsSupportedHttpMethods.java │ │ ├── EvoInflectorTypeBasedCollectionResourceMapping.java │ │ ├── ExposureConfiguration.java │ │ ├── ExposureConfigurer.java │ │ ├── HttpMethods.java │ │ ├── MappingResourceMetadata.java │ │ ├── MethodResourceMapping.java │ │ ├── ParameterMetadata.java │ │ ├── ParametersMetadata.java │ │ ├── PersistentEntitiesResourceMappings.java │ │ ├── PersistentPropertyResourceMapping.java │ │ ├── PropertyAwareResourceMapping.java │ │ ├── RepositoryAwareResourceMetadata.java │ │ ├── RepositoryCollectionResourceMapping.java │ │ ├── RepositoryDetectionStrategy.java │ │ ├── RepositoryMethodResourceMapping.java │ │ ├── RepositoryResourceMappings.java │ │ ├── ResolvableResourceDescriptionSupport.java │ │ ├── ResourceDescription.java │ │ ├── ResourceMapping.java │ │ ├── ResourceMappings.java │ │ ├── ResourceMetadata.java │ │ ├── ResourceType.java │ │ ├── SearchResourceMappings.java │ │ ├── SimpleResourceDescription.java │ │ ├── SupportedHttpMethods.java │ │ ├── TypeBasedCollectionResourceMapping.java │ │ └── TypedResourceDescription.java │ │ ├── package-info.java │ │ ├── projection │ │ └── ProjectionDefinitions.java │ │ ├── support │ │ ├── DefaultSelfLinkProvider.java │ │ ├── EntityLookup.java │ │ ├── EntityLookupSupport.java │ │ ├── RepositoryRelProvider.java │ │ ├── ResourceMappingUtils.java │ │ ├── ResourceStringUtils.java │ │ ├── SelfLinkProvider.java │ │ ├── SimpleRelProvider.java │ │ └── UnwrappingRepositoryInvokerFactory.java │ │ └── util │ │ └── MapUtils.java │ └── test │ ├── java │ └── org │ │ └── springframework │ │ └── data │ │ └── rest │ │ └── core │ │ ├── AbstractIntegrationTests.java │ │ ├── PathUnitTests.java │ │ ├── RepositoryRestConfigurationIntegrationTests.java │ │ ├── RepositoryRestConfigurationUnitTests.java │ │ ├── RepositoryTestsConfig.java │ │ ├── ResolvingAggregateReferenceUnitTests.java │ │ ├── StringToLdapNameConverterUnitTests.java │ │ ├── UriToEntityConverterUnitTests.java │ │ ├── ValidationErrorsUnitTests.java │ │ ├── config │ │ ├── ProjectionDefinitionConfigurationUnitTests.java │ │ └── ResourceMappingUnitTests.java │ │ ├── context │ │ ├── RepositoryEventIntegrationTests.java │ │ └── ValidatorIntegrationTests.java │ │ ├── domain │ │ ├── AnnotatedPersonEventHandler.java │ │ ├── AnnotatedPersonRepository.java │ │ ├── Author.java │ │ ├── AuthorRepository.java │ │ ├── ConfiguredPersonRepository.java │ │ ├── CreditCard.java │ │ ├── CreditCardRepository.java │ │ ├── EventHandlerInvokedException.java │ │ ├── JpaRepositoryConfig.java │ │ ├── Order.java │ │ ├── OrderRepository.java │ │ ├── Person.java │ │ ├── PersonBeforeSaveHandler.java │ │ ├── PersonNameValidator.java │ │ ├── PersonRepository.java │ │ ├── PlainPersonRepository.java │ │ ├── Profile.java │ │ ├── ProfileLoader.java │ │ └── ProfileRepository.java │ │ ├── event │ │ └── AnnotatedEventHandlerInvokerUnitTests.java │ │ ├── mapping │ │ ├── CrudMethodsSupportedHttpMethodsUnitTests.java │ │ ├── ExposureConfigurationUnitTests.java │ │ ├── MappingResourceMetadataUnitTests.java │ │ ├── PersistentEntitiesResourceMappingsUnitTests.java │ │ ├── PersistentPropertyResourceMappingUnitTests.java │ │ ├── RepositoryCollectionResourceMappingUnitTests.java │ │ ├── RepositoryDetectionStrategiesUnitTests.java │ │ ├── RepositoryMethodResourceMappingUnitTests.java │ │ ├── RepositoryResourceMappingsIntegrationTests.java │ │ └── TypeBasedCollectionResourceMappingUnitTests.java │ │ └── support │ │ ├── DefaultSelfLinkProviderUnitTests.java │ │ ├── RepositoryRelProviderUnitTests.java │ │ ├── ResourceStringUtilsTests.java │ │ └── UnwrappingRepositoryInvokerFactoryUnitTests.java │ └── resources │ ├── ValidationErrors.properties │ └── logback.xml ├── spring-data-rest-distribution ├── package.json └── pom.xml ├── spring-data-rest-hal-explorer ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── springframework │ │ │ └── data │ │ │ └── rest │ │ │ └── webmvc │ │ │ └── halexplorer │ │ │ ├── HalExplorer.java │ │ │ └── HalExplorerConfiguration.java │ └── resources │ │ └── META-INF │ │ ├── native-image │ │ └── org.springframework.data │ │ │ └── spring-data-rest-hal-explorer │ │ │ └── resource-config.json │ │ └── spring.factories │ └── test │ ├── java │ └── org │ │ └── springframework │ │ └── data │ │ └── rest │ │ └── webmvc │ │ └── halexplorer │ │ ├── HalExplorerIntegrationTests.java │ │ └── HalExplorerUnitTests.java │ └── resources │ └── logback.xml ├── spring-data-rest-tests ├── pom.xml ├── spring-data-rest-tests-core │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── org │ │ │ └── springframework │ │ │ └── data │ │ │ └── rest │ │ │ └── tests │ │ │ ├── AbstractControllerIntegrationTests.java │ │ │ ├── AbstractWebIntegrationTests.java │ │ │ ├── CommonWebTests.java │ │ │ ├── RepositoryTestsConfig.java │ │ │ ├── RequestParameters.java │ │ │ ├── ResourceTester.java │ │ │ ├── TestMatchers.java │ │ │ └── TestMvcClient.java │ │ └── resources │ │ └── logback.xml ├── spring-data-rest-tests-jpa │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── springframework │ │ │ └── data │ │ │ └── rest │ │ │ └── webmvc │ │ │ └── jpa │ │ │ ├── Address.java │ │ │ ├── AddressRepository.java │ │ │ ├── AssignableSequenceStyleGenerator.java │ │ │ ├── Author.java │ │ │ ├── AuthorRepository.java │ │ │ ├── AuthorsController.java │ │ │ ├── Book.java │ │ │ ├── BookExcerpt.java │ │ │ ├── BookIdConverter.java │ │ │ ├── BookRepository.java │ │ │ ├── Category.java │ │ │ ├── CategoryProjection.java │ │ │ ├── CategoryRepository.java │ │ │ ├── CreditCard.java │ │ │ ├── CreditCardRepository.java │ │ │ ├── Dinner.java │ │ │ ├── Guest.java │ │ │ ├── Item.java │ │ │ ├── ItemRepository.java │ │ │ ├── LineItem.java │ │ │ ├── Meal.java │ │ │ ├── Order.java │ │ │ ├── OrderRepository.java │ │ │ ├── OrderSummary.java │ │ │ ├── Person.java │ │ │ ├── PersonRepository.java │ │ │ ├── PersonSummary.java │ │ │ ├── Receipt.java │ │ │ ├── ReceiptRepository.java │ │ │ ├── Room.java │ │ │ ├── SequenceGenerator.java │ │ │ ├── Suite.java │ │ │ ├── Type.java │ │ │ ├── User.java │ │ │ ├── UserExcerpt.java │ │ │ └── UserRepository.java │ │ └── test │ │ ├── java │ │ └── org │ │ │ └── springframework │ │ │ └── data │ │ │ └── rest │ │ │ └── webmvc │ │ │ ├── RepositoryControllerIntegrationTests.java │ │ │ ├── RepositoryEntityControllerIntegrationTests.java │ │ │ ├── RepositoryPropertyReferenceControllerIntegrationTests.java │ │ │ ├── RepositorySearchControllerIntegrationTests.java │ │ │ ├── RootResourceInformationIntegrationTests.java │ │ │ ├── alps │ │ │ └── AlpsControllerIntegrationTests.java │ │ │ ├── jpa │ │ │ ├── CorsIntegrationTests.java │ │ │ ├── DataRest262Tests.java │ │ │ ├── DataRest363Tests.java │ │ │ ├── JpaDefaultPageableWebTests.java │ │ │ ├── JpaInfrastructureConfig.java │ │ │ ├── JpaRepositoryConfig.java │ │ │ ├── JpaWebTests.java │ │ │ ├── LocalConfigCorsIntegrationTests.java │ │ │ ├── ProfileIntegrationTests.java │ │ │ ├── TestDataPopulator.java │ │ │ └── groovy │ │ │ │ ├── SimulatedGroovyDomainClass.java │ │ │ │ └── SimulatedGroovyDomainClassRepository.java │ │ │ ├── json │ │ │ ├── Jackson2DatatypeHelperIntegrationTests.java │ │ │ ├── PersistentEntitySerializationTests.java │ │ │ └── RepositoryTestsConfig.java │ │ │ ├── support │ │ │ ├── BackendIdConverterHandlerMethodArgumentResolverIntegrationTests.java │ │ │ ├── ExceptionHandlingCustomizationIntegrationTests.java │ │ │ └── RepositoryEntityLinksIntegrationTests.java │ │ │ └── util │ │ │ └── TestUtils.java │ │ └── resources │ │ └── org │ │ └── springframework │ │ └── data │ │ └── rest │ │ └── webmvc │ │ └── jpa │ │ ├── order.json │ │ └── person.json ├── spring-data-rest-tests-mongodb │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── springframework │ │ │ └── data │ │ │ └── rest │ │ │ └── tests │ │ │ └── mongodb │ │ │ ├── Address.java │ │ │ ├── Profile.java │ │ │ ├── ProfileRepository.java │ │ │ ├── Receipt.java │ │ │ ├── ReceiptRepository.java │ │ │ ├── User.java │ │ │ ├── UserRepository.java │ │ │ ├── UserSummary.java │ │ │ └── groovy │ │ │ ├── SimulatedGroovyDomainClass.java │ │ │ └── SimulatedGroovyDomainClassRepository.java │ │ └── test │ │ ├── java │ │ └── org │ │ │ └── springframework │ │ │ └── data │ │ │ └── rest │ │ │ ├── tests │ │ │ └── mongodb │ │ │ │ ├── MongoDbRepositoryConfig.java │ │ │ │ ├── MongoWebTests.java │ │ │ │ └── TestUtils.java │ │ │ └── webmvc │ │ │ ├── PersistentEntityResourceAssemblerIntegrationTests.java │ │ │ ├── RepositoryRestHandlerMappingIntegrationTests.java │ │ │ ├── config │ │ │ ├── AbstractRepositoryRestMvcConfigurationIntegrationTests.java │ │ │ ├── JsonPatchHandlerUnitTests.java │ │ │ └── QuerydslAwareRootResourceInformationHandlerMethodArgumentResolverUnitTests.java │ │ │ ├── json │ │ │ ├── PersistentEntitySerializationTests.java │ │ │ └── PersistentEntityToJsonSchemaConverterUnitTests.java │ │ │ └── support │ │ │ └── RepositoryLinkBuildUnitTests.java │ │ └── resources │ │ └── rest-messages.properties ├── spring-data-rest-tests-security │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── springframework │ │ │ └── data │ │ │ └── rest │ │ │ └── tests │ │ │ └── security │ │ │ ├── Order.java │ │ │ └── Person.java │ │ └── test │ │ └── java │ │ └── org │ │ └── springframework │ │ └── data │ │ └── rest │ │ └── tests │ │ └── security │ │ ├── PreAuthorizedOrderRepository.java │ │ ├── SecuredPersonRepository.java │ │ ├── SecurityConfiguration.java │ │ └── SecurityIntegrationTests.java └── spring-data-rest-tests-shop │ ├── pom.xml │ └── src │ ├── main │ └── java │ │ └── org │ │ └── springframework │ │ └── data │ │ └── rest │ │ └── tests │ │ └── shop │ │ ├── Address.java │ │ ├── CustomController.java │ │ ├── Customer.java │ │ ├── CustomerExcerpt.java │ │ ├── CustomerRepository.java │ │ ├── LineItem.java │ │ ├── LineItemType.java │ │ ├── LineItemTypeRepository.java │ │ ├── Order.java │ │ ├── OrderRepository.java │ │ ├── Product.java │ │ ├── ProductExcerpt.java │ │ └── ProductRepository.java │ └── test │ └── java │ └── org │ └── springframework │ └── data │ └── rest │ └── tests │ └── shop │ ├── ShopConfiguration.java │ └── ShopIntegrationTests.java ├── spring-data-rest-webmvc ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── springframework │ │ │ └── data │ │ │ └── rest │ │ │ └── webmvc │ │ │ ├── BasePathAwareController.java │ │ │ ├── BasePathAwareHandlerMapping.java │ │ │ ├── BaseUri.java │ │ │ ├── ControllerUtils.java │ │ │ ├── EmbeddedResourcesAssembler.java │ │ │ ├── HttpHeadersPreparer.java │ │ │ ├── IncomingRequest.java │ │ │ ├── PersistentEntityResource.java │ │ │ ├── PersistentEntityResourceAssembler.java │ │ │ ├── ProfileController.java │ │ │ ├── ProfileResourceProcessor.java │ │ │ ├── RepositoryController.java │ │ │ ├── RepositoryEntityController.java │ │ │ ├── RepositoryLinksResource.java │ │ │ ├── RepositoryPropertyReferenceController.java │ │ │ ├── RepositoryRestController.java │ │ │ ├── RepositoryRestDispatcherServlet.java │ │ │ ├── RepositoryRestExceptionHandler.java │ │ │ ├── RepositoryRestHandlerAdapter.java │ │ │ ├── RepositoryRestHandlerMapping.java │ │ │ ├── RepositorySchemaController.java │ │ │ ├── RepositorySearchController.java │ │ │ ├── RepositorySearchesResource.java │ │ │ ├── RepresentationModelAssemblers.java │ │ │ ├── ResourceNotFoundException.java │ │ │ ├── ResourceStatus.java │ │ │ ├── RestControllerConfiguration.java │ │ │ ├── RestMediaTypes.java │ │ │ ├── RootResourceInformation.java │ │ │ ├── alps │ │ │ ├── AlpsController.java │ │ │ ├── AlpsJsonHttpMessageConverter.java │ │ │ └── RootResourceInformationToAlpsDescriptorConverter.java │ │ │ ├── aot │ │ │ ├── BasePathAwareControllerAotProcessor.java │ │ │ ├── ProjectionProxyAotProcessor.java │ │ │ ├── RestMessagesResourcesRuntimeHints.java │ │ │ ├── ValueInstantiatorCustomizerRuntimeHints.java │ │ │ └── package-info.java │ │ │ ├── config │ │ │ ├── ArgumentResolverPagingAndSortingTemplateVariables.java │ │ │ ├── CorsConfigurationAware.java │ │ │ ├── DelegatingHandlerMapping.java │ │ │ ├── HalFormsAdaptingResponseBodyAdvice.java │ │ │ ├── JMoleculesConfigurer.java │ │ │ ├── JsonPatchHandler.java │ │ │ ├── PersistentEntityResourceAssemblerArgumentResolver.java │ │ │ ├── PersistentEntityResourceHandlerMethodArgumentResolver.java │ │ │ ├── ProjectionDefinitionRegistar.java │ │ │ ├── QuerydslAwareRootResourceInformationHandlerMethodArgumentResolver.java │ │ │ ├── RepositoryCorsRegistry.java │ │ │ ├── RepositoryRestConfigurer.java │ │ │ ├── RepositoryRestConfigurerDelegate.java │ │ │ ├── RepositoryRestMvcConfiguration.java │ │ │ ├── RepresentationModelAssemblersArgumentResolver.java │ │ │ ├── ResourceMetadataHandlerMethodArgumentResolver.java │ │ │ ├── RestControllerImportSelector.java │ │ │ ├── RootResourceInformationHandlerMethodArgumentResolver.java │ │ │ ├── StaticResourceProvider.java │ │ │ ├── StringToAggregateReferenceConverter.java │ │ │ └── WebMvcRepositoryRestConfiguration.java │ │ │ ├── convert │ │ │ └── UriListHttpMessageConverter.java │ │ │ ├── json │ │ │ ├── AggregateReferenceResolvingModule.java │ │ │ ├── BindContextFactory.java │ │ │ ├── DomainObjectReader.java │ │ │ ├── EnumTranslator.java │ │ │ ├── Jackson2DatatypeHelper.java │ │ │ ├── JacksonBindContext.java │ │ │ ├── JacksonMappingAwareSortTranslator.java │ │ │ ├── JacksonMetadata.java │ │ │ ├── JacksonSerializers.java │ │ │ ├── JsonSchema.java │ │ │ ├── JsonSchemaPropertyCustomizer.java │ │ │ ├── MappedProperties.java │ │ │ ├── MappingAwareDefaultedPageableArgumentResolver.java │ │ │ ├── MappingAwarePageableArgumentResolver.java │ │ │ ├── MappingAwareSortArgumentResolver.java │ │ │ ├── PersistentEntitiesBindContextFactory.java │ │ │ ├── PersistentEntityJackson2Module.java │ │ │ ├── PersistentEntityToJsonSchemaConverter.java │ │ │ ├── WrappedProperties.java │ │ │ ├── package-info.java │ │ │ └── patch │ │ │ │ ├── AddOperation.java │ │ │ │ ├── BindContext.java │ │ │ │ ├── CopyOperation.java │ │ │ │ ├── JsonLateObjectEvaluator.java │ │ │ │ ├── JsonPatchPatchConverter.java │ │ │ │ ├── JsonPointerMapping.java │ │ │ │ ├── LateObjectEvaluator.java │ │ │ │ ├── MoveOperation.java │ │ │ │ ├── Patch.java │ │ │ │ ├── PatchConverter.java │ │ │ │ ├── PatchException.java │ │ │ │ ├── PatchOperation.java │ │ │ │ ├── RemoveOperation.java │ │ │ │ ├── ReplaceOperation.java │ │ │ │ ├── SpelPath.java │ │ │ │ ├── TestOperation.java │ │ │ │ └── package-info.java │ │ │ ├── mapping │ │ │ ├── Associations.java │ │ │ ├── DefaultLinkCollector.java │ │ │ └── LinkCollector.java │ │ │ ├── package-info.java │ │ │ ├── spi │ │ │ └── BackendIdConverter.java │ │ │ ├── support │ │ │ ├── BackendId.java │ │ │ ├── BackendIdHandlerMethodArgumentResolver.java │ │ │ ├── ConstraintViolationExceptionMessage.java │ │ │ ├── ConstraintViolationMessage.java │ │ │ ├── DefaultExcerptProjector.java │ │ │ ├── DefaultedPageable.java │ │ │ ├── DefaultedPageableHandlerMethodArgumentResolver.java │ │ │ ├── DomainClassResolver.java │ │ │ ├── ETag.java │ │ │ ├── ETagArgumentResolver.java │ │ │ ├── ETagDoesntMatchException.java │ │ │ ├── ExceptionMessage.java │ │ │ ├── ExcerptProjector.java │ │ │ ├── HttpMethodHandlerMethodArgumentResolver.java │ │ │ ├── JpaHelper.java │ │ │ ├── PagingAndSortingTemplateVariables.java │ │ │ ├── PersistentEntityProjector.java │ │ │ ├── PersistentEntityResourceProcessor.java │ │ │ ├── Projector.java │ │ │ ├── RepositoryConstraintViolationExceptionMessage.java │ │ │ ├── RepositoryEntityLinks.java │ │ │ └── RepositoryLinkBuilder.java │ │ │ └── util │ │ │ ├── InputStreamHttpInputMessage.java │ │ │ └── UriUtils.java │ └── resources │ │ ├── META-INF │ │ └── spring │ │ │ └── aot.factories │ │ └── rest-default-messages.properties │ └── test │ ├── java │ └── org │ │ └── springframework │ │ └── data │ │ └── rest │ │ └── webmvc │ │ ├── AssociationLinksUnitTests.java │ │ ├── AugmentingHandlerMappingUnitTests.java │ │ ├── BasePathAwareHandlerMappingUnitTests.java │ │ ├── BaseUriUnitTests.java │ │ ├── CustomAcceptHeaderHttpServletRequestUnitTests.java │ │ ├── IncomingRequestUnitTests.java │ │ ├── PersistentEntityResourceUnitTests.java │ │ ├── RepositoryCorsConfigurationAccessorUnitTests.java │ │ ├── RepositoryEntityControllerTest.java │ │ ├── RepositoryPropertyReferenceControllerUnitTests.java │ │ ├── RepositoryRestExceptionHandlerUnitTests.java │ │ ├── RepositoryRestHandlerMappingUnitTests.java │ │ ├── RepositorySearchesResourceUnitTests.java │ │ ├── Requests.java │ │ ├── ResourceStatusUnitTests.java │ │ ├── RootResourceInformationUnitTests.java │ │ ├── ValidationErrors.properties │ │ ├── aot │ │ └── ValueInstantiatorCustomizerRuntimeHintsUnitTests.java │ │ ├── config │ │ ├── ArgumentResolverPagingAndSortingTemplateVariablesUnitTests.java │ │ ├── DelegatingHandlerMappingUnitTests.java │ │ ├── HalFormsAdaptingResponseBodyAdviceTests.java │ │ ├── PersistentEntityResourceHandlerMethodArgumentResolverUnitTests.java │ │ ├── RepositoryRestMvConfigurationIntegrationTests.java │ │ ├── ResourceMetadataHandlerMethodArgumentResolverUnitTests.java │ │ └── StringToAggregateReferenceConverterUnitTests.java │ │ ├── json │ │ ├── AggregateReferenceResolvingModuleUnitTests.java │ │ ├── DomainObjectReaderUnitTests.java │ │ ├── EnumTranslatorUnitTests.java │ │ ├── JacksonMetadataUnitTests.java │ │ ├── JacksonSerializersUnitTests.java │ │ ├── JsonSchemaUnitTests.java │ │ ├── MappedPropertiesUnitTests.java │ │ ├── MappingAwarePageableArgumentResolverUnitTests.java │ │ ├── PersistentEntityJackson2ModuleUnitTests.java │ │ ├── ProjectionJacksonIntegrationTests.java │ │ ├── SortTranslatorUnitTests.java │ │ ├── UriStringDeserializerUnitTests.java │ │ ├── WrappedPropertiesUnitTests.java │ │ └── patch │ │ │ ├── AddOperationUnitTests.java │ │ │ ├── CopyOperationUnitTests.java │ │ │ ├── JsonPatchUnitTests.java │ │ │ ├── JsonPointerMappingTests.java │ │ │ ├── MoveOperationUnitTests.java │ │ │ ├── PatchOperationUnitTests.java │ │ │ ├── RemoveOperationTests.java │ │ │ ├── ReplaceOperationTests.java │ │ │ ├── SpelPathUnitTests.java │ │ │ ├── TestOperationUnitTests.java │ │ │ ├── TestPropertyPathContext.java │ │ │ ├── Todo.java │ │ │ ├── TodoList.java │ │ │ └── TodoType.java │ │ ├── mapping │ │ └── AssociationsUnitTests.java │ │ ├── support │ │ ├── BackendIdHandlerMethodArgumentResolverUnitTests.java │ │ ├── DefaultExcerptProjectorUnitTests.java │ │ ├── ETagDoesntMatchExceptionUnitTests.java │ │ ├── ETagUnitTests.java │ │ ├── PersistentEntityProjectorUnitTests.java │ │ └── RepositoryConstraintViolationExceptionMessageUnitTests.java │ │ └── util │ │ ├── AssertionUtils.java │ │ └── UriUtilsUnitTests.java │ └── resources │ ├── cassandra.yaml │ ├── logback.xml │ └── org │ └── springframework │ └── data │ └── rest │ └── webmvc │ └── json │ └── patch │ ├── patch-array.json │ ├── patch-biginteger.json │ ├── patch-failing-operation-first.json │ ├── patch-failing-operation-in-middle.json │ ├── patch-failing-with-invalid-content.json │ ├── patch-invalid-path.json │ └── patch-many-successful-operations.json └── src └── main ├── antora ├── antora-playbook.yml ├── antora.yml ├── modules │ └── ROOT │ │ ├── examples │ │ ├── mongodb │ │ ├── security │ │ └── support │ │ ├── images │ │ ├── hal-explorer-1.png │ │ ├── hal-explorer-2.png │ │ └── hal-explorer-3.png │ │ ├── nav.adoc │ │ └── pages │ │ ├── customizing-sdr.adoc │ │ ├── customizing │ │ ├── adding-sdr-to-spring-mvc-app.adoc │ │ ├── configuring-cors.adoc │ │ ├── configuring-the-rest-url-path.adoc │ │ ├── custom-jackson-deserialization.adoc │ │ ├── customizing-json-output.adoc │ │ └── overriding-sdr-response-handlers.adoc │ │ ├── etags-and-other-conditionals.adoc │ │ ├── events.adoc │ │ ├── index.adoc │ │ ├── integration.adoc │ │ ├── intro.adoc │ │ ├── introduction │ │ ├── example-api-usage-with-curl.adoc │ │ ├── getting-started.adoc │ │ ├── spring-data-rest-examples.adoc │ │ └── upgrade.adoc │ │ ├── metadata.adoc │ │ ├── paging-and-sorting.adoc │ │ ├── projections-excerpts.adoc │ │ ├── repository-resources.adoc │ │ ├── representations.adoc │ │ ├── security.adoc │ │ ├── tools.adoc │ │ └── validation.adoc └── resources │ └── antora-resources │ └── antora.yml ├── asciidoc └── images │ ├── epub-cover.png │ ├── epub-cover.svg │ ├── hal-explorer-1.png │ ├── hal-explorer-2.png │ └── hal-explorer-3.png └── resources ├── license.txt └── notice.txt /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | - [ ] You have read the [Spring Data contribution guidelines](https://github.com/spring-projects/spring-data-build/blob/master/CONTRIBUTING.adoc). 9 | - [ ] You use the code formatters provided [here](https://github.com/spring-projects/spring-data-build/tree/master/etc/ide) and have them applied to your changes. Don’t submit any formatting related changes. 10 | - [ ] You submit test cases (unit or integration tests) that back your changes. 11 | - [ ] You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only). 12 | -------------------------------------------------------------------------------- /.github/dco.yml: -------------------------------------------------------------------------------- 1 | require: 2 | members: false 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .gradle/ 3 | bin/ 4 | build/ 5 | target/ 6 | *.i* 7 | .classpath 8 | .project 9 | .settings 10 | .externalToolBuilders 11 | *.log 12 | vf.gf.* 13 | out/ 14 | _site 15 | node_modules 16 | package-lock.json 17 | node 18 | .mvn/.develocity 19 | -------------------------------------------------------------------------------- /.mvn/extensions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | io.spring.develocity.conventions 5 | develocity-conventions-maven-extension 6 | 0.0.22 7 | 8 | 9 | -------------------------------------------------------------------------------- /.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED 2 | --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED 3 | --add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED 4 | --add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED 5 | --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED 6 | --add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED 7 | --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED 8 | --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED 9 | --add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED 10 | --add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED 11 | --add-opens=java.base/java.util=ALL-UNNAMED 12 | --add-opens=java.base/java.lang.reflect=ALL-UNNAMED 13 | --add-opens=java.base/java.text=ALL-UNNAMED 14 | --add-opens=java.desktop/java.awt.font=ALL-UNNAMED 15 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-projects/spring-data-rest/a6889a70e4d6623d7398f99cc987b9036250bedc/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Nov 07 09:47:24 CET 2024 2 | distributionUrl=https\://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 3 | -------------------------------------------------------------------------------- /CONTRIBUTING.adoc: -------------------------------------------------------------------------------- 1 | = Spring Data contribution guidelines 2 | 3 | You find the contribution guidelines for Spring Data projects https://github.com/spring-projects/spring-data-build/blob/main/CONTRIBUTING.adoc[here]. 4 | -------------------------------------------------------------------------------- /SECURITY.adoc: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Please see the https://spring.io/projects/spring-data-rest[Spring Data REST] project page for supported versions. 6 | 7 | ## Reporting a Vulnerability 8 | 9 | Please don't raise security vulnerabilities here. Head over to https://pivotal.io/security to learn how to disclose them responsibly. 10 | -------------------------------------------------------------------------------- /ci/pipeline.properties: -------------------------------------------------------------------------------- 1 | # Java versions 2 | java.main.tag=24.0.1_9-jdk-noble 3 | java.next.tag=24.0.1_9-jdk-noble 4 | 5 | # Docker container images - standard 6 | docker.java.main.image=library/eclipse-temurin:${java.main.tag} 7 | docker.java.next.image=library/eclipse-temurin:${java.next.tag} 8 | 9 | # Supported versions of MongoDB 10 | docker.mongodb.6.0.version=6.0.23 11 | docker.mongodb.7.0.version=7.0.20 12 | docker.mongodb.8.0.version=8.0.9 13 | 14 | # Supported versions of Redis 15 | docker.redis.6.version=6.2.13 16 | docker.redis.7.version=7.2.4 17 | 18 | # Docker environment settings 19 | docker.java.inside.basic=-v $HOME:/tmp/jenkins-home 20 | docker.java.inside.docker=-u root -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker -v $HOME:/tmp/jenkins-home 21 | 22 | # Credentials 23 | docker.registry= 24 | docker.credentials=hub.docker.com-springbuildmaster 25 | docker.proxy.registry=https://docker-hub.usw1.packages.broadcom.com 26 | docker.proxy.credentials=usw1_packages_broadcom_com-jenkins-token 27 | artifactory.credentials=02bd1690-b54f-4c9f-819d-a77cb7a9822c 28 | artifactory.url=https://repo.spring.io 29 | artifactory.repository.snapshot=libs-snapshot-local 30 | develocity.access-key=gradle_enterprise_secret_access_key 31 | jenkins.user.name=spring-builds+jenkins 32 | -------------------------------------------------------------------------------- /ci/start-replica.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mkdir -p /tmp/mongodb/db /tmp/mongodb/log 3 | mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log & 4 | sleep 10 5 | mongosh --eval "rs.initiate({_id: 'rs0', members:[{_id: 0, host: '127.0.0.1:27017'}]});" 6 | sleep 15 7 | -------------------------------------------------------------------------------- /settings.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | spring-plugins-release 9 | ${env.ARTIFACTORY_USR} 10 | ${env.ARTIFACTORY_PSW} 11 | 12 | 13 | spring-libs-snapshot 14 | ${env.ARTIFACTORY_USR} 15 | ${env.ARTIFACTORY_PSW} 16 | 17 | 18 | spring-libs-milestone 19 | ${env.ARTIFACTORY_USR} 20 | ${env.ARTIFACTORY_PSW} 21 | 22 | 23 | spring-libs-release 24 | ${env.ARTIFACTORY_USR} 25 | ${env.ARTIFACTORY_PSW} 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/RepositoryConstraintViolationException.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.core; 2 | 3 | import org.springframework.dao.DataIntegrityViolationException; 4 | import org.springframework.validation.Errors; 5 | 6 | /** 7 | * Exception that is thrown when a Spring {@link org.springframework.validation.Validator} throws an error. 8 | * 9 | * @author Jon Brisbin 10 | */ 11 | public class RepositoryConstraintViolationException extends DataIntegrityViolationException { 12 | 13 | private static final long serialVersionUID = -4789377071564956366L; 14 | 15 | private final Errors errors; 16 | 17 | public RepositoryConstraintViolationException(Errors errors) { 18 | super("Validation failed"); 19 | this.errors = errors; 20 | } 21 | 22 | public Errors getErrors() { 23 | return errors; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/StringToLdapNameConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core; 17 | 18 | import javax.naming.InvalidNameException; 19 | import javax.naming.Name; 20 | import javax.naming.ldap.LdapName; 21 | 22 | import org.springframework.core.convert.converter.Converter; 23 | 24 | /** 25 | * {@link Converter} to convert a {@link String} to a {@link LdapName}. 26 | * 27 | * @author Mark Paluch 28 | * @since 3.0.8 29 | */ 30 | public enum StringToLdapNameConverter implements Converter { 31 | 32 | INSTANCE; 33 | 34 | @Override 35 | public LdapName convert(String source) { 36 | 37 | try { 38 | return new LdapName(source); 39 | } catch (InvalidNameException e) { 40 | throw new IllegalArgumentException(String.format("Cannot create LdapName for '%s'", source), e); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/annotation/Description.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.data.rest.core.annotation; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Annotation to describe semantics of a resource. 26 | * 27 | * @author Jon Brisbin 28 | * @author Oliver Gierke 29 | */ 30 | @Target({ ElementType.FIELD, ElementType.METHOD, ElementType.TYPE }) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | public @interface Description { 33 | 34 | /** 35 | * The textual description of the resource. Can be a resource bundle key for internationalization. 36 | * 37 | * @return 38 | */ 39 | String value(); 40 | } 41 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/annotation/HandleAfterCreate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Inherited; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * @author Jon Brisbin 26 | * @author Oliver Gierke 27 | */ 28 | @Target({ ElementType.TYPE, ElementType.METHOD }) 29 | @Retention(RetentionPolicy.RUNTIME) 30 | @Inherited 31 | public @interface HandleAfterCreate { 32 | 33 | /** 34 | * The domain type which you want to listen for events for. 35 | * 36 | * @deprecated the domain type of interest is derived from the type of the first parameter of the annotated handler 37 | * method. 38 | * @return 39 | */ 40 | @Deprecated 41 | Class[] value() default {}; 42 | } 43 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/annotation/HandleAfterDelete.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Inherited; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Denotes a component that should handle the {@literal afterDelete} event. 26 | * 27 | * @author Jon Brisbin 28 | * @author Oliver Gierke 29 | */ 30 | @Target({ ElementType.TYPE, ElementType.METHOD }) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Inherited 33 | public @interface HandleAfterDelete { 34 | 35 | /** 36 | * The domain type which you want to listen for events for. 37 | * 38 | * @deprecated the domain type of interest is derived from the type of the first parameter of the annotated handler 39 | * method. 40 | * @return 41 | */ 42 | @Deprecated 43 | Class[] value() default {}; 44 | } 45 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/annotation/HandleAfterLinkDelete.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Inherited; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Denotes a component that should handle the {@literal afterLinkDelete} event. 26 | * 27 | * @author Jon Brisbin 28 | * @author Oliver Gierke 29 | */ 30 | @Target({ ElementType.TYPE, ElementType.METHOD }) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Inherited 33 | public @interface HandleAfterLinkDelete { 34 | 35 | /** 36 | * The domain type which you want to listen for events for. 37 | * 38 | * @deprecated the domain type of interest is derived from the type of the first parameter of the annotated handler 39 | * method. 40 | * @return 41 | */ 42 | @Deprecated 43 | Class[] value() default {}; 44 | } 45 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/annotation/HandleAfterLinkSave.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Inherited; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Denotes a component that should handle the {@literal afterLinkSave} event. 26 | * 27 | * @author Jon Brisbin 28 | * @author Oliver Gierke 29 | */ 30 | @Target({ ElementType.TYPE, ElementType.METHOD }) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Inherited 33 | public @interface HandleAfterLinkSave { 34 | 35 | /** 36 | * The domain type which you want to listen for events for. 37 | * 38 | * @deprecated the domain type of interest is derived from the type of the first parameter of the annotated handler 39 | * method. 40 | * @return 41 | */ 42 | @Deprecated 43 | Class[] value() default {}; 44 | } 45 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/annotation/HandleAfterSave.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Inherited; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Denotes a component that should handle the {@literal afterSave} event. 26 | * 27 | * @author Jon Brisbin 28 | * @author Oliver Gierke 29 | */ 30 | @Target({ ElementType.TYPE, ElementType.METHOD }) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Inherited 33 | public @interface HandleAfterSave { 34 | 35 | /** 36 | * The domain type which you want to listen for events for. 37 | * 38 | * @deprecated the domain type of interest is derived from the type of the first parameter of the annotated handler 39 | * method. 40 | * @return 41 | */ 42 | @Deprecated 43 | Class[] value() default {}; 44 | } 45 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/annotation/HandleBeforeCreate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Inherited; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * @author Jon Brisbin 26 | * @author Oliver Gierke 27 | */ 28 | @Target({ ElementType.TYPE, ElementType.METHOD }) 29 | @Retention(RetentionPolicy.RUNTIME) 30 | @Inherited 31 | public @interface HandleBeforeCreate { 32 | 33 | /** 34 | * The domain type which you want to listen for events for. 35 | * 36 | * @deprecated the domain type of interest is derived from the type of the first parameter of the annotated handler 37 | * method. 38 | * @return 39 | */ 40 | @Deprecated 41 | Class[] value() default {}; 42 | } 43 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/annotation/HandleBeforeDelete.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Inherited; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Denotes a component that should handle the {@literal beforeDelete} event. 26 | * 27 | * @author Jon Brisbin 28 | * @author Oliver Gierke 29 | */ 30 | @Target({ ElementType.TYPE, ElementType.METHOD }) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Inherited 33 | public @interface HandleBeforeDelete { 34 | 35 | /** 36 | * The domain type which you want to listen for events for. 37 | * 38 | * @deprecated the domain type of interest is derived from the type of the first parameter of the annotated handler 39 | * method. 40 | * @return 41 | */ 42 | @Deprecated 43 | Class[] value() default {}; 44 | } 45 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/annotation/HandleBeforeLinkDelete.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Inherited; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Denotes a component that should handle the {@literal beforeLinkDelete} event. 26 | * 27 | * @author Jon Brisbin 28 | * @author Oliver Gierke 29 | */ 30 | @Target({ ElementType.TYPE, ElementType.METHOD }) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Inherited 33 | public @interface HandleBeforeLinkDelete { 34 | 35 | /** 36 | * The domain type which you want to listen for events for. 37 | * 38 | * @deprecated the domain type of interest is derived from the type of the first parameter of the annotated handler 39 | * method. 40 | * @return 41 | */ 42 | @Deprecated 43 | Class[] value() default {}; 44 | } 45 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/annotation/HandleBeforeLinkSave.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Inherited; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Denotes a component that should handle the {@literal beforeLinkSave} event. 26 | * 27 | * @author Jon Brisbin 28 | * @author Oliver Gierke 29 | */ 30 | @Target({ ElementType.TYPE, ElementType.METHOD }) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Inherited 33 | public @interface HandleBeforeLinkSave { 34 | 35 | /** 36 | * The domain type which you want to listen for events for. 37 | * 38 | * @deprecated the domain type of interest is derived from the type of the first parameter of the annotated handler 39 | * method. 40 | * @return 41 | */ 42 | @Deprecated 43 | Class[] value() default {}; 44 | } 45 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/annotation/HandleBeforeSave.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Inherited; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Denotes a component that should handle the {@literal beforeSave} event. 26 | * 27 | * @author Jon Brisbin 28 | * @author Oliver Gierke 29 | */ 30 | @Target({ ElementType.TYPE, ElementType.METHOD }) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Inherited 33 | public @interface HandleBeforeSave { 34 | 35 | /** 36 | * The domain type which you want to listen for events for. 37 | * 38 | * @deprecated the domain type of interest is derived from the type of the first parameter of the annotated handler 39 | * method. 40 | * @return 41 | */ 42 | @Deprecated 43 | Class[] value() default {}; 44 | } 45 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/annotation/RepositoryEventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Inherited; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Advertises classes annotated with this that they are event handlers. 26 | * 27 | * @author Jon Brisbin 28 | * @author Oliver Gierke 29 | */ 30 | @Target({ ElementType.TYPE }) 31 | @Retention(RetentionPolicy.RUNTIME) 32 | @Inherited 33 | public @interface RepositoryEventHandler { 34 | 35 | /** 36 | * The list of {@link org.springframework.context.ApplicationEvent} classes this event handler cares about. 37 | * 38 | * @deprecated the type the handler is interested in is determined by the type of the first parameter of a handler 39 | * method. 40 | */ 41 | @Deprecated 42 | Class[] value() default {}; 43 | } 44 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/config/JsonSchemaFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.config; 17 | 18 | import java.util.Locale; 19 | 20 | import com.fasterxml.jackson.annotation.JsonValue; 21 | 22 | /** 23 | * An enum to represent JSON Schema pre-defined formats. 24 | * 25 | * @author Oliver Gierke 26 | * @since 2.3 27 | */ 28 | public enum JsonSchemaFormat { 29 | 30 | EMAIL, DATE_TIME, HOSTNAME, IPV4, IPV6, URI; 31 | 32 | @JsonValue 33 | public String toString() { 34 | return name().toLowerCase(Locale.US).replaceAll("_", "-"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/config/Projection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.config; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Inherited; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Annotation to tie a particular projection type to a source type. Used to find projection interfaces at startup time. 27 | * 28 | * @author Oliver Gierke 29 | */ 30 | @Inherited 31 | @Documented 32 | @Retention(RetentionPolicy.RUNTIME) 33 | @Target({ ElementType.TYPE, ElementType.ANNOTATION_TYPE }) 34 | public @interface Projection { 35 | 36 | /** 37 | * The type the projection type is bound to. 38 | * 39 | * @return 40 | */ 41 | Class[] types(); 42 | 43 | /** 44 | * The name of projection to refer to. 45 | * 46 | * @return 47 | */ 48 | String name() default ""; 49 | } 50 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/event/AfterCreateEvent.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.core.event; 2 | 3 | /** 4 | * Event that is emitted after a new entity is saved. 5 | * 6 | * @author Jon Brisbin 7 | */ 8 | public class AfterCreateEvent extends RepositoryEvent { 9 | 10 | private static final long serialVersionUID = -7673953693485678403L; 11 | 12 | public AfterCreateEvent(Object source) { 13 | super(source); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/event/AfterDeleteEvent.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.core.event; 2 | 3 | /** 4 | * Emitted after the entity is deleted from the repository. 5 | * 6 | * @author Jon Brisbin 7 | */ 8 | public class AfterDeleteEvent extends RepositoryEvent { 9 | 10 | private static final long serialVersionUID = -6090615345948638970L; 11 | 12 | public AfterDeleteEvent(Object source) { 13 | super(source); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/event/AfterLinkDeleteEvent.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.core.event; 2 | 3 | /** 4 | * Emitted after a link to a related object is deleted from the parent. 5 | * 6 | * @author Jon Brisbin 7 | */ 8 | public class AfterLinkDeleteEvent extends LinkedEntityEvent { 9 | 10 | private static final long serialVersionUID = 3887575011761146290L; 11 | 12 | public AfterLinkDeleteEvent(Object source, Object linked) { 13 | super(source, linked); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/event/AfterLinkSaveEvent.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.core.event; 2 | 3 | /** 4 | * Emitted after saving a linked object to its parent in the repository. 5 | * 6 | * @author Jon Brisbin 7 | */ 8 | public class AfterLinkSaveEvent extends LinkedEntityEvent { 9 | 10 | private static final long serialVersionUID = 261522353893713633L; 11 | 12 | public AfterLinkSaveEvent(Object source, Object child) { 13 | super(source, child); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/event/AfterSaveEvent.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.core.event; 2 | 3 | /** 4 | * Emitted after a save to the repository. 5 | * 6 | * @author Jon Brisbin 7 | */ 8 | public class AfterSaveEvent extends RepositoryEvent { 9 | 10 | private static final long serialVersionUID = 8568843338617401903L; 11 | 12 | public AfterSaveEvent(Object source) { 13 | super(source); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/event/BeforeCreateEvent.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.core.event; 2 | 3 | /** 4 | * Event emitted before an entity is saved for the first time. 5 | * 6 | * @author Jon Brisbin 7 | */ 8 | public class BeforeCreateEvent extends RepositoryEvent { 9 | 10 | private static final long serialVersionUID = -1642841708537223975L; 11 | 12 | public BeforeCreateEvent(Object source) { 13 | super(source); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/event/BeforeDeleteEvent.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.core.event; 2 | 3 | /** 4 | * Emitted before an entity is deleted from the repository. 5 | * 6 | * @author Jon Brisbin 7 | */ 8 | public class BeforeDeleteEvent extends RepositoryEvent { 9 | 10 | private static final long serialVersionUID = 9150212393209433211L; 11 | 12 | public BeforeDeleteEvent(Object source) { 13 | super(source); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/event/BeforeLinkDeleteEvent.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.core.event; 2 | 3 | /** 4 | * Emitted before a link to a related object is deleted from the parent. 5 | * 6 | * @author Jon Brisbin 7 | */ 8 | public class BeforeLinkDeleteEvent extends LinkedEntityEvent { 9 | 10 | private static final long serialVersionUID = -973540913790564962L; 11 | 12 | public BeforeLinkDeleteEvent(Object source, Object linked) { 13 | super(source, linked); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/event/BeforeLinkSaveEvent.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.core.event; 2 | 3 | /** 4 | * Emitted before a linked object is saved to the repository. 5 | * 6 | * @author Jon Brisbin 7 | */ 8 | public class BeforeLinkSaveEvent extends LinkedEntityEvent { 9 | 10 | private static final long serialVersionUID = 4836932640633578985L; 11 | 12 | public BeforeLinkSaveEvent(Object source, Object linked) { 13 | super(source, linked); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/event/BeforeSaveEvent.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.core.event; 2 | 3 | /** 4 | * Emitted before an entity is saved into the repository. 5 | */ 6 | public class BeforeSaveEvent extends RepositoryEvent { 7 | 8 | private static final long serialVersionUID = -1404580942928384726L; 9 | 10 | public BeforeSaveEvent(Object source) { 11 | super(source); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/event/ExceptionEvent.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.core.event; 2 | 3 | /** 4 | * An event to encapsulate an exception occurring anywhere within the REST exporter. 5 | * 6 | * @author Jon Brisbin 7 | */ 8 | public class ExceptionEvent extends RepositoryEvent { 9 | 10 | private static final long serialVersionUID = 6614805546974091704L; 11 | 12 | public ExceptionEvent(Throwable t) { 13 | super(t); 14 | } 15 | 16 | /** 17 | * Get the source of this exception event. 18 | * 19 | * @return The {@link Throwable} that is the source of this exception event. 20 | */ 21 | public Throwable getException() { 22 | return (Throwable) getSource(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/event/LinkedEntityEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.event; 17 | 18 | /** 19 | * Base class for {@link RepositoryEvent}s that deal with saving/updating or deleting a linked object. 20 | * 21 | * @author Jon Brisbin 22 | * @author Oliver Gierke 23 | */ 24 | public abstract class LinkedEntityEvent extends RepositoryEvent { 25 | 26 | private static final long serialVersionUID = -9071648572128698903L; 27 | private final Object linked; 28 | 29 | /** 30 | * Creates a new {@link LinkedEntityEvent} for th given source and linked instance. 31 | * 32 | * @param source must not be {@literal null}. 33 | * @param linked can be {@literal null}. 34 | */ 35 | public LinkedEntityEvent(Object source, Object linked) { 36 | 37 | super(source); 38 | this.linked = linked; 39 | } 40 | 41 | /** 42 | * Get the linked object. 43 | * 44 | * @return The entity representing the right-hand side of this relationship. 45 | */ 46 | public Object getLinked() { 47 | return linked; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/event/RepositoryEvent.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.core.event; 2 | 3 | import org.springframework.context.ApplicationEvent; 4 | 5 | /** 6 | * Abstract base class for events emitted by the REST exporter. 7 | * 8 | * @author Jon Brisbin 9 | */ 10 | public abstract class RepositoryEvent extends ApplicationEvent { 11 | 12 | private static final long serialVersionUID = -966689410815418259L; 13 | 14 | protected RepositoryEvent(Object source) { 15 | super(source); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/CollectionResourceMapping.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.mapping; 17 | 18 | import java.util.Optional; 19 | 20 | import org.springframework.hateoas.LinkRelation; 21 | 22 | /** 23 | * A custom resource mapping for collection resources. 24 | * 25 | * @author Oliver Gierke 26 | */ 27 | public interface CollectionResourceMapping extends ResourceMapping { 28 | 29 | /** 30 | * Returns the relation type pointing to the item resource within a collection. 31 | * 32 | * @return 33 | */ 34 | LinkRelation getItemResourceRel(); 35 | 36 | /** 37 | * Returns the {@link ResourceDescription} for the item resource. 38 | * 39 | * @return 40 | */ 41 | ResourceDescription getItemResourceDescription(); 42 | 43 | /** 44 | * Returns the projection type to be used when embedding item resources into collections and related resources. If 45 | * {@link Optional#empty()} is returned this will mean full rendering for collections and no rendering for related 46 | * resources. 47 | * 48 | * @return 49 | */ 50 | Optional> getExcerptProjection(); 51 | } 52 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/ComposableFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.mapping; 17 | 18 | interface ComposableFilter { 19 | 20 | S filter(T first, S second); 21 | 22 | default ComposableFilter andThen(ComposableFilter filter) { 23 | return (first, second) -> filter.filter(first, filter(first, second)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/EvoInflectorTypeBasedCollectionResourceMapping.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.mapping; 17 | 18 | import org.atteo.evo.inflector.English; 19 | import org.springframework.hateoas.server.LinkRelationProvider; 20 | 21 | /** 22 | * {@link TypeBasedCollectionResourceMapping} extension to use Evo Inflector to pluralize the simple class name by as 23 | * default path. 24 | * 25 | * @author Oliver Gierke 26 | */ 27 | class EvoInflectorTypeBasedCollectionResourceMapping extends TypeBasedCollectionResourceMapping { 28 | 29 | /** 30 | * Creates a new {@link EvoInflectorTypeBasedCollectionResourceMapping} for the given type and {@link RelProvider}. 31 | * 32 | * @param type must not be {@literal null}. 33 | * @param relProvider must not be {@literal null}. 34 | */ 35 | public EvoInflectorTypeBasedCollectionResourceMapping(Class type, LinkRelationProvider relProvider) { 36 | super(type, relProvider); 37 | } 38 | 39 | @Override 40 | protected String getDefaultPathFor(Class type) { 41 | return English.plural(super.getDefaultPathFor(type)); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/PropertyAwareResourceMapping.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.mapping; 17 | 18 | import org.springframework.data.mapping.PersistentProperty; 19 | 20 | /** 21 | * @author Oliver Gierke 22 | */ 23 | public interface PropertyAwareResourceMapping extends ResourceMapping { 24 | 25 | PersistentProperty getProperty(); 26 | } 27 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/ResolvableResourceDescriptionSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.mapping; 17 | 18 | import org.springframework.context.MessageSourceResolvable; 19 | 20 | /** 21 | * Adapter class for the {@link MessageSourceResolvable} part of a {@link ResourceDescription}. 22 | * 23 | * @author Oliver Gierke 24 | */ 25 | public abstract class ResolvableResourceDescriptionSupport implements ResourceDescription { 26 | 27 | @Override 28 | public Object[] getArguments() { 29 | return new Object[0]; 30 | } 31 | 32 | @Override 33 | public String getDefaultMessage() { 34 | return null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/ResourceDescription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.mapping; 17 | 18 | import org.springframework.context.MessageSource; 19 | import org.springframework.context.MessageSourceResolvable; 20 | import org.springframework.http.MediaType; 21 | 22 | /** 23 | * A description of a resource. Resolvable to plain text by using a {@link MessageSource}. 24 | * 25 | * @author Oliver Gierke 26 | */ 27 | public interface ResourceDescription extends MessageSourceResolvable { 28 | 29 | /** 30 | * Returns the description. This can be a message source code or a custom text format. Prefer resolving the 31 | * {@link ResourceDescription} using a {@link MessageSource}. 32 | * 33 | * @return 34 | */ 35 | String getMessage(); 36 | 37 | /** 38 | * Returns whether this is the default description. 39 | * 40 | * @return 41 | */ 42 | boolean isDefault(); 43 | 44 | MediaType getType(); 45 | } 46 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/mapping/ResourceType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.mapping; 17 | 18 | /** 19 | * An enum listing all supported resource types. 20 | * 21 | * @author Oliver Gierke 22 | */ 23 | public enum ResourceType { 24 | 25 | COLLECTION, ITEM; 26 | } 27 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/package-info.java: -------------------------------------------------------------------------------- 1 | @org.springframework.lang.NonNullApi 2 | package org.springframework.data.rest.core; 3 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/support/EntityLookupSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.support; 17 | 18 | import org.springframework.core.GenericTypeResolver; 19 | 20 | /** 21 | * {@link EntityLookup} implementation base class to derive the supported domain type from the generics signature. 22 | * 23 | * @author Oliver Gierke 24 | * @since 2.5 25 | * @soundtrack Elephants Crossing - The New (Live at Stadtfest Dresden - 26 | * https://soundcloud.com/elephants-crossing/sets/live-at-stadtfest-dresden) 27 | */ 28 | public abstract class EntityLookupSupport implements EntityLookup { 29 | 30 | private final Class domainType; 31 | 32 | /** 33 | * Creates a new {@link EntityLookupSupport} instance discovering the supported type from the generics signature. 34 | */ 35 | public EntityLookupSupport() { 36 | this.domainType = GenericTypeResolver.resolveTypeArgument(getClass(), EntityLookup.class); 37 | } 38 | 39 | @Override 40 | public boolean supports(Class delimiter) { 41 | return domainType.isAssignableFrom(delimiter); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/support/SimpleRelProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.support; 17 | 18 | import org.springframework.hateoas.LinkRelation; 19 | import org.springframework.hateoas.server.LinkRelationProvider; 20 | import org.springframework.util.StringUtils; 21 | 22 | /** 23 | * @author Oliver Gierke 24 | */ 25 | public class SimpleRelProvider implements LinkRelationProvider { 26 | 27 | @Override 28 | public boolean supports(LookupContext context) { 29 | return true; 30 | } 31 | 32 | @Override 33 | public LinkRelation getItemResourceRelFor(Class type) { 34 | 35 | LinkRelation collectionRel = getCollectionResourceRelFor(type); 36 | return LinkRelation.of(String.format("%s.%s", collectionRel.value(), collectionRel.value())); 37 | } 38 | 39 | @Override 40 | public LinkRelation getCollectionResourceRelFor(Class type) { 41 | return LinkRelation.of(StringUtils.uncapitalize(type.getSimpleName())); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/main/java/org/springframework/data/rest/core/util/MapUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.util; 17 | 18 | import java.util.Collection; 19 | import java.util.LinkedHashMap; 20 | import java.util.List; 21 | import java.util.Map; 22 | import java.util.Map.Entry; 23 | 24 | import org.springframework.util.Assert; 25 | import org.springframework.util.MultiValueMap; 26 | 27 | /** 28 | * Helper methods to work with {@link Map}s. 29 | * 30 | * @author Oliver Gierke 31 | */ 32 | public interface MapUtils { 33 | 34 | /** 35 | * Turns a {@link MultiValueMap} into its {@link Map} equivalent. 36 | * 37 | * @param map must not be {@literal null}. 38 | * @return 39 | */ 40 | public static Map> toMap(MultiValueMap map) { 41 | 42 | Assert.notNull(map, "Given map must not be null"); 43 | Map> result = new LinkedHashMap>(map.size()); 44 | 45 | for (Entry> entry : map.entrySet()) { 46 | result.put(entry.getKey(), entry.getValue()); 47 | } 48 | 49 | return result; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/java/org/springframework/data/rest/core/AbstractIntegrationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core; 17 | 18 | import org.junit.jupiter.api.BeforeEach; 19 | import org.junit.jupiter.api.extension.ExtendWith; 20 | import org.springframework.beans.factory.annotation.Autowired; 21 | import org.springframework.data.rest.core.domain.Person; 22 | import org.springframework.data.rest.core.domain.PersonRepository; 23 | import org.springframework.test.context.ContextConfiguration; 24 | import org.springframework.test.context.junit.jupiter.SpringExtension; 25 | 26 | /** 27 | * Base class for integration tests loading {@link RepositoryTestsConfig} and populating the {@link PersonRepository} 28 | * with a {@link Person}. 29 | * 30 | * @author Oliver Gierke 31 | */ 32 | @ExtendWith(SpringExtension.class) 33 | @ContextConfiguration(classes = RepositoryTestsConfig.class) 34 | public abstract class AbstractIntegrationTests { 35 | 36 | @Autowired PersonRepository repository; 37 | 38 | @BeforeEach 39 | void populateDatabase() { 40 | repository.save(new Person("John", "Doe")); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/java/org/springframework/data/rest/core/ResolvingAggregateReferenceUnitTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core; 17 | 18 | import static org.assertj.core.api.Assertions.*; 19 | 20 | import java.net.URI; 21 | 22 | import org.junit.jupiter.api.Test; 23 | 24 | /** 25 | * Unit tests for {@link ResolvingAggregateReference}. 26 | * 27 | * @author Oliver Drotbohm 28 | */ 29 | class ResolvingAggregateReferenceUnitTests { 30 | 31 | @Test // GH-2239 32 | void usesResolverForFinalInstanceLookup() { 33 | 34 | var reference = new ResolvingAggregateReference<>(URI.create("/foo/42"), it -> "aggregate", it -> 42L); 35 | 36 | assertThat(reference.resolveAggregate()).isEqualTo("aggregate"); 37 | assertThat(reference.resolveId()).isEqualTo(42); 38 | } 39 | 40 | @Test // GH-2239 41 | void appliesCustomExtractor() { 42 | 43 | var reference = new ResolvingAggregateReference<>(URI.create("/foo/42"), it -> "aggregate", 44 | it -> Long.valueOf(it.toString())).withIdSource(it -> it.getPathSegments().get(1)); 45 | 46 | assertThat(reference.resolveId()).isEqualTo(42); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/AnnotatedPersonEventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.domain; 17 | 18 | import org.springframework.data.rest.core.annotation.*; 19 | 20 | /** 21 | * Sample annotation-based event handler. 22 | * 23 | * @author Jon Brisbin 24 | * @author Oliver Gierke 25 | */ 26 | @RepositoryEventHandler 27 | public class AnnotatedPersonEventHandler { 28 | 29 | @HandleAfterCreate 30 | @HandleAfterDelete 31 | @HandleAfterSave 32 | void handleAfter(Person p) { 33 | throw new EventHandlerInvokedException(); 34 | } 35 | 36 | @HandleAfterLinkDelete 37 | @HandleAfterLinkSave 38 | void handleAfterLink(Person p, Object o) { 39 | throw new EventHandlerInvokedException(); 40 | } 41 | 42 | @HandleBeforeCreate 43 | @HandleBeforeDelete 44 | @HandleBeforeSave 45 | void handleBefore(Person p) { 46 | throw new EventHandlerInvokedException(); 47 | } 48 | 49 | @HandleBeforeLinkDelete 50 | @HandleBeforeLinkSave 51 | void handleBeforeLink(Person p, Object o) { 52 | throw new EventHandlerInvokedException(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/AnnotatedPersonRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.domain; 17 | 18 | import org.springframework.data.repository.CrudRepository; 19 | import org.springframework.data.repository.NoRepositoryBean; 20 | import org.springframework.data.rest.core.annotation.RestResource; 21 | 22 | /** 23 | * A repository to manage {@link org.springframework.data.rest.core.domain.Person}s. 24 | * 25 | * @author Jon Brisbin 26 | */ 27 | @RestResource(rel = "people", exported = false) 28 | @NoRepositoryBean 29 | public interface AnnotatedPersonRepository extends CrudRepository {} 30 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/Author.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.domain; 17 | 18 | import org.springframework.data.annotation.Id; 19 | 20 | /** 21 | * @author Oliver Gierke 22 | */ 23 | 24 | public class Author { 25 | 26 | @Id Long id; 27 | String firstname, lastname; 28 | } 29 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/AuthorRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.domain; 17 | 18 | import java.util.List; 19 | 20 | import org.springframework.data.repository.Repository; 21 | import org.springframework.data.repository.query.Param; 22 | import org.springframework.data.rest.core.annotation.RepositoryRestResource; 23 | 24 | /** 25 | * @author Oliver Gierke 26 | */ 27 | @RepositoryRestResource 28 | interface AuthorRepository extends Repository { 29 | 30 | List findByFirstnameContaining(@Param("firstname") String firstname); 31 | } 32 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/ConfiguredPersonRepository.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.core.domain; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | import org.springframework.data.repository.NoRepositoryBean; 5 | 6 | /** 7 | * A repository to manage {@link Person}s. 8 | * 9 | * @author Jon Brisbin 10 | */ 11 | @NoRepositoryBean 12 | public interface ConfiguredPersonRepository extends CrudRepository {} 13 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/CreditCard.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.domain; 17 | 18 | import org.springframework.data.annotation.Id; 19 | 20 | /** 21 | * @author Oliver Gierke 22 | */ 23 | public class CreditCard { 24 | 25 | @Id Long id; 26 | String creditCardNumber; 27 | } 28 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/CreditCardRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.domain; 17 | 18 | import org.springframework.data.repository.CrudRepository; 19 | 20 | /** 21 | * @author Oliver Gierke 22 | */ 23 | interface CreditCardRepository extends CrudRepository { 24 | 25 | CreditCard findByCreditCardNumber(String creditCardNumber); 26 | } 27 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/EventHandlerInvokedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.domain; 17 | 18 | /** 19 | * @author Oliver Gierke 20 | */ 21 | public class EventHandlerInvokedException extends RuntimeException { 22 | 23 | private static final long serialVersionUID = -7879286986960261090L; 24 | } 25 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/JpaRepositoryConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.domain; 17 | 18 | import org.springframework.context.MessageSource; 19 | import org.springframework.context.annotation.Bean; 20 | import org.springframework.context.annotation.ComponentScan; 21 | import org.springframework.context.annotation.Configuration; 22 | import org.springframework.context.support.ResourceBundleMessageSource; 23 | import org.springframework.data.map.repository.config.EnableMapRepositories; 24 | 25 | /** 26 | * @author Jon Brisbin 27 | * @author Oliver Gierke 28 | */ 29 | @Configuration 30 | @ComponentScan 31 | @EnableMapRepositories 32 | public class JpaRepositoryConfig { 33 | 34 | @Bean 35 | public MessageSource messageSource() { 36 | ResourceBundleMessageSource ms = new ResourceBundleMessageSource(); 37 | ms.setBasename("org.springframework.data.rest.core.ValidationErrors"); 38 | return ms; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/Order.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.domain; 17 | 18 | import java.util.UUID; 19 | 20 | import org.springframework.data.annotation.Id; 21 | import org.springframework.data.annotation.Reference; 22 | 23 | /** 24 | * @author Oliver Gierke 25 | */ 26 | final class Order { 27 | 28 | @Id private final UUID id = UUID.randomUUID(); 29 | @Reference private final Person creator; 30 | 31 | public Order(Person creator) { 32 | this.creator = creator; 33 | } 34 | 35 | public UUID getId() { 36 | return this.id; 37 | } 38 | 39 | public Person getCreator() { 40 | return this.creator; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/OrderRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.domain; 17 | 18 | import java.util.Optional; 19 | import java.util.UUID; 20 | 21 | import org.springframework.data.repository.CrudRepository; 22 | 23 | /** 24 | * @author Oliver Gierke 25 | */ 26 | public interface OrderRepository extends CrudRepository { 27 | 28 | @Override 29 | @SuppressWarnings("unchecked") 30 | Order save(Order entity); 31 | 32 | @Override 33 | Optional findById(UUID id); 34 | } 35 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/PersonBeforeSaveHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.domain; 17 | 18 | import org.springframework.data.rest.core.event.AbstractRepositoryEventListener; 19 | 20 | /** 21 | * @author Jon Brisbin 22 | * @author Oliver Gierke 23 | */ 24 | public class PersonBeforeSaveHandler extends AbstractRepositoryEventListener { 25 | 26 | @Override 27 | protected void onBeforeSave(Person person) { 28 | throw new EventHandlerInvokedException(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/PersonNameValidator.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.core.domain; 2 | 3 | import static org.springframework.util.ClassUtils.*; 4 | import static org.springframework.util.StringUtils.*; 5 | 6 | import org.springframework.data.rest.core.annotation.HandleBeforeSave; 7 | import org.springframework.stereotype.Component; 8 | import org.springframework.validation.Errors; 9 | import org.springframework.validation.Validator; 10 | 11 | /** 12 | * A test {@link Validator} that checks for non-blank names. 13 | * 14 | * @author Jon Brisbin 15 | */ 16 | @Component 17 | @HandleBeforeSave 18 | public class PersonNameValidator implements Validator { 19 | 20 | @Override 21 | public boolean supports(Class clazz) { 22 | return isAssignable(clazz, Person.class); 23 | } 24 | 25 | @Override 26 | public void validate(Object target, Errors errors) { 27 | Person p = (Person) target; 28 | if (!hasText(p.getLastName())) { 29 | errors.rejectValue("lastName", "blank", "Last name cannot be blank"); 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/PlainPersonRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.domain; 17 | 18 | import org.springframework.data.repository.CrudRepository; 19 | import org.springframework.data.repository.NoRepositoryBean; 20 | 21 | /** 22 | * A repository to manage {@link Person}s. 23 | * 24 | * @author Jon Brisbin 25 | */ 26 | @NoRepositoryBean 27 | public interface PlainPersonRepository extends CrudRepository {} 28 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/Profile.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.domain; 17 | 18 | import java.util.UUID; 19 | 20 | import org.springframework.data.annotation.Id; 21 | 22 | /** 23 | * @author Jon Brisbin 24 | * @author Oliver Gierke 25 | */ 26 | public class Profile { 27 | 28 | @Id private final UUID id = UUID.randomUUID(); 29 | private final String name, type; 30 | 31 | public Profile(String name, String type) { 32 | this.name = name; 33 | this.type = type; 34 | } 35 | 36 | public UUID getId() { 37 | return this.id; 38 | } 39 | 40 | public String getName() { 41 | return this.name; 42 | } 43 | 44 | public String getType() { 45 | return this.type; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/ProfileLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.domain; 17 | 18 | import org.springframework.beans.factory.InitializingBean; 19 | import org.springframework.beans.factory.annotation.Autowired; 20 | import org.springframework.stereotype.Component; 21 | 22 | /** 23 | * @author Jon Brisbin 24 | * @author Oliver Gierke 25 | */ 26 | @Component 27 | class ProfileLoader implements InitializingBean { 28 | 29 | @Autowired ProfileRepository profiles; 30 | 31 | @Override 32 | public void afterPropertiesSet() throws Exception { 33 | profiles.save(new Profile("jdoe", "account")); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/java/org/springframework/data/rest/core/domain/ProfileRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.domain; 17 | 18 | import java.util.UUID; 19 | 20 | import org.springframework.data.repository.CrudRepository; 21 | 22 | /** 23 | * Repository for managing {@link Profile}s. 24 | * 25 | * @author Jon Brisbin 26 | * @author Oliver Gierke 27 | */ 28 | public interface ProfileRepository extends CrudRepository { 29 | 30 | Profile findByName(String name); 31 | } 32 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/java/org/springframework/data/rest/core/support/RepositoryRelProviderUnitTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.core.support; 17 | 18 | import static org.assertj.core.api.Assertions.*; 19 | 20 | import org.junit.jupiter.api.Test; 21 | 22 | import org.springframework.core.annotation.OrderUtils; 23 | 24 | /** 25 | * Unit tests for {@link RepositoryRelProvider}. 26 | * 27 | * @author Mark Paluch 28 | */ 29 | class RepositoryRelProviderUnitTests { 30 | 31 | @Test // GH-2477 32 | void shouldReportOrder() { 33 | 34 | Integer order = OrderUtils.getOrder(RepositoryRelProvider.class); 35 | 36 | assertThat(order).isEqualTo(Integer.MAX_VALUE - 10); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/resources/ValidationErrors.properties: -------------------------------------------------------------------------------- 1 | field.name.required = Field {0}.{1} is required. 2 | no.userid = {0}s must be assigned initial userids. 3 | -------------------------------------------------------------------------------- /spring-data-rest-core/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d %5p %40.40c:%4L - %m%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /spring-data-rest-distribution/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "antora": "3.2.0-alpha.6", 4 | "@antora/atlas-extension": "1.0.0-alpha.2", 5 | "@antora/collector-extension": "1.0.0-alpha.7", 6 | "@asciidoctor/tabs": "1.0.0-beta.6", 7 | "@springio/antora-extensions": "1.13.0", 8 | "@springio/asciidoctor-extensions": "1.0.0-alpha.11" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /spring-data-rest-distribution/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | spring-data-rest-distribution 7 | 8 | pom 9 | 10 | Spring Data REST - Distribution 11 | Distribution build for Spring Data REST 12 | 13 | 14 | org.springframework.data 15 | spring-data-rest-parent 16 | 5.0.0-SNAPSHOT 17 | ../pom.xml 18 | 19 | 20 | 21 | ${basedir}/.. 22 | ${project.basedir}/../src/main/antora/antora-playbook.yml 23 | 24 | 25 | 26 | 27 | 28 | ${project.basedir}/../src/main/antora/resources/antora-resources 29 | true 30 | 31 | 32 | 33 | 34 | org.apache.maven.plugins 35 | maven-assembly-plugin 36 | 37 | 38 | 39 | org.apache.maven.plugins 40 | maven-resources-plugin 41 | 42 | 43 | 44 | resources 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.antora 53 | antora-maven-plugin 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /spring-data-rest-hal-explorer/src/main/resources/META-INF/native-image/org.springframework.data/spring-data-rest-hal-explorer/resource-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "resources" : [ 3 | { "pattern" : "META-INF/spring-data-rest/hal-explorer/.*" } 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /spring-data-rest-hal-explorer/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.data.rest.webmvc.config.StaticResourceProvider=org.springframework.data.rest.webmvc.halexplorer.HalExplorerConfiguration 2 | -------------------------------------------------------------------------------- /spring-data-rest-hal-explorer/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d %5p %40.40c:%4L - %m%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /spring-data-rest-tests/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.springframework.data 7 | spring-data-rest-parent 8 | 5.0.0-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | Spring Data REST Tests 13 | spring-data-rest-tests 14 | pom 15 | 16 | 17 | spring-data-rest-tests-core 18 | spring-data-rest-tests-jpa 19 | spring-data-rest-tests-mongodb 20 | spring-data-rest-tests-security 21 | spring-data-rest-tests-shop 22 | 23 | 24 | 25 | 2.4.21 26 | 27 | 28 | 29 | 30 | 31 | jakarta.servlet 32 | jakarta.servlet-api 33 | provided 34 | 35 | 36 | 37 | org.codehaus.groovy 38 | groovy-all 39 | ${groovy.version} 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-core/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.springframework.data 7 | spring-data-rest-tests 8 | 5.0.0-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | Spring Data REST Tests - Core 13 | spring-data-rest-tests-core 14 | 15 | 16 | spring.data.rest.tests.core 17 | 18 | 19 | 20 | 21 | 22 | org.springframework.data 23 | spring-data-rest-webmvc 24 | 5.0.0-SNAPSHOT 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | org.apache.maven.plugins 33 | maven-jar-plugin 34 | 35 | 36 | 37 | test-jar 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-core/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d %5p %40.40c:%4L - %m%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/Address.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | import jakarta.persistence.Entity; 19 | import jakarta.persistence.GeneratedValue; 20 | import jakarta.persistence.Id; 21 | import jakarta.persistence.Version; 22 | 23 | /** 24 | * @author Oliver Gierke 25 | */ 26 | @Entity 27 | public class Address { 28 | 29 | public @Id @GeneratedValue Long id; 30 | public @Version Long version; 31 | } 32 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/AddressRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | import org.springframework.data.repository.CrudRepository; 19 | import org.springframework.data.rest.core.annotation.RestResource; 20 | 21 | /** 22 | * @author Oliver Gierke 23 | */ 24 | public interface AddressRepository extends CrudRepository { 25 | 26 | @Override 27 | @RestResource(exported = false) 28 | Iterable
findAll(); 29 | 30 | @Override 31 | @RestResource(exported = false) 32 | S save(S entity); 33 | } 34 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/AssignableSequenceStyleGenerator.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.webmvc.jpa; 2 | 3 | import org.hibernate.id.enhanced.SequenceStyleGenerator; 4 | 5 | /** 6 | * Extension to {@link SequenceStyleGenerator} to allow assigned identifiers. 7 | * 8 | * @author Mark Paluch 9 | * @see Manually 11 | * setting the identifier results in object optimistic locking failure exception 12 | * @see HHH-17472 13 | */ 14 | public class AssignableSequenceStyleGenerator extends SequenceStyleGenerator { 15 | 16 | @Override 17 | public boolean allowAssignedIdentifiers() { 18 | return true; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/Author.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | import jakarta.persistence.Entity; 19 | import jakarta.persistence.GeneratedValue; 20 | import jakarta.persistence.Id; 21 | import jakarta.persistence.ManyToMany; 22 | 23 | import java.util.HashSet; 24 | import java.util.Set; 25 | 26 | /** 27 | * @author Oliver Gierke 28 | */ 29 | @Entity 30 | public class Author { 31 | 32 | @Id @GeneratedValue // 33 | Long id; 34 | public String name; 35 | 36 | @ManyToMany(mappedBy = "authors") // 37 | public Set books = new HashSet(); 38 | 39 | protected Author() {} 40 | 41 | public Author(String name) { 42 | this.name = name; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/AuthorRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | import static org.springframework.web.bind.annotation.RequestMethod.*; 19 | 20 | import org.springframework.data.repository.CrudRepository; 21 | import org.springframework.web.bind.annotation.CrossOrigin; 22 | 23 | /** 24 | * @author Oliver Gierke 25 | * @author Mark Paluch 26 | */ 27 | @CrossOrigin(origins = "http://not.so.far.example", // 28 | allowCredentials = "true", // 29 | methods = { GET, PATCH, POST }, // 30 | maxAge = 1234) 31 | public interface AuthorRepository extends CrudRepository {} 32 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/AuthorsController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | import org.springframework.data.rest.webmvc.RepositoryRestController; 19 | import org.springframework.http.HttpEntity; 20 | import org.springframework.http.HttpStatus; 21 | import org.springframework.http.ResponseEntity; 22 | import org.springframework.util.Assert; 23 | import org.springframework.web.bind.annotation.PathVariable; 24 | import org.springframework.web.bind.annotation.RequestMapping; 25 | import org.springframework.web.bind.annotation.RequestMethod; 26 | 27 | /** 28 | * Sample custom controller to test the ability to override 29 | * 30 | * @author Oliver Gierke 31 | */ 32 | @RepositoryRestController 33 | public class AuthorsController { 34 | 35 | @RequestMapping(value = "/authors/{author}", method = RequestMethod.DELETE) 36 | HttpEntity deleteAuthor(@PathVariable Author author) { 37 | 38 | Assert.notNull(author, "Author must not be null"); 39 | return new ResponseEntity(HttpStatus.I_AM_A_TEAPOT); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/BookExcerpt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | import org.springframework.data.rest.core.config.Projection; 19 | 20 | /** 21 | * Interface for an excerpt projection for {@link Book}s. 22 | * 23 | * @author Oliver Gierke 24 | */ 25 | @Projection(name = "excerpt", types = Book.class) 26 | public interface BookExcerpt { 27 | 28 | String getTitle(); 29 | } 30 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/Category.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | import jakarta.persistence.Entity; 19 | import jakarta.persistence.GeneratedValue; 20 | import jakarta.persistence.Id; 21 | import jakarta.persistence.Version; 22 | 23 | /** 24 | * @author Dario Seidl 25 | */ 26 | @Entity 27 | class Category { 28 | 29 | public @Id @GeneratedValue Long id; 30 | public @Version Long version = 0L; 31 | public String name; 32 | 33 | @SuppressWarnings("unused") 34 | private Category() {} 35 | 36 | public Category(String name) { 37 | this.name = name; 38 | } 39 | 40 | public Long getId() { 41 | return this.id; 42 | } 43 | 44 | public Long getVersion() { 45 | return this.version; 46 | } 47 | 48 | public String getName() { 49 | return this.name; 50 | } 51 | 52 | public void setId(Long id) { 53 | this.id = id; 54 | } 55 | 56 | public void setVersion(Long version) { 57 | this.version = version; 58 | } 59 | 60 | public void setName(String name) { 61 | this.name = name; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/CategoryProjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | import org.springframework.beans.factory.annotation.Value; 19 | import org.springframework.data.rest.core.config.Projection; 20 | 21 | /** 22 | * @author Dario Seidl 23 | */ 24 | @Projection(name = "open", types = Category.class) 25 | interface CategoryProjection { 26 | 27 | String getName(); 28 | 29 | @Value("calculated-#{target.name}") 30 | String getCalculatedName(); 31 | } 32 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/CategoryRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | import org.springframework.data.repository.CrudRepository; 19 | import org.springframework.data.rest.core.annotation.RepositoryRestResource; 20 | 21 | /** 22 | * @author Dario Seidl 23 | */ 24 | @RepositoryRestResource 25 | interface CategoryRepository extends CrudRepository { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/CreditCard.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | import jakarta.persistence.Embeddable; 19 | import jakarta.persistence.Entity; 20 | import jakarta.persistence.Id; 21 | 22 | import com.fasterxml.jackson.annotation.JsonUnwrapped; 23 | 24 | /** 25 | * @author Oliver Gierke 26 | */ 27 | @Entity 28 | public class CreditCard { 29 | 30 | @Id Long id; 31 | final @JsonUnwrapped CCN ccn; 32 | 33 | public CreditCard(CCN ccn) { 34 | this.ccn = ccn; 35 | } 36 | 37 | public Long getId() { 38 | return this.id; 39 | } 40 | 41 | public CCN getCcn() { 42 | return this.ccn; 43 | } 44 | 45 | @Embeddable 46 | public static class CCN { 47 | String ccn; 48 | 49 | public CCN(String ccn) { 50 | this.ccn = ccn; 51 | } 52 | 53 | public CCN() {} 54 | 55 | public String getCcn() { 56 | return this.ccn; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/CreditCardRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | import org.springframework.data.repository.CrudRepository; 19 | 20 | /** 21 | * @author Oliver Gierke 22 | */ 23 | interface CreditCardRepository extends CrudRepository { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/Dinner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | import jakarta.persistence.DiscriminatorValue; 19 | import jakarta.persistence.Entity; 20 | 21 | /** 22 | * @author Alex Leigh 23 | */ 24 | @Entity 25 | @DiscriminatorValue("D") 26 | public class Dinner extends Meal { 27 | 28 | public static final String TYPE = "dinner"; 29 | 30 | private String dinnerCode; 31 | 32 | @Override 33 | public String getType() { 34 | return TYPE; 35 | } 36 | 37 | public String getDinnerCode() { 38 | return this.dinnerCode; 39 | } 40 | 41 | public void setDinnerCode(String dinnerCode) { 42 | this.dinnerCode = dinnerCode; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/ItemRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | import org.springframework.data.repository.CrudRepository; 19 | import org.springframework.web.bind.annotation.CrossOrigin; 20 | 21 | /** 22 | * @author Greg Turnquist 23 | * @author Oliver Gierke 24 | * @author Mark Paluch 25 | */ 26 | @CrossOrigin 27 | public interface ItemRepository extends CrudRepository {} 28 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/LineItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | import jakarta.persistence.Entity; 19 | import jakarta.persistence.GeneratedValue; 20 | import jakarta.persistence.Id; 21 | 22 | /** 23 | * @author Oliver Gierke 24 | */ 25 | @Entity 26 | public class LineItem { 27 | 28 | @Id @GeneratedValue // 29 | private Long id; 30 | private String name; 31 | 32 | public LineItem(String name) { 33 | this.name = name; 34 | } 35 | 36 | protected LineItem() { 37 | 38 | } 39 | 40 | public String getName() { 41 | return name; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/Meal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | import jakarta.persistence.Entity; 19 | import jakarta.persistence.GeneratedValue; 20 | import jakarta.persistence.Id; 21 | import jakarta.persistence.Inheritance; 22 | 23 | import com.fasterxml.jackson.annotation.JsonSubTypes; 24 | import com.fasterxml.jackson.annotation.JsonTypeInfo; 25 | 26 | /** 27 | * @author Alex Leigh 28 | */ 29 | @Entity 30 | @Inheritance 31 | @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type") 32 | @JsonSubTypes({ @JsonSubTypes.Type(value = Dinner.class, name = Dinner.TYPE) }) 33 | public abstract class Meal { 34 | 35 | @Id @GeneratedValue private Long id; 36 | 37 | public abstract String getType(); 38 | 39 | public Long getId() { 40 | return this.id; 41 | } 42 | 43 | public void setId(Long id) { 44 | this.id = id; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/OrderRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | import java.util.List; 19 | 20 | import org.springframework.data.repository.CrudRepository; 21 | import org.springframework.data.repository.query.Param; 22 | import org.springframework.data.rest.core.annotation.Description; 23 | import org.springframework.data.rest.core.annotation.RepositoryRestResource; 24 | 25 | /** 26 | * @author Oliver Gierke 27 | */ 28 | @RepositoryRestResource(collectionResourceDescription = @Description("Collection resource description"), 29 | itemResourceDescription = @Description("Item resource description.")) 30 | public interface OrderRepository extends CrudRepository { 31 | 32 | List findByType(@Param("type") Type type); 33 | } 34 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/OrderSummary.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | import java.math.BigDecimal; 19 | 20 | import org.springframework.data.rest.core.annotation.Description; 21 | import org.springframework.data.rest.core.config.Projection; 22 | 23 | /** 24 | * @author Oliver Gierke 25 | */ 26 | @Projection(name = "summary", types = Order.class) 27 | @Description("A summary of an order.") 28 | public interface OrderSummary { 29 | 30 | @Description("Price!!") 31 | BigDecimal getPrice(); 32 | } 33 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/PersonSummary.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | import org.springframework.data.rest.core.config.Projection; 19 | 20 | /** 21 | * @author Oliver Gierke 22 | */ 23 | @Projection(name = "excerpt", types = Person.class) 24 | public interface PersonSummary { 25 | 26 | String getFirstName(); 27 | 28 | String getLastName(); 29 | } 30 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/ReceiptRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.data.rest.webmvc.jpa; 18 | 19 | import org.springframework.data.repository.CrudRepository; 20 | 21 | /** 22 | * A repository to manage {@link Receipt}s. 23 | * 24 | * @author Pablo Lozano 25 | */ 26 | 27 | public interface ReceiptRepository extends CrudRepository { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/Room.java: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | * Copyright 2012-2025 the original author or authors. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.springframework.data.rest.webmvc.jpa; 18 | 19 | import jakarta.persistence.Entity; 20 | import jakarta.persistence.GeneratedValue; 21 | import jakarta.persistence.Id; 22 | import jakarta.persistence.Inheritance; 23 | 24 | import com.fasterxml.jackson.annotation.JsonSubTypes; 25 | import com.fasterxml.jackson.annotation.JsonTypeInfo; 26 | 27 | /** 28 | * @author Alex Leigh 29 | */ 30 | @Entity 31 | @Inheritance 32 | @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type") 33 | @JsonSubTypes({ @JsonSubTypes.Type(value = Suite.class, name = Suite.TYPE) }) 34 | public abstract class Room { 35 | 36 | @Id @GeneratedValue // 37 | private Long id; 38 | 39 | public abstract String getType(); 40 | 41 | public Long getId() { 42 | return this.id; 43 | } 44 | 45 | public void setId(Long id) { 46 | this.id = id; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/SequenceGenerator.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.webmvc.jpa; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | import org.hibernate.annotations.IdGeneratorType; 9 | 10 | /** 11 | * Variant of {@link jakarta.persistence.GeneratedValue} using Hibernate-specific generators. 12 | * 13 | * @see Manually 15 | * setting the identifier results in object optimistic locking failure exception 16 | * @see HHH-17472 17 | */ 18 | @IdGeneratorType(AssignableSequenceStyleGenerator.class) 19 | @Retention(RetentionPolicy.RUNTIME) 20 | @Target({ ElementType.METHOD, ElementType.FIELD }) 21 | public @interface SequenceGenerator { 22 | } 23 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/Suite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | import jakarta.persistence.DiscriminatorValue; 19 | import jakarta.persistence.Entity; 20 | 21 | /** 22 | * @author Alex Leigh 23 | */ 24 | @Entity 25 | @DiscriminatorValue("S") 26 | public class Suite extends Room { 27 | 28 | static final String TYPE = "suite"; 29 | 30 | private String suiteCode; 31 | 32 | @Override 33 | public String getType() { 34 | return TYPE; 35 | } 36 | 37 | public String getSuiteCode() { 38 | return this.suiteCode; 39 | } 40 | 41 | public void setSuiteCode(String suiteCode) { 42 | this.suiteCode = suiteCode; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/Type.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | /** 19 | * @author Oliver Gierke 20 | */ 21 | public enum Type { 22 | 23 | IN_STORE, TAKE_AWAY; 24 | } 25 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/UserExcerpt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | /** 19 | * @author Oliver Gierke 20 | * @soundtrack Elen - Sink like a stone (Elen) 21 | */ 22 | public interface UserExcerpt { 23 | 24 | UserExcerpt getFather(); 25 | } 26 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/main/java/org/springframework/data/rest/webmvc/jpa/UserRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa; 17 | 18 | import org.springframework.data.repository.CrudRepository; 19 | 20 | /** 21 | * @author Greg Turnquist 22 | * @author Oliver Gierke 23 | */ 24 | interface UserRepository extends CrudRepository {} 25 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/jpa/groovy/SimulatedGroovyDomainClassRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2022 original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.jpa.groovy; 17 | 18 | import org.springframework.data.repository.CrudRepository; 19 | 20 | /** 21 | * Simulates a repository built on a Groovy domain object. 22 | * 23 | * @author Greg Turnquist 24 | */ 25 | public interface SimulatedGroovyDomainClassRepository extends CrudRepository {} 26 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/util/TestUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.util; 17 | 18 | import java.nio.charset.Charset; 19 | import java.util.Scanner; 20 | 21 | import org.springframework.core.io.ClassPathResource; 22 | import org.springframework.data.rest.webmvc.jpa.JpaWebTests; 23 | 24 | /** 25 | * Test helper methods. 26 | * 27 | * @author Oliver Gierke 28 | * @author Christoph Strobl 29 | */ 30 | public class TestUtils { 31 | 32 | private static final Charset UTF8 = Charset.forName("UTF-8"); 33 | 34 | public static String readFileFromClasspath(String name) throws Exception { 35 | 36 | ClassPathResource file = new ClassPathResource(name, JpaWebTests.class); 37 | StringBuilder builder = new StringBuilder(); 38 | 39 | Scanner scanner = new Scanner(file.getFile(), UTF8.name()); 40 | 41 | try { 42 | 43 | while (scanner.hasNextLine()) { 44 | builder.append(scanner.nextLine()); 45 | } 46 | 47 | } finally { 48 | scanner.close(); 49 | } 50 | 51 | return builder.toString(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/resources/org/springframework/data/rest/webmvc/jpa/order.json: -------------------------------------------------------------------------------- 1 | { 2 | "_links": { 3 | "self": { 4 | "href": "http://localhost:8080/persons/1" 5 | } 6 | }, 7 | "lineItems": [ 8 | { 9 | "name": "Java Chip" 10 | }, 11 | { 12 | "name": "Chocolate Mocca " 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/resources/org/springframework/data/rest/webmvc/jpa/person.json: -------------------------------------------------------------------------------- 1 | { "firstName" : "Dave", 2 | "lastName" : "Matthews" 3 | } -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-mongodb/src/main/java/org/springframework/data/rest/tests/mongodb/Address.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.tests.mongodb; 17 | 18 | import com.fasterxml.jackson.annotation.JsonProperty; 19 | 20 | /** 21 | * @author Oliver Gierke 22 | */ 23 | public class Address { 24 | 25 | public String street; 26 | public @JsonProperty(required = true) String zipCode; 27 | } 28 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-mongodb/src/main/java/org/springframework/data/rest/tests/mongodb/ProfileRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.tests.mongodb; 17 | 18 | import java.util.List; 19 | import java.util.Optional; 20 | 21 | import org.springframework.data.repository.CrudRepository; 22 | import org.springframework.data.repository.PagingAndSortingRepository; 23 | import org.springframework.data.repository.query.Param; 24 | 25 | /** 26 | * @author Jon Brisbin 27 | * @author Oliver Gierke 28 | */ 29 | public interface ProfileRepository extends PagingAndSortingRepository, CrudRepository { 30 | 31 | List findByType(String type); 32 | 33 | // DATAREST-247 34 | long countByType(@Param("type") String type); 35 | 36 | // DATAREST-511 37 | Optional findProfileById(@Param("id") String id); 38 | } 39 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-mongodb/src/main/java/org/springframework/data/rest/tests/mongodb/Receipt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.data.rest.tests.mongodb; 18 | 19 | import java.math.BigDecimal; 20 | import java.util.Date; 21 | 22 | import org.springframework.data.annotation.Id; 23 | import org.springframework.data.annotation.LastModifiedDate; 24 | import org.springframework.data.annotation.Version; 25 | import org.springframework.data.mongodb.core.mapping.Document; 26 | 27 | /** 28 | * @author Pablo Lozano 29 | */ 30 | // tag::code[] 31 | @Document 32 | public class Receipt { 33 | 34 | public @Id String id; 35 | public @Version Long version; 36 | public @LastModifiedDate Date date; // <1> 37 | 38 | public String saleItem; 39 | public BigDecimal amount; 40 | 41 | } 42 | // end::code[] 43 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-mongodb/src/main/java/org/springframework/data/rest/tests/mongodb/ReceiptRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.springframework.data.rest.tests.mongodb; 18 | 19 | import org.springframework.data.repository.CrudRepository; 20 | 21 | /** 22 | * A repository to manage {@link Receipt}s. 23 | * 24 | * @author Pablo Lozano 25 | */ 26 | 27 | public interface ReceiptRepository extends CrudRepository { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-mongodb/src/main/java/org/springframework/data/rest/tests/mongodb/UserSummary.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.tests.mongodb; 17 | 18 | import org.springframework.data.rest.core.config.Projection; 19 | 20 | /** 21 | * @author Oliver Gierke 22 | */ 23 | @Projection(types = User.class) 24 | public interface UserSummary { 25 | 26 | String getFirstname(); 27 | 28 | String getLastname(); 29 | } 30 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-mongodb/src/main/java/org/springframework/data/rest/tests/mongodb/groovy/SimulatedGroovyDomainClassRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.tests.mongodb.groovy; 17 | 18 | import org.springframework.data.repository.CrudRepository; 19 | 20 | /** 21 | * Simulates a repository built on a Groovy domain object. 22 | * 23 | * @author Greg Turnquist 24 | */ 25 | public interface SimulatedGroovyDomainClassRepository extends CrudRepository {} 26 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/tests/mongodb/TestUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.tests.mongodb; 17 | 18 | import java.io.ByteArrayInputStream; 19 | import java.io.InputStream; 20 | import java.nio.charset.Charset; 21 | 22 | import org.springframework.util.Assert; 23 | 24 | /** 25 | * Test helper methods. 26 | * 27 | * @author Oliver Gierke 28 | * @author Christoph Strobl 29 | */ 30 | public class TestUtils { 31 | 32 | private static final Charset UTF8 = Charset.forName("UTF-8"); 33 | 34 | /** 35 | * Returns the given {@link String} as {@link InputStream}. 36 | * 37 | * @param source must not be {@literal null}. 38 | * @return 39 | */ 40 | public static InputStream asStream(String source) { 41 | Assert.notNull(source, "Source string must not be null"); 42 | return new ByteArrayInputStream(source.getBytes(UTF8)); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/resources/rest-messages.properties: -------------------------------------------------------------------------------- 1 | rest.description.profile=Profile description 2 | 3 | # User 4 | # Local property 5 | address._title=Adresse 6 | 7 | # Property on simple type 8 | User.gender._title=Geschlecht 9 | 10 | # Property on fully-qualified property 11 | org.springframework.data.rest.tests.mongodb.User.firstname._title=Vorname 12 | 13 | # Local property that should be trumped by the more precise definition above 14 | firstname._title=emanroV -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-security/src/main/java/org/springframework/data/rest/tests/security/Order.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.tests.security; 17 | 18 | import java.util.UUID; 19 | 20 | import org.springframework.data.annotation.Id; 21 | 22 | /** 23 | * @author Oliver Gierke 24 | */ 25 | public final class Order { 26 | 27 | @Id private final UUID id = UUID.randomUUID(); 28 | private final Person customer; 29 | 30 | public Order(Person customer) { 31 | this.customer = customer; 32 | } 33 | 34 | public UUID getId() { 35 | return this.id; 36 | } 37 | 38 | public Person getCustomer() { 39 | return this.customer; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-security/src/main/java/org/springframework/data/rest/tests/security/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.tests.security; 17 | 18 | import java.util.UUID; 19 | 20 | import org.springframework.data.annotation.Id; 21 | 22 | /** 23 | * @author Oliver Gierke 24 | */ 25 | public final class Person { 26 | 27 | @Id private final UUID id = UUID.randomUUID(); 28 | private final String firstname, lastname; 29 | 30 | public Person(String firstname, String lastname) { 31 | this.firstname = firstname; 32 | this.lastname = lastname; 33 | } 34 | 35 | public UUID getId() { 36 | return this.id; 37 | } 38 | 39 | public String getFirstname() { 40 | return this.firstname; 41 | } 42 | 43 | public String getLastname() { 44 | return this.lastname; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-security/src/test/java/org/springframework/data/rest/tests/security/SecuredPersonRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.tests.security; 17 | 18 | import java.util.UUID; 19 | 20 | import org.springframework.data.repository.CrudRepository; 21 | import org.springframework.data.rest.core.annotation.RepositoryRestResource; 22 | import org.springframework.security.access.annotation.Secured; 23 | 24 | // tag::code[] 25 | @Secured("ROLE_USER") // <1> 26 | @RepositoryRestResource(collectionResourceRel = "people", path = "people") 27 | public interface SecuredPersonRepository extends CrudRepository { 28 | 29 | @Secured("ROLE_ADMIN") // <2> 30 | @Override 31 | void deleteById(UUID aLong); 32 | 33 | @Secured("ROLE_ADMIN") 34 | @Override 35 | void delete(Person person); 36 | 37 | @Secured("ROLE_ADMIN") 38 | @Override 39 | void deleteAll(Iterable persons); 40 | 41 | @Secured("ROLE_ADMIN") 42 | @Override 43 | void deleteAll(); 44 | } 45 | // end::code[] 46 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-shop/src/main/java/org/springframework/data/rest/tests/shop/CustomerExcerpt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.tests.shop; 17 | 18 | import org.springframework.beans.factory.annotation.Value; 19 | import org.springframework.data.rest.core.config.Projection; 20 | 21 | /** 22 | * @author Oliver Gierke 23 | */ 24 | @Projection(name = "excerpt", types = Customer.class) 25 | public interface CustomerExcerpt { 26 | 27 | String getFirstname(); 28 | 29 | String getLastname(); 30 | 31 | @Value("#{target.address.toString()}") 32 | String getAddress(); 33 | } 34 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-shop/src/main/java/org/springframework/data/rest/tests/shop/CustomerRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.tests.shop; 17 | 18 | import java.util.UUID; 19 | 20 | import org.springframework.data.repository.CrudRepository; 21 | import org.springframework.data.rest.core.annotation.RepositoryRestResource; 22 | 23 | /** 24 | * @author Oliver Gierke 25 | */ 26 | @RepositoryRestResource(excerptProjection = CustomerExcerpt.class) 27 | public interface CustomerRepository extends CrudRepository { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-shop/src/main/java/org/springframework/data/rest/tests/shop/LineItemType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.tests.shop; 17 | 18 | import java.util.UUID; 19 | 20 | import org.springframework.data.annotation.Id; 21 | import org.springframework.util.ObjectUtils; 22 | 23 | /** 24 | * @author Oliver Gierke 25 | */ 26 | public class LineItemType { 27 | 28 | private final @Id UUID id = UUID.randomUUID(); 29 | private final String name; 30 | 31 | public LineItemType(String name) { 32 | this.name = name; 33 | } 34 | 35 | public UUID getId() { 36 | return this.id; 37 | } 38 | 39 | public String getName() { 40 | return this.name; 41 | } 42 | 43 | @Override 44 | public boolean equals(Object o) { 45 | if (this == o) 46 | return true; 47 | if (o == null || getClass() != o.getClass()) 48 | return false; 49 | 50 | LineItemType that = (LineItemType) o; 51 | 52 | return ObjectUtils.nullSafeEquals(id, that.id); 53 | } 54 | 55 | @Override 56 | public int hashCode() { 57 | return ObjectUtils.nullSafeHashCode(id); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-shop/src/main/java/org/springframework/data/rest/tests/shop/LineItemTypeRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.tests.shop; 17 | 18 | import java.util.Optional; 19 | import java.util.UUID; 20 | 21 | import org.springframework.data.repository.CrudRepository; 22 | 23 | /** 24 | * @author Oliver Gierke 25 | */ 26 | public interface LineItemTypeRepository extends CrudRepository { 27 | 28 | Optional findByName(String name); 29 | } 30 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-shop/src/main/java/org/springframework/data/rest/tests/shop/OrderRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.tests.shop; 17 | 18 | import org.springframework.data.repository.CrudRepository; 19 | import org.springframework.data.rest.tests.shop.Order.OrderIdentifier; 20 | 21 | /** 22 | * @author Oliver Gierke 23 | */ 24 | public interface OrderRepository extends CrudRepository { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-shop/src/main/java/org/springframework/data/rest/tests/shop/ProductExcerpt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.tests.shop; 17 | 18 | /** 19 | * @author Oliver Gierke 20 | */ 21 | interface ProductExcerpt { 22 | 23 | String getName(); 24 | } 25 | -------------------------------------------------------------------------------- /spring-data-rest-tests/spring-data-rest-tests-shop/src/main/java/org/springframework/data/rest/tests/shop/ProductRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.tests.shop; 17 | 18 | import java.util.Optional; 19 | 20 | import org.springframework.data.repository.CrudRepository; 21 | import org.springframework.data.rest.core.annotation.RepositoryRestResource; 22 | 23 | /** 24 | * @author Oliver Gierke 25 | */ 26 | @RepositoryRestResource(excerptProjection = Product.class) 27 | public interface ProductRepository extends CrudRepository { 28 | 29 | Optional findByName(String name); 30 | } 31 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryLinksResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc; 17 | 18 | import org.springframework.hateoas.RepresentationModel; 19 | 20 | /** 21 | * Dedicated resource type to represent the links pointing to collection resources exposed for repositories. 22 | * 23 | * @author Jon Brisbin 24 | * @author Oliver Gierke 25 | */ 26 | public class RepositoryLinksResource extends RepresentationModel {} 27 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryRestDispatcherServlet.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.webmvc; 2 | 3 | import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration; 4 | import org.springframework.web.context.WebApplicationContext; 5 | import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; 6 | import org.springframework.web.servlet.DispatcherServlet; 7 | 8 | /** 9 | * Special {@link DispatcherServlet} subclass that certain exporter components can recognize. 10 | * 11 | * @author Jon Brisbin 12 | */ 13 | public class RepositoryRestDispatcherServlet extends DispatcherServlet { 14 | 15 | private static final long serialVersionUID = 5761346441984290240L; 16 | 17 | public RepositoryRestDispatcherServlet() { 18 | configure(); 19 | } 20 | 21 | public RepositoryRestDispatcherServlet(WebApplicationContext webApplicationContext) { 22 | super(webApplicationContext); 23 | configure(); 24 | } 25 | 26 | private void configure() { 27 | setContextClass(AnnotationConfigWebApplicationContext.class); 28 | setContextConfigLocation(RepositoryRestMvcConfiguration.class.getName()); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ResourceNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc; 17 | 18 | import org.springframework.http.HttpStatus; 19 | import org.springframework.web.bind.annotation.ResponseStatus; 20 | 21 | /** 22 | * Indicates a resource was not found. 23 | * 24 | * @author Jon Brisbin 25 | * @author Oliver Gierke 26 | */ 27 | @ResponseStatus(HttpStatus.NOT_FOUND) 28 | public class ResourceNotFoundException extends RuntimeException { 29 | 30 | private static final long serialVersionUID = 7992904489502842099L; 31 | 32 | public ResourceNotFoundException() { 33 | this("EntityRepresentationModel not found"); 34 | } 35 | 36 | public ResourceNotFoundException(String message) { 37 | this(message, null); 38 | } 39 | 40 | public ResourceNotFoundException(String message, Throwable cause) { 41 | super(message, cause); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/aot/BasePathAwareControllerAotProcessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.aot; 17 | 18 | import org.springframework.data.rest.webmvc.BasePathAwareController; 19 | import org.springframework.hateoas.aot.ControllerMethodReturnTypeAotProcessor; 20 | 21 | /** 22 | * Extension of {@link ControllerMethodReturnTypeAotProcessor} to also pick up controllers defined using 23 | * {@link BasePathAwareController}. 24 | * 25 | * @author Christoph Strobl 26 | * @author Oliver Drotbohm 27 | * @since 4.0 28 | */ 29 | class BasePathAwareControllerAotProcessor extends ControllerMethodReturnTypeAotProcessor { 30 | 31 | protected BasePathAwareControllerAotProcessor() { 32 | super(BasePathAwareController.class); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/aot/RestMessagesResourcesRuntimeHints.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.aot; 17 | 18 | import org.springframework.aot.hint.ResourceHints; 19 | import org.springframework.aot.hint.RuntimeHints; 20 | import org.springframework.aot.hint.RuntimeHintsRegistrar; 21 | 22 | /** 23 | * @author Oliver Drotbohm 24 | */ 25 | class RestMessagesResourcesRuntimeHints implements RuntimeHintsRegistrar { 26 | 27 | /* 28 | * (non-Javadoc) 29 | * @see org.springframework.aot.hint.RuntimeHintsRegistrar#registerHints(org.springframework.aot.hint.RuntimeHints, java.lang.ClassLoader) 30 | */ 31 | @Override 32 | public void registerHints(RuntimeHints hints, ClassLoader classLoader) { 33 | 34 | ResourceHints resources = hints.resources(); 35 | 36 | resources.registerPattern("rest-messages*.properties"); 37 | resources.registerPattern("rest-default-messages.properties"); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/aot/ValueInstantiatorCustomizerRuntimeHints.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.aot; 17 | 18 | import org.springframework.aot.hint.RuntimeHints; 19 | import org.springframework.aot.hint.RuntimeHintsRegistrar; 20 | import org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module.AssociationUriResolvingDeserializerModifier.ValueInstantiatorCustomizer; 21 | 22 | import com.fasterxml.jackson.databind.deser.std.StdValueInstantiator; 23 | 24 | /** 25 | * Registers the {@link StdValueInstantiator}'s {@code _constructorArgs} field for reflection as needed by 26 | * {@link ValueInstantiatorCustomizer}. 27 | * 28 | * @author Oliver Drotbohm 29 | * @since 4.0.2 30 | * @soundtrack The Intersphere - Wanderer (https://www.youtube.com/watch?v=Sp_VyFBbDPA) 31 | */ 32 | class ValueInstantiatorCustomizerRuntimeHints implements RuntimeHintsRegistrar { 33 | 34 | @Override 35 | public void registerHints(RuntimeHints hints, ClassLoader classLoader) { 36 | hints.reflection().registerField(ValueInstantiatorCustomizer.CONSTRUCTOR_ARGS_FIELD); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/aot/package-info.java: -------------------------------------------------------------------------------- 1 | /** AOT & native configuration for rest.webmvc */ 2 | package org.springframework.data.rest.webmvc.aot; 3 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/CorsConfigurationAware.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.config; 17 | 18 | import java.util.Map; 19 | 20 | import org.springframework.web.cors.CorsConfiguration; 21 | 22 | /** 23 | * Components that are aware of CORS configuration. 24 | * 25 | * @author Oliver Drotbohm 26 | * @since 3.4 27 | * @soundtrack Elen - Blind über Rot (Blind über Rot) 28 | */ 29 | public interface CorsConfigurationAware { 30 | 31 | /** 32 | * Return the registered {@link CorsConfiguration} objects, keyed by path pattern. 33 | * 34 | * @return will never be {@literal null}. 35 | */ 36 | Map getCorsConfigurations(); 37 | } 38 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryCorsRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.config; 17 | 18 | import java.util.Map; 19 | 20 | import org.springframework.web.cors.CorsConfiguration; 21 | import org.springframework.web.servlet.config.annotation.CorsRegistry; 22 | 23 | /** 24 | * Spring Data REST specific {@code CorsRegistry} implementation exposing {@link #getCorsConfigurations()}. Assists with 25 | * the registration of {@link CorsConfiguration} mapped to a path pattern. 26 | * 27 | * @author Mark Paluch 28 | * @since 2.6 29 | */ 30 | class RepositoryCorsRegistry extends CorsRegistry { 31 | 32 | @Override 33 | public Map getCorsConfigurations() { 34 | return super.getCorsConfigurations(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/StaticResourceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.config; 17 | 18 | import org.springframework.data.rest.core.config.RepositoryRestConfiguration; 19 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 20 | 21 | /** 22 | * SPI to be able to register extensions that add static resource routes. See 23 | * {@code org.springframework.data.rest.webmvc.halexplorer.HalExplorerConfiguration} in the HAL Explorer module. 24 | * 25 | * @author Oliver Drotbohm 26 | * @since 3.2 27 | */ 28 | public interface StaticResourceProvider { 29 | 30 | /** 31 | * Customize the given {@link ResourceHandlerRegistry}. 32 | * 33 | * @param registry must not be {@literal null}. 34 | * @param configuration must not be {@literal null}. 35 | */ 36 | void customizeResources(ResourceHandlerRegistry registry, RepositoryRestConfiguration configuration); 37 | } 38 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/BindContextFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.json; 17 | 18 | import org.springframework.data.rest.webmvc.json.patch.BindContext; 19 | 20 | import com.fasterxml.jackson.databind.ObjectMapper; 21 | 22 | /** 23 | * Factory to create {@link BindContext} instances. 24 | * 25 | * @author Oliver Drotbohm 26 | */ 27 | public interface BindContextFactory { 28 | 29 | /** 30 | * Creates a {@link BindContext} for the given {@link ObjectMapper}. 31 | * 32 | * @param mapper must not be {@literal null}. 33 | * @return will never be {@literal null}. 34 | */ 35 | BindContext getBindContextFor(ObjectMapper mapper); 36 | } 37 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/JsonSchemaPropertyCustomizer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.json; 17 | 18 | import org.springframework.data.rest.webmvc.json.JsonSchema.JsonSchemaProperty; 19 | import org.springframework.data.util.TypeInformation; 20 | 21 | /** 22 | * Callback interface to customize the {@link JsonSchemaProperty} created by default for a given type. 23 | * 24 | * @author Oliver Gierke 25 | * @since 2.4 26 | * @soundtrack Superflight - Four Sided Cube (Bellyjam) 27 | */ 28 | public interface JsonSchemaPropertyCustomizer { 29 | 30 | /** 31 | * Returns the customized {@link JsonSchemaProperty} based on the given one and the given type. 32 | * 33 | * @param property will never be {@literal null}. 34 | * @param type will never be {@literal null}. 35 | * @return 36 | */ 37 | JsonSchemaProperty customize(JsonSchemaProperty property, TypeInformation type); 38 | } 39 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | @org.springframework.lang.NonNullApi 17 | package org.springframework.data.rest.webmvc.json; 18 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/patch/LateObjectEvaluator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.json.patch; 17 | 18 | /** 19 | *

20 | * Strategy interface for resolving values from an operation definition. 21 | *

22 | *

23 | * {@link Patch} implementation generically defines a patch without being tied to any particular patch specification. 24 | * But it's important to know the patch format when resolving the value of an operation, as the value format will likely 25 | * be tied to the patch specification. For example, the value attribute of a JSON Patch operation will 26 | * contain a JSON object. A different patch specification may define values in some non-JSON format. 27 | *

28 | *

29 | * This interface allows for pluggable evaluation of values, allowing {@link Patch} to remain independent of any 30 | * specific patch representation. 31 | *

32 | * 33 | * @author Craig Walls 34 | */ 35 | interface LateObjectEvaluator { 36 | 37 | Object evaluate(Class type); 38 | } 39 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/patch/PatchException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.json.patch; 17 | 18 | /** 19 | * Exception thrown if an error occurs in the course of applying a Patch. 20 | * 21 | * @author Craig Walls 22 | * @author Oliver Gierke 23 | */ 24 | public class PatchException extends RuntimeException { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | public PatchException(String message) { 29 | super(message); 30 | } 31 | 32 | public PatchException(String message, Exception e) { 33 | super(message, e); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/patch/RemoveOperation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.json.patch; 17 | 18 | import org.springframework.data.rest.webmvc.json.patch.SpelPath.UntypedSpelPath; 19 | 20 | /** 21 | * Operation that removes the value at the given path. Will throw a {@link PatchException} if the given path isn't valid 22 | * or if the path is non-nullable. 23 | * 24 | * @author Craig Walls 25 | * @author Oliver Gierke 26 | */ 27 | class RemoveOperation extends PatchOperation { 28 | 29 | /** 30 | * Constructs the remove operation 31 | * 32 | * @param path The path of the value to be removed. (e.g., '/foo/bar/4') 33 | */ 34 | private RemoveOperation(UntypedSpelPath path) { 35 | super("remove", path); 36 | } 37 | 38 | public static RemoveOperation valueAt(String path) { 39 | return new RemoveOperation(SpelPath.untyped(path)); 40 | } 41 | 42 | @Override 43 | void perform(Object target, Class type, BindContext context) { 44 | path.bindForWrite(type, context).removeFrom(target); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/patch/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | @org.springframework.lang.NonNullApi 17 | package org.springframework.data.rest.webmvc.json.patch; 18 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/mapping/LinkCollector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.mapping; 17 | 18 | import org.springframework.hateoas.Link; 19 | import org.springframework.hateoas.Links; 20 | 21 | /** 22 | * A service to collect all standard links that need to be added to a certain object. 23 | * 24 | * @author Oliver Gierke 25 | */ 26 | public interface LinkCollector { 27 | 28 | /** 29 | * Returns all {@link Links} for the given object. 30 | * 31 | * @param object must not be {@literal null}. 32 | * @return 33 | */ 34 | Links getLinksFor(Object object); 35 | 36 | /** 37 | * Returns all {@link Links} for the given object and already existing {@link Link}. 38 | * 39 | * @param object must not be {@literal null}. 40 | * @param existing must not be {@literal null}. 41 | * @return 42 | */ 43 | Links getLinksFor(Object object, Links existing); 44 | 45 | Links getLinksForNested(Object object, Links existing); 46 | } 47 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/package-info.java: -------------------------------------------------------------------------------- 1 | @org.springframework.lang.NonNullApi 2 | package org.springframework.data.rest.webmvc; 3 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/BackendId.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.support; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * Annotation to bind the backend id of an entity. 25 | * 26 | * @author Oliver Gierke 27 | */ 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Target(ElementType.PARAMETER) 30 | public @interface BackendId { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/ConstraintViolationExceptionMessage.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.webmvc.support; 2 | 3 | import jakarta.validation.ConstraintViolation; 4 | import jakarta.validation.ConstraintViolationException; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.Locale; 9 | 10 | import org.springframework.context.MessageSource; 11 | 12 | import com.fasterxml.jackson.annotation.JsonProperty; 13 | 14 | /** 15 | * @author Jon Brisbin 16 | */ 17 | public class ConstraintViolationExceptionMessage { 18 | 19 | private final ConstraintViolationException cve; 20 | private final List messages = new ArrayList(); 21 | 22 | public ConstraintViolationExceptionMessage(ConstraintViolationException cve, MessageSource msgSrc, Locale locale) { 23 | this.cve = cve; 24 | for (ConstraintViolation cv : cve.getConstraintViolations()) { 25 | messages.add(new ConstraintViolationMessage(cv, msgSrc, locale)); 26 | } 27 | } 28 | 29 | @JsonProperty("cause") 30 | public String getCause() { 31 | return cve.getMessage(); 32 | } 33 | 34 | @JsonProperty("messages") 35 | public List getMessages() { 36 | return messages; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/ConstraintViolationMessage.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.webmvc.support; 2 | 3 | import static java.lang.String.*; 4 | 5 | import jakarta.validation.ConstraintViolation; 6 | 7 | import java.util.Locale; 8 | 9 | import org.springframework.context.MessageSource; 10 | 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | 13 | /** 14 | * A helper class to encapsulate {@link ConstraintViolation} errors. 15 | * 16 | * @author Jon Brisbin 17 | */ 18 | public class ConstraintViolationMessage { 19 | 20 | private final ConstraintViolation violation; 21 | private final String message; 22 | 23 | public ConstraintViolationMessage(ConstraintViolation violation, MessageSource msgSrc, Locale locale) { 24 | this.violation = violation; 25 | this.message = msgSrc.getMessage(violation.getMessageTemplate(), 26 | new Object[] { violation.getLeafBean().getClass().getSimpleName(), violation.getPropertyPath().toString(), 27 | violation.getInvalidValue() }, 28 | violation.getMessage(), locale); 29 | } 30 | 31 | @JsonProperty("entity") 32 | public String getEntity() { 33 | return violation.getRootBean().getClass().getName(); 34 | } 35 | 36 | @JsonProperty("message") 37 | public String getMessage() { 38 | return message; 39 | } 40 | 41 | @JsonProperty("invalidValue") 42 | public String getInvalidValue() { 43 | return format("%s", violation.getInvalidValue()); 44 | } 45 | 46 | @JsonProperty("property") 47 | public String getProperty() { 48 | return violation.getPropertyPath().toString(); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/ExceptionMessage.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.webmvc.support; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | /** 6 | * A helper that renders an {@link Exception} JSON-friendly. 7 | * 8 | * @author Jon Brisbin 9 | */ 10 | public class ExceptionMessage { 11 | 12 | private final Throwable throwable; 13 | 14 | public ExceptionMessage(Throwable throwable) { 15 | this.throwable = throwable; 16 | } 17 | 18 | @JsonProperty("message") 19 | public String getMessage() { 20 | return throwable.getMessage(); 21 | } 22 | 23 | @JsonProperty("cause") 24 | public ExceptionMessage getCause() { 25 | return throwable.getCause() != null ? new ExceptionMessage(throwable.getCause()) : null; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/ExcerptProjector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.support; 17 | 18 | /** 19 | * Interface for a component that can provide excerpt projections. 20 | * 21 | * @author Oliver Gierke 22 | * @since 2.5 23 | */ 24 | public interface ExcerptProjector { 25 | 26 | /** 27 | * Creates a excerpt projection for the given source. If no excerpt projection is available, the object will be 28 | * returned as is. If you completely wish to skip handling the object, check for the presence of an excerpt projection 29 | * using {@link #hasExcerptProjection(Class)}. 30 | * 31 | * @param source must not be {@literal null}. 32 | * @return 33 | */ 34 | Object projectExcerpt(Object source); 35 | 36 | /** 37 | * Returns whether an excerpt projection has been registered for the given type. 38 | * 39 | * @param type must not be {@literal null}. 40 | * @return 41 | */ 42 | boolean hasExcerptProjection(Class type); 43 | } 44 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/JpaHelper.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.webmvc.support; 2 | 3 | import jakarta.persistence.EntityManagerFactory; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.springframework.beans.BeansException; 9 | import org.springframework.beans.factory.BeanFactory; 10 | import org.springframework.beans.factory.BeanFactoryAware; 11 | import org.springframework.beans.factory.BeanFactoryUtils; 12 | import org.springframework.beans.factory.ListableBeanFactory; 13 | import org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor; 14 | import org.springframework.web.context.request.WebRequestInterceptor; 15 | 16 | /** 17 | * @author Jon Brisbin 18 | */ 19 | public class JpaHelper implements BeanFactoryAware { 20 | 21 | private List interceptor = new ArrayList(); 22 | 23 | @Override 24 | public void setBeanFactory(BeanFactory beanFactory) throws BeansException { 25 | String[] beanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors((ListableBeanFactory) beanFactory, 26 | EntityManagerFactory.class); 27 | for (String s : beanNames) { 28 | EntityManagerFactory emf = (EntityManagerFactory) beanFactory.getBean(s); 29 | OpenEntityManagerInViewInterceptor omivi = new OpenEntityManagerInViewInterceptor(); 30 | omivi.setEntityManagerFactory(emf); 31 | interceptor.add(omivi); 32 | } 33 | } 34 | 35 | public List getInterceptors() { 36 | return interceptor; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/Projector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.support; 17 | 18 | /** 19 | * Interface for a component being able to create projections for objects. 20 | * 21 | * @author Oliver Gierke 22 | */ 23 | public interface Projector extends ExcerptProjector { 24 | 25 | /** 26 | * Returns the projection object for the given source. This may result in the same object being returned or a 27 | * completely different acting as projection for the source. 28 | * 29 | * @param source must not be {@literal null}. 30 | * @return 31 | */ 32 | Object project(Object source); 33 | } 34 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/resources/META-INF/spring/aot.factories: -------------------------------------------------------------------------------- 1 | org.springframework.beans.factory.aot.BeanRegistrationAotProcessor=\ 2 | org.springframework.data.rest.webmvc.aot.BasePathAwareControllerAotProcessor,\ 3 | org.springframework.data.rest.webmvc.aot.ProjectionProxyAotProcessor 4 | org.springframework.aot.hint.RuntimeHintsRegistrar=\ 5 | org.springframework.data.rest.webmvc.aot.ValueInstantiatorCustomizerRuntimeHints,\ 6 | org.springframework.data.rest.webmvc.aot.RestMessagesResourcesRuntimeHints 7 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/main/resources/rest-default-messages.properties: -------------------------------------------------------------------------------- 1 | rest.description.pagination.page.description=The page to return. 2 | rest.description.pagination.size.description=The size of the page to return. 3 | rest.description.pagination.sort.description=The sorting criteria to use to calculate the content of the page. 4 | rest.description.projection=The projection that shall be applied when rendering the response. Acceptable values available in nested descriptors. 5 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/RepositorySearchesResourceUnitTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2022 original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc; 17 | 18 | import static org.assertj.core.api.Assertions.*; 19 | 20 | import org.junit.jupiter.api.Test; 21 | 22 | /** 23 | * Unit tests for {@link RepositorySearchesResource} 24 | * 25 | * @author Oliver Gierke 26 | * @soundtrack Bakkushan - Gefahr (Bakkushan) 27 | */ 28 | class RepositorySearchesResourceUnitTests { 29 | 30 | @Test // DATAREST-515 31 | void rejectsNullDomainType() { 32 | 33 | assertThatIllegalArgumentException() // 34 | .isThrownBy(() -> new RepositorySearchesResource(null)); 35 | } 36 | 37 | @Test // DATAREST-515 38 | void returnsConfiguredDomainType() { 39 | assertThat(new RepositorySearchesResource(String.class).getDomainType()).isAssignableFrom(String.class); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/Requests.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.webmvc; 2 | 3 | import org.springframework.mock.web.MockHttpServletRequest; 4 | 5 | /** 6 | * @author Jon Brisbin 7 | */ 8 | public abstract class Requests { 9 | 10 | public static MockHttpServletRequest ROOT_REQUEST = new MockHttpServletRequest("GET", "http://localhost:8080/"); 11 | public static MockHttpServletRequest PAGE_REQUEST = new MockHttpServletRequest("GET", "http://localhost:8080/"); 12 | 13 | static { 14 | PAGE_REQUEST.setParameter("page", "2"); 15 | PAGE_REQUEST.setParameter("size", "10"); 16 | } 17 | 18 | private Requests() {} 19 | 20 | } 21 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/ValidationErrors.properties: -------------------------------------------------------------------------------- 1 | field.name.required = Field {0}.{1} is required. 2 | no.userid = {0}s must be assigned initial userids. -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/JsonSchemaUnitTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2022 original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.json; 17 | 18 | import static org.assertj.core.api.Assertions.*; 19 | 20 | import org.junit.jupiter.api.Test; 21 | import org.springframework.data.rest.webmvc.json.JsonSchema.JsonSchemaProperty; 22 | import org.springframework.data.util.TypeInformation; 23 | 24 | /** 25 | * Unit tests for {@link JsonSchema}. 26 | * 27 | * @author Oliver Gierke 28 | */ 29 | class JsonSchemaUnitTests { 30 | 31 | static final TypeInformation type = TypeInformation.of(Sample.class); 32 | 33 | @Test // DATAREST-492 34 | void considersNumberPrimitivesJsonSchemaNumbers() { 35 | 36 | JsonSchemaProperty property = new JsonSchemaProperty("foo", null, "bar", false); 37 | 38 | assertThat(property.with(type.getRequiredProperty("foo")).type).isEqualTo("number"); 39 | } 40 | 41 | static class Sample { 42 | double foo; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/patch/TodoList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.json.patch; 17 | 18 | import java.io.Serializable; 19 | import java.util.List; 20 | 21 | class TodoList implements Serializable { 22 | 23 | private static final long serialVersionUID = 1L; 24 | 25 | private List todos; 26 | private Todo[] todoArray; 27 | private String name; 28 | 29 | public List getTodos() { 30 | return this.todos; 31 | } 32 | 33 | public Todo[] getTodoArray() { 34 | return this.todoArray; 35 | } 36 | 37 | public String getName() { 38 | return this.name; 39 | } 40 | 41 | public void setTodos(List todos) { 42 | this.todos = todos; 43 | } 44 | 45 | public void setTodoArray(Todo[] todoArray) { 46 | this.todoArray = todoArray; 47 | } 48 | 49 | public void setName(String name) { 50 | this.name = name; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/patch/TodoType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2025 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.json.patch; 17 | 18 | import org.springframework.util.ObjectUtils; 19 | 20 | /** 21 | * @author Mathias Düsterhöft 22 | * @author Oliver Gierke 23 | */ 24 | class TodoType { 25 | private String value = "none"; 26 | 27 | public TodoType(String value) { 28 | this.value = value; 29 | } 30 | 31 | public TodoType() {} 32 | 33 | public String getValue() { 34 | return this.value; 35 | } 36 | 37 | public void setValue(String value) { 38 | this.value = value; 39 | } 40 | 41 | @Override 42 | public boolean equals(Object o) { 43 | if (this == o) 44 | return true; 45 | if (o == null || getClass() != o.getClass()) 46 | return false; 47 | 48 | TodoType todoType = (TodoType) o; 49 | 50 | return ObjectUtils.nullSafeEquals(value, todoType.value); 51 | } 52 | 53 | @Override 54 | public int hashCode() { 55 | return ObjectUtils.nullSafeHashCode(value); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/support/ETagDoesntMatchExceptionUnitTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2022 original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.springframework.data.rest.webmvc.support; 17 | 18 | import static org.assertj.core.api.Assertions.*; 19 | 20 | import org.junit.jupiter.api.Test; 21 | 22 | /** 23 | * Unit tests for {@link ETagDoesntMatchException}. 24 | * 25 | * @author Oliver Gierke 26 | */ 27 | class ETagDoesntMatchExceptionUnitTests { 28 | 29 | @Test // DATAREST-160 30 | void rejectsNullTargetBean() { 31 | 32 | assertThatIllegalArgumentException() // 33 | .isThrownBy(() -> new ETagDoesntMatchException(null, ETag.from("1"))); 34 | } 35 | 36 | @Test // DATAREST-160 37 | void rejectsNullExpectedETag() { 38 | 39 | assertThatIllegalArgumentException() // 40 | .isThrownBy(() -> new ETagDoesntMatchException(new Object(), null)); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/util/AssertionUtils.java: -------------------------------------------------------------------------------- 1 | package org.springframework.data.rest.webmvc.util; 2 | 3 | import java.util.function.Predicate; 4 | 5 | /** 6 | * Various extensions of AssertJ to improve testing. 7 | * 8 | * @author Greg Turnquist 9 | */ 10 | public final class AssertionUtils { 11 | 12 | /** 13 | * {@link Predicate} to verify a given string ends in a certain suffix. 14 | * 15 | * @param suffix 16 | * @return 17 | */ 18 | public static Predicate suffix(String suffix) { 19 | return s -> s.endsWith(suffix); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d %5p %40.40c:%4L - %m%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/test/resources/org/springframework/data/rest/webmvc/json/patch/patch-array.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"op":"replace", "path":"/items", "value": ["one","two","three"]} 3 | ] -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/test/resources/org/springframework/data/rest/webmvc/json/patch/patch-biginteger.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"op":"replace", "path":"/amount", "value": 18446744073709551616 } 3 | ] -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/test/resources/org/springframework/data/rest/webmvc/json/patch/patch-failing-operation-first.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"op":"test", "path":"/5/description", "value":"A"}, 3 | {"op":"remove", "path":"/5"}, 4 | {"op":"replace", "path":"/1/complete", "value":true}, 5 | {"op":"copy", "path":"/3/description", "from":"/2/description"}, 6 | {"op":"copy", "path":"/4", "from":"/0"} 7 | ] -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/test/resources/org/springframework/data/rest/webmvc/json/patch/patch-failing-operation-in-middle.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"op":"test", "path":"/5/description", "value":"A"}, 3 | {"op":"remove", "path":"/5"}, 4 | {"op":"replace", "path":"/1/complete", "value":true}, 5 | {"op":"test", "path":"/0/description", "value":"HUH"}, 6 | {"op":"copy", "path":"/3/description", "from":"/2/description"}, 7 | {"op":"copy", "path":"/4", "from":"/0"} 8 | ] -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/test/resources/org/springframework/data/rest/webmvc/json/patch/patch-failing-with-invalid-content.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"op":"add", "path":"/description", "value": { "content" : "blabla"}} 3 | ] -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/test/resources/org/springframework/data/rest/webmvc/json/patch/patch-invalid-path.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"op":"replace", "path":"/somethingInvalid", "value": "bar" } 3 | ] 4 | -------------------------------------------------------------------------------- /spring-data-rest-webmvc/src/test/resources/org/springframework/data/rest/webmvc/json/patch/patch-many-successful-operations.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"op":"test", "path":"/0", "value":{"id":1,"description":"A","complete":true}}, 3 | {"op":"test", "path":"/5/description", "value":"F"}, 4 | {"op":"remove", "path":"/5"}, 5 | {"op":"replace", "path":"/1/complete", "value":true}, 6 | {"op":"copy", "path":"/3/description", "from":"/2/description"}, 7 | {"op":"copy", "path":"/4", "from":"/0"} 8 | ] -------------------------------------------------------------------------------- /src/main/antora/antora-playbook.yml: -------------------------------------------------------------------------------- 1 | # PACKAGES antora@3.2.0-alpha.2 @antora/atlas-extension:1.0.0-alpha.1 @antora/collector-extension@1.0.0-alpha.3 @springio/antora-extensions@1.1.0-alpha.2 @asciidoctor/tabs@1.0.0-alpha.12 @opendevise/antora-release-line-extension@1.0.0-alpha.2 2 | # 3 | # The purpose of this Antora playbook is to build the docs in the current branch. 4 | antora: 5 | extensions: 6 | - require: '@springio/antora-extensions' 7 | root_component_name: 'data-rest' 8 | site: 9 | title: Spring Data REST 10 | url: https://docs.spring.io/spring-data-rest/reference/ 11 | content: 12 | sources: 13 | - url: ./../../.. 14 | branches: HEAD 15 | start_path: src/main/antora 16 | worktrees: true 17 | asciidoc: 18 | attributes: 19 | hide-uri-scheme: '@' 20 | tabs-sync-option: '@' 21 | extensions: 22 | - '@asciidoctor/tabs' 23 | - '@springio/asciidoctor-extensions' 24 | - '@springio/asciidoctor-extensions/javadoc-extension' 25 | sourcemap: true 26 | urls: 27 | latest_version_segment: '' 28 | runtime: 29 | log: 30 | failure_level: warn 31 | format: pretty 32 | ui: 33 | bundle: 34 | url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.4.16/ui-bundle.zip 35 | snapshot: true 36 | -------------------------------------------------------------------------------- /src/main/antora/antora.yml: -------------------------------------------------------------------------------- 1 | name: data-rest 2 | version: true 3 | title: Spring Data REST 4 | nav: 5 | - modules/ROOT/nav.adoc 6 | ext: 7 | collector: 8 | - run: 9 | command: ./mvnw validate process-resources -pl :spring-data-rest-distribution -am -Pantora-process-resources 10 | local: true 11 | scan: 12 | dir: spring-data-rest-distribution/target/classes/ 13 | - run: 14 | command: ./mvnw package -Pdistribute 15 | local: true 16 | scan: 17 | dir: target/antora 18 | -------------------------------------------------------------------------------- /src/main/antora/modules/ROOT/examples/mongodb: -------------------------------------------------------------------------------- 1 | ../../../../../../spring-data-rest-tests/spring-data-rest-tests-mongodb/src/main/java/org/springframework/data/rest/tests/mongodb -------------------------------------------------------------------------------- /src/main/antora/modules/ROOT/examples/security: -------------------------------------------------------------------------------- 1 | ../../../../../../spring-data-rest-tests/spring-data-rest-tests-security/src/test/java/org/springframework/data/rest/tests/security -------------------------------------------------------------------------------- /src/main/antora/modules/ROOT/examples/support: -------------------------------------------------------------------------------- 1 | ../../../../../../spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/support -------------------------------------------------------------------------------- /src/main/antora/modules/ROOT/images/hal-explorer-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-projects/spring-data-rest/a6889a70e4d6623d7398f99cc987b9036250bedc/src/main/antora/modules/ROOT/images/hal-explorer-1.png -------------------------------------------------------------------------------- /src/main/antora/modules/ROOT/images/hal-explorer-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-projects/spring-data-rest/a6889a70e4d6623d7398f99cc987b9036250bedc/src/main/antora/modules/ROOT/images/hal-explorer-2.png -------------------------------------------------------------------------------- /src/main/antora/modules/ROOT/images/hal-explorer-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-projects/spring-data-rest/a6889a70e4d6623d7398f99cc987b9036250bedc/src/main/antora/modules/ROOT/images/hal-explorer-3.png -------------------------------------------------------------------------------- /src/main/antora/modules/ROOT/nav.adoc: -------------------------------------------------------------------------------- 1 | * xref:index.adoc[] 2 | 3 | * xref:intro.adoc[] 4 | ** xref:introduction/upgrade.adoc[] 5 | ** xref:introduction/getting-started.adoc[] 6 | ** xref:introduction/example-api-usage-with-curl.adoc[] 7 | ** xref:introduction/spring-data-rest-examples.adoc[] 8 | 9 | * xref:repository-resources.adoc[] 10 | ** xref:paging-and-sorting.adoc[] 11 | ** xref:projections-excerpts.adoc[] 12 | 13 | * xref:representations.adoc[Representations] 14 | * xref:etags-and-other-conditionals.adoc[Conditional Operations] 15 | * xref:validation.adoc[] 16 | * xref:events.adoc[] 17 | * xref:integration.adoc[] 18 | * xref:metadata.adoc[] 19 | * xref:security.adoc[] 20 | * xref:tools.adoc[] 21 | 22 | * xref:customizing-sdr.adoc[] 23 | ** xref:customizing/configuring-the-rest-url-path.adoc[] 24 | ** xref:customizing/adding-sdr-to-spring-mvc-app.adoc[] 25 | ** xref:customizing/overriding-sdr-response-handlers.adoc[] 26 | ** xref:customizing/customizing-json-output.adoc[] 27 | ** xref:customizing/custom-jackson-deserialization.adoc[] 28 | ** xref:customizing/configuring-cors.adoc[] 29 | 30 | * xref:attachment$api/java/index.html[Javadoc,role=link-external,window=_blank] 31 | * https://github.com/spring-projects/spring-data-commons/wiki[Wiki,role=link-external,window=_blank] 32 | -------------------------------------------------------------------------------- /src/main/antora/modules/ROOT/pages/index.adoc: -------------------------------------------------------------------------------- 1 | [[spring-data-rest-reference-documentation]] 2 | = Spring Data REST 3 | :feature-scroll: true 4 | 5 | _Spring Data REST exports Spring Data repositories as REST resources through WebMVC. 6 | It eases development of applications with a consistent programming model backed by Spring Data modules sources._ 7 | 8 | [horizontal] 9 | xref:intro.adoc[Introduction] :: Introduction to Spring Data REST and Examples 10 | xref:repository-resources.adoc[Repository Resources] :: Exporting Repositories as REST Resources 11 | xref:representations.adoc[Representations] :: Domain Object Representations (Object Mapping) 12 | xref:etags-and-other-conditionals.adoc[Conditionals] :: Conditional Operations with ETag and other Headers 13 | xref:validation.adoc[Validation] :: Validator Integration 14 | xref:events.adoc[Events] :: Listening to REST Events 15 | xref:integration.adoc[Integration] :: Integration with Spring Data REST components 16 | xref:metadata.adoc[Metadata] :: ALPS and JSON Schema 17 | xref:security.adoc[Security] :: Spring Security Integration 18 | xref:tools.adoc[Tools] :: HAL Explorer 19 | xref:customizing-sdr.adoc[Customizing] :: Tutorials and Recipes to customize Spring Data REST 20 | https://github.com/spring-projects/spring-data-commons/wiki[Wiki] :: What's New, 21 | Upgrade Notes, Supported Versions, additional cross-version information. 22 | 23 | Jon Brisbin, Oliver Drotbohm, Greg Turnquist, Jay Bryant 24 | 25 | (C) 2008-2025 VMware, Inc. 26 | 27 | Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically. 28 | -------------------------------------------------------------------------------- /src/main/antora/modules/ROOT/pages/intro.adoc: -------------------------------------------------------------------------------- 1 | [[intro-chapter]] 2 | = Introduction 3 | :page-section-summary-toc: 1 4 | 5 | REST web services have become the number one means for application integration on the web. In its core, REST defines that a system that consists of resources with which clients interact. These resources are implemented in a hypermedia-driven way. link:{springDocsUrl}/web.html#spring-web[Spring MVC] and link:{springDocsUrl}/web-reactive.html#spring-webflux[Spring WebFlux] each offer a solid foundation to build these kinds of services. However, implementing even the simplest tenet of REST web services for a multi-domain object system can be quite tedious and result in a lot of boilerplate code. 6 | 7 | Spring Data REST builds on top of the Spring Data repositories and automatically exports those as REST resources. It leverages hypermedia to let clients automatically find functionality exposed by the repositories and integrate these resources into related hypermedia-based functionality. 8 | -------------------------------------------------------------------------------- /src/main/antora/modules/ROOT/pages/introduction/example-api-usage-with-curl.adoc: -------------------------------------------------------------------------------- 1 | [[example-api-usage-with-curl]] 2 | [appendix] 3 | [[using-curl-to-talk-to-spring-data-rest]] 4 | = Using cURL to talk to Spring Data REST 5 | :page-section-summary-toc: 1 6 | 7 | This appendix contains a list of guides that demonstrate interacting with a Spring Data REST service over cURL: 8 | 9 | * https://spring.io/guides/gs/accessing-data-rest/[Accessing JPA Data with REST] 10 | * https://spring.io/guides/gs/accessing-neo4j-data-rest/[Accessing Neo4j Data with REST] 11 | * https://spring.io/guides/gs/accessing-mongodb-data-rest/[Accessing MongoDB Data with REST] 12 | * https://spring.io/guides/gs/accessing-gemfire-data-rest/[Accessing GemFire Data with REST] 13 | -------------------------------------------------------------------------------- /src/main/antora/modules/ROOT/pages/introduction/upgrade.adoc: -------------------------------------------------------------------------------- 1 | [[new-features]] 2 | [[upgrading]] 3 | = Upgrading Spring Data 4 | 5 | Instructions for how to upgrade from earlier versions of Spring Data are provided on the project https://github.com/spring-projects/spring-data-commons/wiki[wiki]. 6 | Follow the links in the https://github.com/spring-projects/spring-data-commons/wiki#release-notes[release notes section] to find the version that you want to upgrade to. 7 | 8 | Upgrading instructions are always the first item in the release notes. If you are more than one release behind, please make sure that you also review the release notes of the versions that you jumped. 9 | -------------------------------------------------------------------------------- /src/main/antora/modules/ROOT/pages/validation.adoc: -------------------------------------------------------------------------------- 1 | [[validation]] 2 | = Validation 3 | 4 | There are two ways to register a `Validator` instance in Spring Data REST: wire it by bean name or register the validator manually. For the majority of cases, the simple bean name prefix style is sufficient. 5 | 6 | In order to tell Spring Data REST you want a particular `Validator` assigned to a particular event, prefix the bean name with the event in question. For example, to validate instances of the `Person` class before new ones are saved into the repository, you would declare an instance of a `Validator` in your `ApplicationContext` with a bean name of `beforeCreatePersonValidator`. Since the `beforeCreate` prefix matches a known Spring Data REST event, that validator is wired to the correct event. 7 | 8 | [[validation.assigning-validators]] 9 | == Assigning Validators Manually 10 | 11 | If you would rather not use the bean name prefix approach, you need to register an instance of your validator with the bean whose job it is to invoke validators after the correct event. In your configuration that implements `RepositoryRestConfigurer`, override the `configureValidatingRepositoryEventListener` method and call `addValidator` on the `ValidatingRepositoryEventListener`, passing the event on which you want this validator to be triggered and an instance of the validator. The following example shows how to do so: 12 | 13 | ==== 14 | [source,java] 15 | ---- 16 | @Override 17 | void configureValidatingRepositoryEventListener(ValidatingRepositoryEventListener v) { 18 | v.addValidator("beforeSave", new BeforeSaveValidator()); 19 | } 20 | ---- 21 | ==== 22 | -------------------------------------------------------------------------------- /src/main/antora/resources/antora-resources/antora.yml: -------------------------------------------------------------------------------- 1 | version: ${antora-component.version} 2 | prerelease: ${antora-component.prerelease} 3 | 4 | asciidoc: 5 | attributes: 6 | version: ${project.version} 7 | springversionshort: ${spring.short} 8 | springversion: ${spring} 9 | attribute-missing: 'warn' 10 | commons: ${springdata.commons.docs} 11 | include-xml-namespaces: false 12 | spring-data-commons-docs-url: https://docs.spring.io/spring-data/commons/reference 13 | spring-data-commons-javadoc-base: https://docs.spring.io/spring-data/commons/docs/${springdata.commons}/api/ 14 | springdocsurl: https://docs.spring.io/spring-framework/reference/{springversionshort} 15 | springjavadocurl: https://docs.spring.io/spring-framework/docs/${spring}/javadoc-api 16 | spring-framework-docs: '{springdocsurl}' 17 | spring-framework-javadoc: '{springjavadocurl}' 18 | springhateoasversion: ${spring-hateoas} 19 | releasetrainversion: ${releasetrain} 20 | -------------------------------------------------------------------------------- /src/main/asciidoc/images/epub-cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-projects/spring-data-rest/a6889a70e4d6623d7398f99cc987b9036250bedc/src/main/asciidoc/images/epub-cover.png -------------------------------------------------------------------------------- /src/main/asciidoc/images/hal-explorer-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-projects/spring-data-rest/a6889a70e4d6623d7398f99cc987b9036250bedc/src/main/asciidoc/images/hal-explorer-1.png -------------------------------------------------------------------------------- /src/main/asciidoc/images/hal-explorer-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-projects/spring-data-rest/a6889a70e4d6623d7398f99cc987b9036250bedc/src/main/asciidoc/images/hal-explorer-2.png -------------------------------------------------------------------------------- /src/main/asciidoc/images/hal-explorer-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-projects/spring-data-rest/a6889a70e4d6623d7398f99cc987b9036250bedc/src/main/asciidoc/images/hal-explorer-3.png -------------------------------------------------------------------------------- /src/main/resources/notice.txt: -------------------------------------------------------------------------------- 1 | Spring Data REST 5.0 M3 (2025.1.0) 2 | Copyright (c) 2012-2019 Pivotal Software, Inc. 3 | 4 | This product is licensed to you under the Apache License, Version 2.0 5 | (the "License"). You may not use this product except in compliance with 6 | the License. 7 | 8 | This product may include a number of subcomponents with separate 9 | copyright notices and license terms. Your use of the source code for 10 | these subcomponents is subject to the terms and conditions of the 11 | subcomponent's license, as noted in the license.txt file. 12 | 13 | --------------------------------------------------------------------------------