FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

JCL-162: installation documentation (#256) · inrupt/solid-client-java@55c1648 · GitHub

Repository navigation

Commit 55c1648

Browse files
andauthored
JCL-162: installation documentation (#256)
* installation documentation on dedicated page * fixed formating and split getting started in an own menu item * added missing site of solid module * fixed missing information on the apidoc list Co-authored-by: Aaron Coburn <aaronc@inrupt.com>
1 parent 962cf0d commit 55c1648

9 files changed

Lines changed: 281 additions & 167 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2023 Inrupt Inc.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal in
6+
* the Software without restriction, including without limitation the rights to use,
7+
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
8+
* Software, and to permit persons to whom the Software is furnished to do so,
9+
* subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16+
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
/**
22+
* <h2>Sample CLI application.</h2>
23+
*/
24+
package com.inrupt.client.examples.cli;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2023 Inrupt Inc.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal in
6+
* the Software without restriction, including without limitation the rights to use,
7+
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
8+
* Software, and to permit persons to whom the Software is furnished to do so,
9+
* subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16+
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
/**
22+
* <h2>Sample web application.</h2>
23+
*/
24+
package com.inrupt.client.examples.webapp;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#banner img {
2+
width: 200px;
3+
}
4+
5+
table.bodyTable tr.a {
6+
background-color: #ddd;
7+
}
8+
9+
table.bodyTable tr.b {
10+
background-color: #eee;
11+
}
12+
13+
div.sidebar-nav {
14+
display: none;
15+
}
16+
17+
a.externalLink,
18+
a.externalLink[href^=http],
19+
a.externalLink[href^=https] {
20+
background: none;
21+
padding-right: 0px;
22+
}
Lines changed: 1 addition & 0 deletions
LoadingViewer requires iframe.

‎solid/src/site/site.xml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<project name="Inrupt Client Libraries: RDF4J">
2+
3+
<bannerRight>
4+
<name>Inrupt</name>
5+
<src>images/inrupt_logo-2020.svg</src>
6+
<href>https://inrupt.com</href>
7+
</bannerRight>
8+
9+
<body>
10+
<menu name="Module: Solid" inherit="top">
11+
<item name="Summary" href="summary.html"/>
12+
<item name="Dependencies" href="dependencies.html"/>
13+
<item name="Plugins" href="plugins.html"/>
14+
</menu>
15+
</body>
16+
</project>

‎src/site/apt/gettingStarted.apt.vm‎

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
Getting Started
2+
3+
An app developer will first need to consider how a user creates an authenticated session. Depending on the application framework in use, there may already be
4+
a valid OpenID Id Token. Alternatively, a developer may possess a set of client credentials. Both approaches are described below. In both cases, a client object
5+
will be needed:
6+
7+
----------------------
8+
var CLIENT = SolidClient.getClient();
9+
----------------------
10+
11+
* Using an existing ID Token
12+
13+
All interactions with Solid resources happen in the context of a <<<Session>>>. If an existing Id Token is available, the <<<Session>>> can use that value. In this
14+
case, it will be the responsibility of the application framework to refresh the Id Token upon expiration.
15+
16+
----------------------
17+
var session = OpenIdSession.ofIdToken(idToken);
18+
var client = CLIENT.session(session);
19+
----------------------
20+
21+
* Using OAuth2 Client Credentials
22+
23+
Using <<<client_credentials>>>, an app developer can create a session that automatically refreshes upon token expiration.
24+
25+
----------------------
26+
var session = OpenIdSession.ofClientCredentials(issuer, clientId, clientSecret, authMethod);
27+
var client = CLIENT.session(session);
28+
----------------------
29+
30+
With this <<<session>>> object, one can perform normal CRUD operations on Solid resources.
31+
Please note that, with <<<SolidClient>>>, all operations are asynchronous. For synchronous operations, use <<<SolidSyncClient>>>.
32+
33+
----------------------
34+
var playlist = client.read(uri, Playlist.class);
35+
36+
playlist.thenAccept(p -> {
37+
displayTitle(p.getTitle());
38+
displaySongs(p.getSongs());
39+
}).toCompletableFuture().join();
40+
----------------------
41+
42+
One may also create new resources.
43+
44+
----------------------
45+
var playlist = new Playlist(uri);
46+
playlist.setTitle("Jazz Collection");
47+
playlist.addSong(song1);
48+
playlist.addSong(song2);
49+
50+
client.create(playlist).toCompletableFuture().join();
51+
-----------------------
52+
53+
Or update existing resources.
54+
55+
-----------------------
56+
var playlist = client.read(uri, Playlist.class);
57+
58+
playlist.thenCompose(p -> {
59+
p.setTitle("Bossa Nova");
60+
p.removeSong(song1);
61+
p.addSong(song3);
62+
return client.update(p);
63+
}).toCompletableFuture().join();
64+
-----------------------
65+
66+
Or delete resources.
67+
68+
-----------------------
69+
client.delete(uri).toCompletableFuture().join();
70+
-----------------------
71+
72+
One can use the provided Solid classes to list resources across a user's storage locations.
73+
74+
-----------------------
75+
session.getPrincipal().ifPresent(webid ->
76+
client.send(Request.newBuilder(webid).header("Accept", "text/turtle").build(),
77+
WebIdBodyHandlers.ofWebIdProfile(webid))
78+
.thenApply(Response::body)
79+
.thenAccept(profile ->
80+
profile.getStorage().stream().forEach(storage -> {
81+
LOGGER.info("Storage: {}", storage);
82+
client.read(storage, SolidContainer.class).thenAccept(s ->
83+
s.getContainedResources().forEach(r ->
84+
LOGGER.info("Resource: {}", r.getIdentifier())))))
85+
.toCompletableFuture().join());
86+
-----------------------
87+
88+
* Example applications
89+
90+
** A sample Web Application
91+
92+
The {{{https://inrupt.github.io/solid-client-java/apidocs/com/inrupt/client/examples/webapp/package-summary.html}web app example}} is a Quarkus application implementing a similar pattern to look up a user's WebID profile and then display the contents of a user's storage.
93+
94+
To set up the example application the following configuration values need to be added for this to work properly:
95+
96+
---------------------
97+
quarkus.oidc.auth-server-url=<URL of Solid-OIDC server>
98+
quarkus.oidc.client-id=<URL of Client Identifier>
99+
---------------------
100+
101+
Remark: <<<client-id>>> is a {{{https://solidproject.org/TR/oidc#clientids-document}Client ID Document}}.
102+
103+
The above configuration values are typically added to a <<<./config/application.properties>>> file in the directory where the application is run.
104+
105+
To build the application, use this command:
106+
107+
---------------------
108+
$ ./mvnw package
109+
---------------------
110+
111+
To run the application, use this command:
112+
113+
---------------------
114+
$ java -jar examples/webapp/target/quarkus-app/quarkus-run.jar
115+
---------------------
116+
117+
The application will be available at <<<http://localhost:8080>>>.
118+
119+
** A sample CLI Application
120+
121+
The {{{https://inrupt.github.io/solid-client-java/apidocs/com/inrupt/client/examples/webapp/package-summary.html}cli app example}} is a CLI utility application interacting with a Solid Storage. It is making use of OAuth2 Client Credentials to access the Pod Storage.

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL