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

Feature/conditional headers #226

Merged

Conversation

Yannic92
Copy link
Contributor

@Yannic92 Yannic92 commented Sep 5, 2018

This PR adds support for the following precondition headers:

  • If-Match
  • If-None-Match

For things and policies including all their subresources.
When requesting those resources there will now be an ETag-Header in the response.

danielFesenmeyer and others added 30 commits September 5, 2018 13:13
…o DittoHeaderDefinition

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
- add interface CustomApiRoutesProvider (with default implementation NoopCustomApiRoutesProvider) and inject/use it in RootRoute
- add interface CustomHeadersHandler (with default implementation NoopCustomHeadersHandler) and inject/use it in RootRoute
- extract interface GatewayAuthenticationDirectiveBuilder (with default implementation DittoGatewayAuthenticationDirectiveBuilder) and inject/use it in RootRoute
- several improvements
-- use StatusRoute for providing the gateway's own status
-- support Ditto Protocol "compatibility mode" for old "ThingsClients"
-- allow custom-headers not only on MessageRoute, but for all ditto routes -> move the usage of HeaderTranslator from MessageRoute to RootRoute

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
…ditional-headers

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
…ditional-headers

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
…e missing

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
* Adds an ETagValueGenerator to generate the value of the ETag header for
  the entities carried by the command.
* Adds a new abstract base class that adds this value as ETag header to
  thing commands (policy commands will follow)
* Extracts two new base classes Entity and Revision

Signed-off-by: Klem Yannic (INST/ECS1) <Yannic.Klem@bosch-si.com>
Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
…le for all websocket-messages

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
…y have been moved to Entity/Revision, according to semantic versioning nothing has changed

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
…-plugin (binary-compatibility-check) to parent pom

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
Signed-off-by: Klem Yannic (INST/ECS1) <Yannic.Klem@bosch-si.com>
Signed-off-by: Klem Yannic (INST/ECS1) <Yannic.Klem@bosch-si.com>
Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
…l-headers by using a mock-entity instead of concrete Thing- and Policy-Entity

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
* This is already specified by AllParametersAndReturnValuesAreNonnullByDefault

Signed-off-by: Klem Yannic (INST/ECS1) <Yannic.Klem@bosch-si.com>
Signed-off-by: Klem Yannic (INST/ECS1) <Yannic.Klem@bosch-si.com>
Signed-off-by: Klem Yannic (INST/ECS1) <Yannic.Klem@bosch-si.com>
* Adds unit tests for known headers

Signed-off-by: Klem Yannic (INST/ECS1) <Yannic.Klem@bosch-si.com>
* GatewayAuthenticationDirectiveBuilder is now GatewayAuthenticationDirectiveFactory

Signed-off-by: Klem Yannic (INST/ECS1) <Yannic.Klem@bosch-si.com>
…endingReceiveStrategy

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
…sed on the existing data instead of the command

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
…ementations; don't generate an ETag if an entity is deleted

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
… analysis (e.g. in unit tests)

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
- add assertion helper methods in AbstractCommandStrategyTest which check whether the CommandStrategy.Result is correctly executed
- adjust the (Thing)CommandStrategy-Unit-Tests to use these helper methods
- simplify CommandStrategy.Result interface

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
…tend (and thus reuse) AbstractConditionalHeadersCheckingCommandStrategy

- make CreateThingStrategy a singleton
- reference it in ThingPersistenceActor
- move becomeDeleteRunnable to CommandStrategy.Context, add another property becomeCreatedRunnable which is used to switch to the created-state from CreateThingStrategy
- caveat: the modified-date in the response is not exact, but this is not critical atm

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
…Tag always based on the existing data instead of the command

- move AbstractETagAppendingReceiveStrategy to PolicyPersistenceActor, rename it to AbstractConditionalHeadersCheckingReceiveStrategy
- make AbstractConditionalHeadersCheckingReceiveStrategy extend WithIdReceiveStrategy instead the other way round (because WithIdReceiveStrategy is the more general abstraction)
- rename method AbstractConditionalHeadersCheckingReceiveStrategy#determineETagValue() to #determineETagEntity() and just return the object to be used for ETag-calculation instead of already calculating the ETag (same as in Things-Service)
- introduce method AbstractConditionalHeadersCheckingReceiveStrategy#sendSuccessResponse() which allows to enrich successful responses with the ETag, use it where appropriate

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
Yannic92 and others added 21 commits September 5, 2018 13:32
* responses.notModified
* responses.preconditionFailed
* parameters.ifMatchHeaderParam
* parameters.ifNoneMatchHeaderParam

Signed-off-by: Klem Yannic (INST/ECS1) <Yannic.Klem@bosch-si.com>
* Using those headers for a post to /things doesn't make sense since
  if-none-match=* would always be successful and if-match=* would always
  result in 412.

Signed-off-by: Klem Yannic (INST/ECS1) <Yannic.Klem@bosch-si.com>
…ll "Thing" uppercase

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
…dersValidator in module utils-conditional-headers (to allow reuse for policies); move instantiation for the things-service to class ThingsConditionalHeadersValidatorProvider

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
…esources; reuse ConditionalHeadersValidator from module utils-conditional-headers

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
- document ETag
- conditional-headers If-Match and If-None-Match
- status codes 304 and 412

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
…logging in WebsocketRoute (by using this method)

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
…mand-string

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
…se ditto clients won't work as expected) - TODO: consider to add a third flag like "writeToResponses" to allow exclusion of certain headers in responses/events

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
…ment

Signed-off-by: Klem Yannic (INST/ECS1) <Yannic.Klem@bosch-si.com>
…xternal headers); this issue can be solved on client-side by using DittoProtocolAdapter with HeaderTranslator#empty()

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
…ails for a policy-command

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
* Duplicates the description now instead of referencing it.

Signed-off-by: Klem Yannic (INST/ECS1) <Yannic.Klem@bosch-si.com>
Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
@yufei-cai yufei-cai force-pushed the feature/conditional-headers branch 2 times, most recently from 03fa92a to cea26ec Compare September 5, 2018 11:37
Yannic92 and others added 3 commits September 6, 2018 10:07
…tions to make decisions based on it (TODO: CustomHeadersHandler should better be renamed to sth like RequestInterceptor)

Signed-off-by: Daniel Fesenmeyer <daniel.fesenmeyer@bosch-si.com>
@danielFesenmeyer
Copy link
Contributor

PR looks good. The commits have all already been reviewed.

@danielFesenmeyer danielFesenmeyer merged commit 97ca3d7 into eclipse-ditto:master Sep 6, 2018
@Yannic92 Yannic92 deleted the feature/conditional-headers branch September 7, 2018 07:37
@thjaeckle thjaeckle added this to the 0.8.0-M2 milestone Sep 11, 2018
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.

None yet

3 participants