|
|
|
# This is a preliminary tutorial set up a Connected Service to the Sharing Platform
|
|
|
|
|
|
|
|
(Based on Connector-Interface v0.1.2)
|
|
|
|
(Based on Connector-Interface v1.2.1)
|
|
|
|
|
|
|
|
You can download a simple sample implementation of a connected service at https://sharing-codeability.uibk.ac.at/development/sharing/sharing-plugin-demo.
|
|
|
|
|
| ... | ... | @@ -8,14 +8,14 @@ Disclaimer: This is not yet a fully blown tutorial. It only shows the major step |
|
|
|
|
|
|
|
## 0. SetUp Test Environment
|
|
|
|
|
|
|
|
To make your connected service testable, you should ask for an integration in the test sharing plattform at https://dev-exchange.codeability-austria.uibk.ac.at/.
|
|
|
|
To configure your tests, you must make your configuration Rest service publicly available under an URL that is reachable from the sharing plattform. The ```actionTransferURL``` can be an internal URL valid in your local browser.
|
|
|
|
To make your connected service testable, you should ask for an integration in the test sharing plattform at https://dev-exchange.codeability-austria.uibk.ac.at/. To configure your tests, you must make your configuration Rest service publicly available under an URL that is reachable from the sharing plattform. The `actionTransferURL` can be an internal URL valid in your local browser.
|
|
|
|
|
|
|
|
Alternatively, you can install a local version of the sharing plattform. The developer team can provide you with further information how to share the access to the test infrastructure of the gitlab and elasticsearch index via ssh tunnels.
|
|
|
|
|
|
|
|
## 1. Dependency
|
|
|
|
|
|
|
|
For maven include
|
|
|
|
|
|
|
|
```xml
|
|
|
|
<dependency>
|
|
|
|
<groupId>org.codeability.sharing</groupId>
|
| ... | ... | @@ -23,7 +23,9 @@ For maven include |
|
|
|
<version>0.1.2</version>
|
|
|
|
</dependency>
|
|
|
|
```
|
|
|
|
|
|
|
|
from repository
|
|
|
|
|
|
|
|
```xml
|
|
|
|
<repository>
|
|
|
|
<id>codabilitySharingAPIRepository</id>
|
| ... | ... | @@ -31,23 +33,25 @@ from repository |
|
|
|
<url>https://sharing-codeability.uibk.ac.at/development/sharing/codeabilitysharingpluginapi/-/raw/master/target/</url>
|
|
|
|
</repository>
|
|
|
|
```
|
|
|
|
|
|
|
|
## 2. Provide public Config Service
|
|
|
|
|
|
|
|
See classes SharingSupportResource and SharingSupportResource
|
|
|
|
|
|
|
|
This provides a config Rest service at
|
|
|
|
http://localhost:8080/api/sharingPluginConfig
|
|
|
|
This provides a config Rest service at [http://localhost:8080/api/sharingPluginConfig](http://localhost:8080/api/sharingPluginConfig)
|
|
|
|
|
|
|
|
In the Demo-Example we define a rest service
|
|
|
|
|
|
|
|
```java
|
|
|
|
@GetMapping("/sharingPluginConfig")
|
|
|
|
public ResponseEntity<SharingPluginConfig> getConfig(@RequestHeader("Authorization") String bearer,
|
|
|
|
@RequestParam String apiBaseUrl, @RequestParam String installationName) {
|
|
|
|
```
|
|
|
|
|
|
|
|
This service takes two request parameters `apiBaseUrl` and `installationName`. Additional it takes as further parameter the `Authorization`-header. The header value typically has the form `Bearer <<access key>>, and must be checked accordingly.
|
|
|
|
This service takes two request parameters `apiBaseUrl` and `installationName`. Additional it takes as further parameter the `Authorization`-header. The header value typically has the form \`Bearer \<\>, and must be checked accordingly.
|
|
|
|
|
|
|
|
Ensure that this service is accessible from everywhere (or at least from the sharing platform). For our spring boot aplication, we have to exempt this service from spring security by
|
|
|
|
|
|
|
|
Ensure that this service is accessible from everywhere (or at least from the sharing platform).
|
|
|
|
For our spring boot aplication, we have to exempt this service from spring security by
|
|
|
|
```java
|
|
|
|
web.ignoring()
|
|
|
|
...
|
| ... | ... | @@ -55,6 +59,7 @@ For our spring boot aplication, we have to exempt this service from spring secur |
|
|
|
```
|
|
|
|
|
|
|
|
The returned configuration is something like
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"version" : "0.1",
|
| ... | ... | @@ -74,10 +79,12 @@ The returned configuration is something like |
|
|
|
```
|
|
|
|
|
|
|
|
The demo plugin provides two actions
|
|
|
|
|
|
|
|
- one action for collections
|
|
|
|
- another action for programming exercises
|
|
|
|
|
|
|
|
Together with the request for the connector configuration the sharing platform also transfers two parameters for further info:
|
|
|
|
|
|
|
|
- apiBaseUrl: the base url for the call backs to the sharing plattform (e.g. ´https://sharing.codeability-austria.uibk.ac.at/api´)
|
|
|
|
- installationName: an informative name for the current installation (e.g. `sharing plattform (prod)`
|
|
|
|
|
| ... | ... | @@ -90,14 +97,15 @@ The Landing Page is invoked as e.g. http://localhost:8080/sharingPluginLandingPa |
|
|
|
Implement a landing page, that can analyze the URL and extract the relevant Parameters for the basket token (e.g. 67b1f6b5-610d-4e65-a161-ab24f478ad01) and the url parameters apiBaseURL and returnURL respectively.
|
|
|
|
|
|
|
|
An implementation example based on Angluar can be found in the plugin demo in [app-routing.module.ts](https://sharing-codeability.uibk.ac.at/development/sharing/sharing-plugin-demo/-/blob/master/src/main/webapp/app/app-routing.module.ts)
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
// ===== Sharing Import/Export =====
|
|
|
|
{
|
|
|
|
path: 'sharingPluginLandingPage/:basketToken',
|
|
|
|
loadChildren: () => import('./sharing/sharing.module' ).then((m) => m.SharingModule),
|
|
|
|
},
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
and [sharing.component.ts](https://sharing-codeability.uibk.ac.at/development/sharing/sharing-plugin-demo/-/blob/master/src/main/webapp/app/sharing/sharing.component.ts)
|
|
|
|
|
|
|
|
```typescript
|
| ... | ... | @@ -149,5 +157,4 @@ Based on this service you can now implement your own functionality. |
|
|
|
|
|
|
|
## 5. Use the search functionality
|
|
|
|
|
|
|
|
You can also invoke the search functionality of the sharing plattform.
|
|
|
|
Find an example implementation in the demo, and further info in the [documentation](technical/Connector-Interface) |
|
|
|
You can also invoke the search functionality of the sharing plattform. Find an example implementation in the demo, and further info in the [documentation](technical/Connector-Interface) |
|
|
\ No newline at end of file |