Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support RepositoryDetectionStrategies.EXPLICIT_METHOD_ANNOTATED [DATAREST-1268] #1605

Closed
spring-projects-issues opened this issue Jul 26, 2018 · 3 comments
Assignees
Labels
type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link

spring-projects-issues commented Jul 26, 2018

Dario Seidl opened DATAREST-1268 and commented

In the RepositoryDetectionStrategy interface, there's an EXPLICIT_METHOD_ANNOTATED strategy defined. Afaict, it is not documented and not implemented. It does exactly the same as the ANNOTATED strategy, both call isExplicitlyExported:

		/**
		 * Considers repositories that are annotated with {@link RepositoryRestResource} or {@link RestResource} and don't
		 * have the {@code exported} flag not set to {@literal false}.
		 */
		ANNOTATED {

			@Override
			public boolean isExported(RepositoryMetadata metadata) {
				return isExplicitlyExported(metadata.getRepositoryInterface(), false);
			}
		},

		/**
		 * Behaves like the annotated strategy on repository level. But it does not export all methods
		 * of an exported Repository. The methods have to be annotated explicitly too.
		 */
		EXPLICIT_METHOD_ANNOTATED {

			@Override
			public boolean isExported(RepositoryMetadata metadata) {
				return isExplicitlyExported(metadata.getRepositoryInterface(), false);
			}
		};

The JavaDoc is misleading here and tricked me into thinking this would not export our methods unless we annotate them.

It would be a very useful setting to ensure that no method is exported by accident. It would be great if it could be implemented.


Affects: 3.0.8 (Kay SR8)

Reference URL: 5172f89

Issue Links:

  • DATAREST-1176 Add ability to only expose repository methods explicitly declared for exposure

Referenced from: commits 30debcc

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jul 26, 2018

Oliver Drotbohm commented

I have to apologize. The enum value is a left-over of a contribution to solve DATAREST-1176 which we decided to only partially use. That enum value should never have made it into the codebase in the first place. RepositoryDetectionStrategy is about which repositories are about to be exposed in the first place, not about which methods are exposed.

The good news is that the actual implementation of DATAREST-1176 has what you're looking for. You can simply call RepositoryRestConfiguration.disableDefaultExposure(). This is a shortcut for both RepositoryDetectionStrategies.ANNOTATED plus the flag to require @RestResource on the repository methods to be exposed.

Does that help?

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Jul 27, 2018

Dario Seidl commented

Yes, thank you! RepositoryRestConfiguration.disableDefaultExposure() is just what we needed

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Aug 6, 2018

Oliver Drotbohm commented

That's fixed now by deprecating the left-over annotation value. master (i.e. Lovelace) doesn't even have it in any of the releases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants