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

JCL-234: Sample Spring Boot web app by bncummings · Pull Request #324 · inrupt/solid-client-java · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
72c4ec2
added pod integration with oidc
Feb 23, 2023
d66abdc
refactore with solid sync client
Feb 28, 2023
ac828ae
progress on jena use
Mar 2, 2023
d3f6d10
some style changes
Mar 2, 2023
cea447f
added low level pod writing
Mar 6, 2023
caaff3b
removed config information
Mar 6, 2023
75fe1fd
added pod integration with oidc
Feb 23, 2023
042c44e
refactore with solid sync client
Feb 28, 2023
004ce69
progress on jena use
Mar 2, 2023
da22d42
some style changes
Mar 2, 2023
0418870
added low level pod writing
Mar 6, 2023
296318d
removed config information
Mar 6, 2023
c9e3ebe
Minor adjustments
acoburn Mar 6, 2023
05b014f
Merge branch 'JCL-234-initialise-spring-boot-web-app' of https://gith…
timea-solid Mar 10, 2023
7d17376
Merge branch 'main' into JCL-234-initialise-spring-boot-web-app
timea-solid Mar 10, 2023
af115b6
correct test client id
timea-solid Mar 10, 2023
08c73a1
fixing merges
timea-solid Mar 10, 2023
4f4a63f
added pod integration with oidc
Feb 23, 2023
886b90c
refactore with solid sync client
Feb 28, 2023
db9178c
progress on jena use
Mar 2, 2023
d350515
some style changes
Mar 2, 2023
07fd895
added low level pod writing
Mar 6, 2023
2b74b72
removed config information
Mar 6, 2023
9a6a43a
Minor adjustments
acoburn Mar 6, 2023
f88a7dd
added post mapping
Mar 10, 2023
5400151
Merge branch 'JCL-234-initialise-spring-boot-web-app' of https://gith…
timea-solid Mar 10, 2023
f363696
Adjustment
acoburn Mar 10, 2023
564f14c
Make Spring application a runnable JAR, adjust client_id
acoburn Mar 10, 2023
0dff85a
Merge branch 'main' into JCL-234-initialise-spring-boot-web-app
timea-solid Mar 14, 2023
52ce44c
Merge branch 'main' into JCL-234-initialise-spring-boot-web-app
timea-solid Mar 14, 2023
933755f
first version of Digital Book Library
timea-solid Mar 16, 2023
a963c4e
Merge branch 'JCL-234-initialise-spring-boot-web-app' of https://gith…
timea-solid Mar 16, 2023
71b3e84
removing example modules
timea-solid Mar 16, 2023
15e7132
implemented feedback
timea-solid Mar 17, 2023
f5f033d
changed clientid doc ref
Mar 17, 2023
6fe6742
Update json-smart transitive dependency
acoburn Mar 17, 2023
3ea59eb
Merge branch 'main' into JCL-234-initialise-spring-boot-web-app
timea-solid Mar 17, 2023
File filter

Filter by extension

Filter by extension .css  (1) .html  (1) .java  (7) .md  (1) .svg  (1) .xml  (5) .yml  (1) All 7 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
8 changes: 8 additions & 0 deletions examples/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@

<build>
<plugins>
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>${owasp.plugin.version}</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
Comment on lines +19 to +26

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Is this really intentionally here, committed in source?
Or is it just so you can get on with your dev?

If latter, I can show you nicer (not polluting source) ways of being in control of what you run when using Maven profiles.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is intentional. The examples are not released and are intended only to be example code for developers. As such, Spring and Quarkus both bring in many, many transitive dependencies. In the case of Spring, we are currently stuck on spring boot 2.x because 3.x requires Java 17. And the dependency check becomes just a distraction without providing any value. Of course, it is turned on everywhere else: this configuration only applies to the examples directory.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
Expand Down
102 changes: 102 additions & 0 deletions examples/springboot/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Digital Book Library on a Pod

You are building the next-generation digital book library based on Solid. You can think about some similar services such as Goodreads and Audible personalized to your experience. To start you must implement a prototype first, a command-line interface application that only works for your user.

## How to get the example to run

The example web application expects as of now a `{podStorage}` link. Make sure you replace it in the `Vocabulary.java`.
Make sure you have a book library resource in the location `{podStorage}/MyBookLibrary/bookLibResource.ttl`. See example below at The book model section.

## The following user stories (US) will help:

* US1: As a digital book library owner I want to see all the publicly available books I have in my Digital Book Library.
* US2: As a digital book library owner I want to see all the books which have a specified title.


## Vocabulary

```
@prefix vocabulary: <{podStorage}/MyBookLibrary/bookLibraryVocabulary#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

###
# Ontology metadata
###

<{podStorage}/MyBookLibrary/bookLibraryVocabulary.ttl> a owl:Ontology .

###
# Ontology classes
###

vocabulary:BookLibrary a owl:Class;
rdfs:label "Book Library" .

vocabulary:Book a owl:Class;
rdfs:label "Book" .

###
# Ontology relations
###

vocabulary:containsBook a owl:DatatypeProperty;
rdfs:label "contains book"@en;
rdfs:domain vocabulary:BookLibrary;
rdfs:range vocabulary:Book .

###
# Ontology attributes which are also relationships but range is rdfs:Resource or others.
###

vocabulary:author a owl:DatatypeProperty;
rdfs:label "book author"@en;
rdfs:domain vocabulary:Book;
rdfs:range xsd:string .

vocabulary:description a owl:DatatypeProperty;
rdfs:label "book description"@en;
rdfs:domain vocabulary:Book;
rdfs:range xsd:string .

```


## Data Model

`podStorage` is the root of a user's storage. We choose to write the Book Library data on the storage in a container called `bookLibrary`. Together the form the base for where the data is stored on a user's storage: `podStorage/bookLibrary`.
Data model design choice: by the Book being part of the BookLibrary resource directly we express implicitly that the Book is part of only this library. For integration into other libraries one can add the Book triples into the new BookLibrary resource or consider a vocabulary with a dedicated relation (ex: contains book) and dedicated resources per Book.

### The Book model

```
@prefix book: <{podStorage}/MyBookLibrary/bookLibResource.ttl#> .
@prefix vocabulary: <{podStorage}/MyBookLibrary/bookLibraryVocabulary#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<{podStorage}/MyBookLibrary/bookLibResource.ttl> a vocabulary:BookLibrary ;
vocabulary:containsBook book:uuid1;
vocabulary:containsBook book:uuid2;
vocabulary:containsBook book:uuid3;
vocabulary:containsBook book:uuid4.

book:uuid1 a vocabulary:Book ;
dc:title "Dracula" ;
vocabulary:author "Bram Stoker" .

book:uuid2 a vocabulary:Book;
dc:title "Little Women" ;
vocabulary:author "May Alcott" .

book:uuid3 a vocabulary:Book;
dc:title "The graveyard book" ;
vocabulary:author "Neil Gaiman" .

book:uuid4 a vocabulary:Book;
dc:title "The alchemist" ;
vocabulary:author "Paulo Coelho" .


```
105 changes: 105 additions & 0 deletions examples/springboot/pom.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.inrupt</groupId>
<artifactId>inrupt-client-examples-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>inrupt-client-examples-springboot</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Inrupt Java Client Libraries - Spring Boot Example</name>
<description>
Sample Spring Boot application.
</description>

<properties>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>

<springboot.version>3.0.4</springboot.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${springboot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.inrupt</groupId>
<artifactId>inrupt-client-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.inrupt</groupId>
<artifactId>inrupt-client-jena</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.inrupt</groupId>
<artifactId>inrupt-client-okhttp</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.inrupt</groupId>
<artifactId>inrupt-client-jackson</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.inrupt</groupId>
<artifactId>inrupt-client-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.inrupt</groupId>
<artifactId>inrupt-client-solid</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.inrupt</groupId>
<artifactId>inrupt-client-vocabulary</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- for development use, such as restart app when any changes -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<!-- for building a jar -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2023 Inrupt Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.inrupt.client.examples.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SuppressWarnings({"PMD", "checkstyle:hideutilityclassconstructor"})
@SpringBootApplication
public class Application {

public static void main(final String[] args) {
SpringApplication.run(Application.class, args);
}
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2023 Inrupt Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.inrupt.client.examples.springboot;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class ApplicationStartController {

@GetMapping("/")
public String index() {
return "index";
}

@GetMapping("/login")
public String login(@RequestParam(name = "message", required = false, defaultValue = "Under construction")
final String message, final Model model) {
model.addAttribute("message", message);
return "index";
}

}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2023 Inrupt Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.inrupt.client.examples.springboot;

import com.inrupt.client.examples.springboot.model.Book;

import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class BookLibraryController {

@Autowired
private BookLibraryService bookLibService;

@GetMapping("/allbooks")
public String books(final Model model ) {
model.addAttribute("allBooks", bookLibService.getAllBooks());
return "index";
}

@GetMapping("/bookbytitle")
public String bookbytitle(@RequestParam(value = "title", defaultValue = "Dracula")
final String title, final Model model) {
final Set<Book> result = bookLibService.getBookForTitle(title);
if (!result.isEmpty()) {
model.addAttribute("booksByTitle", result);
} else {
model.addAttribute("error", "Did not find the book");
}
return "index";
}
}
Loading

Back | FazBrowse Home | New Git URL