-
Notifications
You must be signed in to change notification settings - Fork 215
/
WotThingModelFetcher.java
70 lines (64 loc) · 3.02 KB
/
WotThingModelFetcher.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.wot.integration.provider;
import java.net.URL;
import java.util.concurrent.CompletionStage;
import org.apache.pekko.actor.ActorSystem;
import org.eclipse.ditto.base.model.headers.DittoHeaders;
import org.eclipse.ditto.wot.integration.config.WotConfig;
import org.eclipse.ditto.wot.model.IRI;
import org.eclipse.ditto.wot.model.ThingModel;
/**
* Fetches WoT (Web of Things) ThingModels from {@code IRI}s/{@code URL}s, optionally caching those
* (as part of the implementation strategy).
*
* @since 2.4.0
*/
public interface WotThingModelFetcher {
/**
* Fetches the ThingModel resource at the passed {@code iri}.
*
* @param iri the IRI (URL) from which to fetch the ThingModel.
* @param dittoHeaders the DittoHeaders for possibly thrown DittoRuntimeExceptions.
* @return a CompletionStage containing the fetched ThingModel or completed exceptionally with a
* {@link org.eclipse.ditto.wot.model.WotThingModelInvalidException} if the fetched ThingModel could not be
* parsed/interpreted as correct WoT ThingModel.
* @throws org.eclipse.ditto.wot.model.ThingDefinitionInvalidException if the passed {@code iri} did not contain a
* valid URL.
* @throws org.eclipse.ditto.wot.model.WotThingModelNotAccessibleException if the ThingModel could not be
* fetched at the given {@code iri}.
*/
CompletionStage<ThingModel> fetchThingModel(IRI iri, DittoHeaders dittoHeaders);
/**
* Fetches the ThingModel resource at the passed {@code iurlri}.
*
* @param url the URL from which to fetch the ThingModel.
* @param dittoHeaders the DittoHeaders for possibly thrown DittoRuntimeExceptions.
* @return a CompletionStage containing the fetched ThingModel or completed exceptionally with a
* {@link org.eclipse.ditto.wot.model.WotThingModelInvalidException} if the fetched ThingModel could not be
* parsed/interpreted as correct WoT ThingModel.
* @throws org.eclipse.ditto.wot.model.WotThingModelNotAccessibleException if the ThingModel could not be
* fetched at the given {@code url}.
*/
CompletionStage<ThingModel> fetchThingModel(URL url, DittoHeaders dittoHeaders);
/**
* Creates a new instance of WotThingModelExtensionResolver with the given {@code actorSystem}.
*
* @param actorSystem the actor system to use.
* @param wotConfig the WoTConfig to use for creating the generator.
* @return the created WotThingSkeletonGenerator.
*/
static WotThingModelFetcher of(final ActorSystem actorSystem, final WotConfig wotConfig) {
return new DefaultWotThingModelFetcher(actorSystem, wotConfig);
}
}