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

#30 RepositoryFilter to allow metrics collection #194

Merged
merged 2 commits into from
Nov 5, 2016
Merged

Conversation

remmeier
Copy link
Contributor

@remmeier remmeier commented Nov 5, 2016

new RepositoryFilter interface introduced that sits in the repository layer and allows to intercept request, respones and links/meta information gathering.

  • repository adapters modified to invoke filters
  • filters get a chain class to decide whether to proceed with the request or return a result on its own.
  • RepositoryRequestSpec to specify the contents of a request
  • existing Filter interface should be renamed to make clear that they operate on a different layer (transport vs repository).
  • Module api extended to allow RepositoryFilter registration
  • minor refactoring to ResourceRegistry/ModuleRegistry dependency to allow access to RepositoryFilter

use cases:

  • metrics
  • tracing
  • security
  • ...

new RepositoryFilter interface introduced that sits in the repository
layer and allows to intercept request, respones and links/meta
information gathering.

- repository adapters modified to invoke filters
- filters get a chain class to decide whether to proceed with the
request or return a result on its own.
- RepositoryRequestSpec to specify the contents of a request
- existing Filter interface should be renamed to make clear that they
operate on a different layer (transport vs repository).
- Module api extended to allow RepositoryFilter registration
- minor refactoring to ResourceRegistry/ModuleRegistry dependency to
allow access to RepositoryFilter
@coveralls
Copy link

Coverage Status

Coverage increased (+0.6%) to 90.296% when pulling cb795a2 on repofilter into 3d81ef2 on develop.

- unused imports
- fixed a invalid package name (for non-public one)
}

@SuppressWarnings({ "unchecked", "rawtypes" })
private LinksInformation doGetLinksInformation(Object repository, Iterable<?> resources, RepositoryRequestSpec requestSpec) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR Move this method into "RepositoryLinksFilterChainImpl". rule

}

@SuppressWarnings({ "unchecked", "rawtypes" })
private MetaInformation doGetMetaInformation(Object repository, Iterable<?> resources, RepositoryRequestSpec requestSpec) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR Move this method into "RepositoryMetaFilterChainImpl". rule


import io.katharsis.module.ModuleRegistry;
import io.katharsis.queryParams.QueryParams;
import io.katharsis.queryspec.DefaultQuerySpecConverter;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR Remove this unused import 'io.katharsis.queryspec.DefaultQuerySpecConverter'. rule

}
}

private <T> String toUrl(QueryAdapter queryAdapter, PagedResultList<T> pagedResultList, RepositoryRequestSpec requestSpec) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Remove this unused method parameter "pagedResultList". rule

import io.katharsis.module.ModuleRegistry;
import io.katharsis.queryParams.QueryParams;
import io.katharsis.queryspec.DefaultQuerySpecConverter;
import io.katharsis.queryspec.QuerySpec;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR Remove this unused import 'io.katharsis.queryspec.QuerySpec'. rule

}

private <S extends T> JsonApiResponse save(S entity, QueryAdapter queryAdapter, HttpMethod method) {
RepositoryRequestFilterChainImpl chain = new RepositoryRequestFilterChainImpl() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Reduce this anonymous class number of lines from 22 to at most 20, or make it a named class. rule

}

public JsonApiResponse findOne(I id, QueryAdapter queryAdapter) {
RepositoryRequestFilterChainImpl chain = new RepositoryRequestFilterChainImpl() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Reduce this anonymous class number of lines from 23 to at most 20, or make it a named class. rule

}

public JsonApiResponse findAll(Iterable ids, QueryAdapter queryAdapter) {
RepositoryRequestFilterChainImpl chain = new RepositoryRequestFilterChainImpl() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Reduce this anonymous class number of lines from 23 to at most 20, or make it a named class. rule

}

public JsonApiResponse findAll(QueryAdapter queryAdapter) {
RepositoryRequestFilterChainImpl chain = new RepositoryRequestFilterChainImpl() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Reduce this anonymous class number of lines from 22 to at most 20, or make it a named class. rule


@SuppressWarnings("rawtypes")
public JsonApiResponse findOneTarget(I sourceId, String fieldName, QueryAdapter queryAdapter) {
RepositoryRequestFilterChainImpl chain = new RepositoryRequestFilterChainImpl() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Reduce this anonymous class number of lines from 24 to at most 20, or make it a named class. rule

.findOneTarget(sourceId, fieldName, request.getQueryParams());
}
return getResponse(relationshipRepository, resource, request);
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR Remove this empty statement. rule


@SuppressWarnings("rawtypes")
public JsonApiResponse findManyTargets(I sourceId, String fieldName, QueryAdapter queryAdapter) {
RepositoryRequestFilterChainImpl chain = new RepositoryRequestFilterChainImpl() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Reduce this anonymous class number of lines from 24 to at most 20, or make it a named class. rule

@sonarqube-reporter
Copy link
Collaborator

SonarQube analysis reported 12 issues

  • MAJOR 7 major
  • MINOR 5 minor

Watch the comments in this conversation to review them.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.6%) to 90.276% when pulling edf7a80 on repofilter into 3d81ef2 on develop.

@remmeier remmeier merged commit 5a3bc14 into develop Nov 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants