common swagger

This commit is contained in:
Michele Artini 2023-11-21 11:11:06 +01:00
parent 0221245c47
commit 0ed679cd3c
38 changed files with 279 additions and 287 deletions

View File

@ -8,18 +8,14 @@ server {
server_name _;
location /ajax/ {
proxy_pass http://is-manager:$SPRING_BOOT_PORT/ajax/;
location /proxy/ {
proxy_pass http://is-manager:$SPRING_BOOT_PORT/proxy/;
}
location /ajax-is/ {
proxy_pass http://is-manager:$SPRING_BOOT_PORT/ajax-is/;
}
location /swagger/ {
proxy_pass http://is-manager:$SPRING_BOOT_PORT/swagger/;
}
location / {
proxy_pass http://angular-dev:4200/;
}

View File

@ -1,5 +1,4 @@
server.title = D-NET Context Manager
server.description = D-NET Context Manager
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-context-manager/effective-pom.xml

View File

@ -1,5 +1,4 @@
server.title = D-NET Datasource Manager
server.description = D-NET Datasource Manager
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-datasource-manager/effective-pom.xml

View File

@ -1,7 +1,6 @@
server.title = D-NET Mail Sender API
server.description = Simple service that sends mails
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-email-sender/effective-pom.xml
mail.smtpHost = localhost

View File

@ -1,6 +1,5 @@
server.title = D-NET Metadata Indexer (SOLR)
server.description = D-NET Metadata Indexer (SOLR)
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-index-manager/effective-pom.xml

View File

@ -21,20 +21,21 @@ import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
import eu.dnetlib.common.app.AbstractDnetApp;
import eu.dnetlib.is.service.ServiceRegistry;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@Controller
@RequestMapping("/ajax")
public class AjaxProxyController {
@RequestMapping("/proxy")
public class ServiceProxyController {
@Autowired
private ServiceRegistry registry;
private static final Log log = LogFactory.getLog(AjaxProxyController.class);
private static final Log log = LogFactory.getLog(ServiceProxyController.class);
@RequestMapping("/{service}/{*path}")
@RequestMapping("/ajax/{service}/{*path}")
public ResponseEntity<?> redirectAjaxCall(@PathVariable final String service,
@PathVariable final String path,
@RequestBody(required = false) final String body,
@ -75,4 +76,25 @@ public class AjaxProxyController {
}
}
@RequestMapping("/swagger-conf/{service}")
public ResponseEntity<?> swaggerServiceHome(@PathVariable final String service) {
try {
final String baseUrl = registry.findBaseUrl(service);
if (StringUtils.isBlank(baseUrl)) { return ResponseEntity.status(HttpStatus.NOT_FOUND).body("The required service is not registered: " + service); }
final RestTemplate restTemplate = new RestTemplate();
final String body = restTemplate.getForObject(baseUrl + "/v3/api-docs/" + AbstractDnetApp.SWAGGER_API_GROUP, String.class);
return ResponseEntity.status(HttpStatus.OK).body(body);
} catch (final HttpStatusCodeException e) {
return ResponseEntity.status(e.getStatusCode())
.headers(e.getResponseHeaders())
.body(e.getResponseBodyAsString());
}
}
}

View File

@ -1,50 +0,0 @@
package eu.dnetlib.is.controller;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.RestTemplate;
import eu.dnetlib.is.service.ServiceRegistry;
@Controller
@RequestMapping("/swagger")
public class SwaggerProxyController {
@Autowired
private ServiceRegistry registry;
private static final Log log = LogFactory.getLog(SwaggerProxyController.class);
@RequestMapping("/{service}/{file}")
public ResponseEntity<?> swaggerServiceHome(@PathVariable final String service, @PathVariable final String file) {
try {
final String baseUrl = registry.findBaseUrl(service);
if (StringUtils.isBlank(baseUrl)) { return ResponseEntity.status(HttpStatus.NOT_FOUND).body("The required service is not registered: " + service); }
final RestTemplate restTemplate = new RestTemplate();
final String body = restTemplate.getForObject(baseUrl + "/swagger-ui/" + URLEncoder.encode(file, StandardCharsets.UTF_8), String.class);
return ResponseEntity.status(HttpStatus.OK).body(body);
} catch (final HttpStatusCodeException e) {
return ResponseEntity.status(e.getStatusCode())
.headers(e.getResponseHeaders())
.body(e.getResponseBodyAsString());
}
}
}

View File

@ -1,6 +1,5 @@
server.title = D-NET Information Service
server.description = D-NET Information Service
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-is-manager/effective-pom.xml

View File

@ -1,6 +1,5 @@
server.title = D-NET MDSM
server.description = D-NET Metadata Store Manager
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-mdstore-manager/effective-pom.xml

View File

@ -1,6 +1,5 @@
server.title = D-NET OAI Exporter
server.description = D-NET Service for metadata export using OAI-PMH
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-oai-manager/effective-pom.xml

View File

@ -1,6 +1,5 @@
server.title = D-NET Resource Manager
server.description = D-NET Resource Manager
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-resource-manager/effective-pom.xml

View File

@ -1,5 +1,4 @@
server.title = D-NET Vocabulary Manager
server.description = D-NET Vocabulary Manager
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-vocabulary-manager/effective-pom.xml

View File

@ -1,6 +1,5 @@
server.title = D-NET Wf executor that uses postgres as backend
server.description = D-NET Wf executor that uses postgres as backend
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-wf-aggregation-postgres/effective-pom.xml

View File

@ -1,6 +1,5 @@
server.title = D-NET Workflow Manager
server.description = D-NET Workflow Manager
server.public_url =
maven.pom.path = /META-INF/maven/eu.dnetlib.docker/dnet-wf-manager/effective-pom.xml

View File

@ -1,102 +1,109 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"dnet-is-frontend": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/dnet-is-frontend",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": [
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.css"
],
"scripts": [
]
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "4mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "4kb",
"maximumError": "8kb"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "dnet-is-frontend:build:production"
},
"development": {
"browserTarget": "dnet-is-frontend:build:development",
"proxyConfig": "src/proxy.conf.json"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "dnet-is-frontend:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.css"
],
"scripts": []
}
}
}
}
}
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"dnet-is-frontend": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/dnet-is-frontend",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": [
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.css",
"node_modules/swagger-ui-dist/swagger-ui.css"
],
"scripts": [
"node_modules/swagger-ui-dist/swagger-ui-bundle.js",
"node_modules/swagger-ui-dist/swagger-ui-standalone-preset.js"
]
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "4mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "4kb",
"maximumError": "8kb"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "dnet-is-frontend:build:production"
},
"development": {
"browserTarget": "dnet-is-frontend:build:development",
"proxyConfig": "src/proxy.conf.json"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "dnet-is-frontend:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.css",
"node_modules/swagger-ui-dist/swagger-ui.css"
],
"scripts": [
"node_modules/swagger-ui-dist/swagger-ui-bundle.js",
"node_modules/swagger-ui-dist/swagger-ui-standalone-preset.js"
]
}
}
}
}
}
}

View File

@ -2,6 +2,7 @@ FROM node:18-alpine
WORKDIR '/app'
COPY package*.json .
RUN npm install
RUN npm install swagger-ui-dist --save
COPY . .
EXPOSE 4200
CMD ["npm", "start"]

View File

@ -19,6 +19,7 @@
"@angular/platform-browser-dynamic": "^15.1.0",
"@angular/router": "^15.1.0",
"rxjs": "~7.8.0",
"swagger-ui-dist": "^5.10.0",
"tslib": "^2.3.0",
"zone.js": "~0.12.0"
},
@ -670,12 +671,12 @@
"dev": true
},
"node_modules/@babel/code-frame": {
"version": "7.22.13",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz",
"integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.23.4.tgz",
"integrity": "sha512-r1IONyb6Ia+jYR2vvIDhdWdlTGhqbBoFqLTQidzZ4kepUFH15ejXvFHxCVbtl7BOXIudsIubf4E81xeA3h3IXA==",
"dev": true,
"dependencies": {
"@babel/highlight": "^7.22.13",
"@babel/highlight": "^7.23.4",
"chalk": "^2.4.2"
},
"engines": {
@ -1166,9 +1167,9 @@
}
},
"node_modules/@babel/helper-string-parser": {
"version": "7.22.5",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz",
"integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.23.4.tgz",
"integrity": "sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ==",
"dev": true,
"engines": {
"node": ">=6.9.0"
@ -1249,9 +1250,9 @@
}
},
"node_modules/@babel/highlight": {
"version": "7.22.20",
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.20.tgz",
"integrity": "sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.23.4.tgz",
"integrity": "sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A==",
"dev": true,
"dependencies": {
"@babel/helper-validator-identifier": "^7.22.20",
@ -1263,9 +1264,9 @@
}
},
"node_modules/@babel/parser": {
"version": "7.23.0",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz",
"integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.4.tgz",
"integrity": "sha512-vf3Xna6UEprW+7t6EtOmFpHNAuxw3xqPZghy+brsnusscJRW5BMUzzHZc5ICjULee81WeUV2jjakG09MDglJXQ==",
"dev": true,
"bin": {
"parser": "bin/babel-parser.js"
@ -2500,19 +2501,19 @@
}
},
"node_modules/@babel/traverse": {
"version": "7.23.0",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.0.tgz",
"integrity": "sha512-t/QaEvyIoIkwzpiZ7aoSKK8kObQYeF7T2v+dazAYCb8SXtp58zEVkWW7zAnju8FNKNdr4ScAOEDmMItbyOmEYw==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.4.tgz",
"integrity": "sha512-IYM8wSUwunWTB6tFC2dkKZhxbIjHoWemdK+3f8/wq8aKhbUscxD5MX72ubd90fxvFknaLPeGw5ycU84V1obHJg==",
"dev": true,
"dependencies": {
"@babel/code-frame": "^7.22.13",
"@babel/generator": "^7.23.0",
"@babel/code-frame": "^7.23.4",
"@babel/generator": "^7.23.4",
"@babel/helper-environment-visitor": "^7.22.20",
"@babel/helper-function-name": "^7.23.0",
"@babel/helper-hoist-variables": "^7.22.5",
"@babel/helper-split-export-declaration": "^7.22.6",
"@babel/parser": "^7.23.0",
"@babel/types": "^7.23.0",
"@babel/parser": "^7.23.4",
"@babel/types": "^7.23.4",
"debug": "^4.1.0",
"globals": "^11.1.0"
},
@ -2521,12 +2522,12 @@
}
},
"node_modules/@babel/traverse/node_modules/@babel/generator": {
"version": "7.23.0",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz",
"integrity": "sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.4.tgz",
"integrity": "sha512-esuS49Cga3HcThFNebGhlgsrVLkvhqvYDTzgjfFFlHJcIfLe5jFmRRfCQ1KuBfc4Jrtn3ndLgKWAKjBE+IraYQ==",
"dev": true,
"dependencies": {
"@babel/types": "^7.23.0",
"@babel/types": "^7.23.4",
"@jridgewell/gen-mapping": "^0.3.2",
"@jridgewell/trace-mapping": "^0.3.17",
"jsesc": "^2.5.1"
@ -2562,12 +2563,12 @@
}
},
"node_modules/@babel/types": {
"version": "7.23.0",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz",
"integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==",
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.4.tgz",
"integrity": "sha512-7uIFwVYpoplT5jp/kVv6EF93VaJ8H+Yn5IczYiaAi98ajzjfoZfslet/e0sLh+wVBjb2qqIut1b0S26VSafsSQ==",
"dev": true,
"dependencies": {
"@babel/helper-string-parser": "^7.22.5",
"@babel/helper-string-parser": "^7.23.4",
"@babel/helper-validator-identifier": "^7.22.20",
"to-fast-properties": "^2.0.0"
},
@ -11560,6 +11561,11 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/swagger-ui-dist": {
"version": "5.10.0",
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.10.0.tgz",
"integrity": "sha512-PBTn5qDOQVtU29hrx74km86SnK3/mFtF3grI98y575y1aRpxiuStRTIvsfXFudPFkLofHU7H9a+fKrP+Oayc3g=="
},
"node_modules/symbol-observable": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-4.0.0.tgz",

View File

@ -21,6 +21,7 @@
"@angular/platform-browser-dynamic": "^15.1.0",
"@angular/router": "^15.1.0",
"rxjs": "~7.8.0",
"swagger-ui-dist": "^5.10.0",
"tslib": "^2.3.0",
"zone.js": "~0.12.0"
},

View File

@ -13,6 +13,7 @@ import { EmailsComponent } from './emails/emails.component';
import { WfConfsComponent } from './wf-confs/wf-confs.component';
import { IndexComponent } from './index/index.component';
import { OaiComponent } from './oai/oai.component';
import { SwaggerUiComponent } from './swagger/swagger-ui.component';
const routes: Routes = [
@ -33,7 +34,8 @@ const routes: Routes = [
{ path: "mdrecords/:versionId/:limit", component: MdstoreInspectorComponent },
{ path: "cleaner", component: CleanerTesterComponent },
{ path: "index", component: IndexComponent },
{ path: "oai", component: OaiComponent }
{ path: "oai", component: OaiComponent },
{ path: "swagger-ui/:id", component: SwaggerUiComponent }
];
@NgModule({

View File

@ -43,6 +43,7 @@ import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatStepperModule } from '@angular/material/stepper';
import { IndexComponent } from './index/index.component';
import { OaiComponent } from './oai/oai.component';
import { SwaggerUiComponent } from './swagger/swagger-ui.component';
@NgModule({
declarations: [
@ -81,7 +82,8 @@ import { OaiComponent } from './oai/oai.component';
WfConfDialog,
WfConfSingle,
IndexComponent,
OaiComponent
OaiComponent,
SwaggerUiComponent
],
imports: [
BrowserModule,

View File

@ -10,12 +10,12 @@ import { SimpleResource } from '../common/is.model';
export class CleanerTesterClient extends ISClient {
loadCleaningRules(onSuccess: Function): void {
this.httpGet<SimpleResource[]>("/ajax/resource-manager/byType/cleaning_rule", onSuccess);
this.httpGet<SimpleResource[]>("/proxy/ajax/resource-manager/byType/cleaning_rule", onSuccess);
}
testCleaning(rule: string, xml: string, onSuccess: Function, relatedForm?: FormGroup): void {
var headers = new HttpHeaders().set('Content-Type', 'text/plain; charset=utf-8');
this.httpPostWithOptions('/ajax/mapping/clean?rule=' + encodeURIComponent(rule), xml, { headers, responseType: 'text' as 'json' }, onSuccess, relatedForm);
this.httpPostWithOptions('/proxy/ajax/mapping/clean?rule=' + encodeURIComponent(rule), xml, { headers, responseType: 'text' as 'json' }, onSuccess, relatedForm);
}
}

View File

@ -8,19 +8,19 @@ import { ISClient } from '../common/is.client';
export class ContextsClient extends ISClient {
loadContexts(onSuccess: Function): void {
this.httpGet<Context[]>('/ajax/contexts-manager/', onSuccess);
this.httpGet<Context[]>('/proxy/ajax/contexts-manager/', onSuccess);
}
loadContext(ctxId: string, onSuccess: Function): void {
this.httpGet<Context>('/ajax/contexts-manager/' + encodeURIComponent(ctxId), onSuccess);
this.httpGet<Context>('/proxy/ajax/contexts-manager/' + encodeURIComponent(ctxId), onSuccess);
}
loadContextCategories(ctxId: string, onSuccess: Function): void {
this.httpGet<ContextNode[]>('/ajax/contexts-manager/' + encodeURIComponent(ctxId) + '/categories', onSuccess);
this.httpGet<ContextNode[]>('/proxy/ajax/contexts-manager/' + encodeURIComponent(ctxId) + '/categories', onSuccess);
}
loadContextConcepts(level: number, nodeId: string, onSuccess: Function): void {
this.httpGet<ContextNode[]>('/ajax/contexts-manager/' + encodeURIComponent(level) + '/' + encodeURIComponent(nodeId) + '/concepts', onSuccess);
this.httpGet<ContextNode[]>('/proxy/ajax/contexts-manager/' + encodeURIComponent(level) + '/' + encodeURIComponent(nodeId) + '/concepts', onSuccess);
}
}

View File

@ -8,23 +8,23 @@ import { ISClient } from '../common/is.client';
export class DsmClient extends ISClient {
dsmConf(onSuccess: Function) {
this.httpGet<DsmConf>('/ajax/dsm/conf', onSuccess);
this.httpGet<DsmConf>('/proxy/ajax/dsm/conf', onSuccess);
}
dsmBrowsableFields(onSuccess: Function) {
this.httpGet<KeyValue[]>('/ajax/dsm/browsableFields', onSuccess);
this.httpGet<KeyValue[]>('/proxy/ajax/dsm/browsableFields', onSuccess);
}
dsmBrowse(field: string, onSuccess: Function) {
this.httpGet<BrowseTerm[]>('/ajax/dsm/browse/' + encodeURIComponent(field), onSuccess);
this.httpGet<BrowseTerm[]>('/proxy/ajax/dsm/browse/' + encodeURIComponent(field), onSuccess);
}
dsmSearchByField(field: string, value: string, page: number, pageSize: number, onSuccess: Function) {
this.httpGet<Page<Datasource>>('/ajax/dsm/searchByField/' + encodeURIComponent(field) + '/' + page + '/' + pageSize + '?value=' + encodeURIComponent(value), onSuccess);
this.httpGet<Page<Datasource>>('/proxy/ajax/dsm/searchByField/' + encodeURIComponent(field) + '/' + page + '/' + pageSize + '?value=' + encodeURIComponent(value), onSuccess);
}
dsmSearch(value: string, page: number, pageSize: number, onSuccess: Function) {
this.httpGet<Page<Datasource>>('/ajax/dsm/search/' + page + '/' + pageSize + '?value=' + encodeURIComponent(value), onSuccess);
this.httpGet<Page<Datasource>>('/proxy/ajax/dsm/search/' + page + '/' + pageSize + '?value=' + encodeURIComponent(value), onSuccess);
}
}

View File

@ -9,14 +9,14 @@ import { ISClient } from '../common/is.client';
export class EmailsClient extends ISClient {
loadEmailTemplates(onSuccess: Function): void {
this.httpGet<EmailTemplate[]>('/ajax/templates/email/', onSuccess);
this.httpGet<EmailTemplate[]>('/proxy/ajax/templates/email/', onSuccess);
}
saveEmailTemplate(email: EmailTemplate, onSuccess: Function, relatedForm?: FormGroup): void {
this.httpPost('/ajax/templates/email/', email, onSuccess, relatedForm);
this.httpPost('/proxy/ajax/templates/email/', email, onSuccess, relatedForm);
}
deleteEmailTemplate(id: string, onSuccess: Function): void {
this.httpDelete('/ajax/templates/email/' + encodeURIComponent(id), onSuccess);
this.httpDelete('/proxy/ajax/templates/email/' + encodeURIComponent(id), onSuccess);
}
}

View File

@ -1,5 +1,4 @@
<h2>Registered Services</h2>
<p>
<button mat-stroked-button color="primary" (click)="reload()">
<mat-icon fontIcon="refresh"></mat-icon>
@ -27,8 +26,7 @@
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef style="width: 30%;" mat-sort-header sortActionDescription="Sort by Name"> Name
</th>
<td mat-cell *matCellDef="let element"> <a href="/swagger/{{element.name}}/index.html"
target="_blank">{{element.name}}</a>
<td mat-cell *matCellDef="let element"> <a [routerLink]="['/swagger-ui', element.name]">{{element.name}}</a>
</td>
</ng-container>

View File

@ -8,11 +8,11 @@ import { ISClient } from '../common/is.client';
export class MainMenuPanelsClient extends ISClient {
loadResourceTypes(onSuccess: Function) {
this.httpGet<ResourceType[]>("/ajax/resource-manager/resourceTypes", onSuccess)
this.httpGet<ResourceType[]>("/proxy/ajax/resource-manager/resourceTypes", onSuccess)
}
loadWfSections(onSuccess: Function) {
this.httpGet<WfSection[]>("/ajax/wf-manager/sections", onSuccess)
this.httpGet<WfSection[]>("/proxy/ajax/wf-manager/sections", onSuccess)
}
}

View File

@ -10,11 +10,11 @@ import { ISClient } from '../common/is.client';
export class MdstoresClient extends ISClient {
loadMDStores(onSuccess: Function): void {
this.httpGet<MDStore[]>("/ajax/mdstores/", onSuccess);
this.httpGet<MDStore[]>("/proxy/ajax/mdstores/", onSuccess);
}
loadMDStore(mdId: string, onSuccess: Function): void {
this.httpGet<MDStore>('/ajax/mdstores/mdstore/' + encodeURIComponent(mdId), onSuccess);
this.httpGet<MDStore>('/proxy/ajax/mdstores/mdstore/' + encodeURIComponent(mdId), onSuccess);
}
addMDStore(format: string, layout: string, interpretation: string, type: string, dsName: string, dsId: string, apiId: string, onSuccess: Function, relatedForm?: FormGroup) {
@ -25,7 +25,7 @@ export class MdstoresClient extends ISClient {
.set('dsId', dsId)
.set('apiId', apiId);
this.httpPostWithOptions('/ajax/mdstores/new/'
this.httpPostWithOptions('/proxy/ajax/mdstores/new/'
+ encodeURIComponent(format)
+ '/'
+ encodeURIComponent(layout)
@ -37,38 +37,38 @@ export class MdstoresClient extends ISClient {
}
deleteMDStore(mdId: string, onSuccess: Function): void {
this.httpDelete('/ajax/mdstores/mdstore/' + encodeURIComponent(mdId), onSuccess);
this.httpDelete('/proxy/ajax/mdstores/mdstore/' + encodeURIComponent(mdId), onSuccess);
}
prepareNewMDStoreVersion(mdId: string, onSuccess: Function): void {
this.httpGet<MDStoreVersion>('/ajax/mdstores/mdstore/' + encodeURIComponent(mdId) + '/newVersion', onSuccess);
this.httpGet<MDStoreVersion>('/proxy/ajax/mdstores/mdstore/' + encodeURIComponent(mdId) + '/newVersion', onSuccess);
}
commitMDStoreVersion(versionId: string, size: number, onSuccess: Function) {
this.httpGet<any>('/ajax/mdstores/version/' + encodeURIComponent(versionId) + '/commit/' + size, onSuccess);
this.httpGet<any>('/proxy/ajax/mdstores/version/' + encodeURIComponent(versionId) + '/commit/' + size, onSuccess);
}
abortMDStoreVersion(versionId: string, onSuccess: Function) {
this.httpGet<any>('/ajax/mdstores/version/' + encodeURIComponent(versionId) + '/abort', onSuccess);
this.httpGet<any>('/proxy/ajax/mdstores/version/' + encodeURIComponent(versionId) + '/abort', onSuccess);
}
deleteMDStoreVersion(versionId: string, onSuccess: Function) {
this.httpDelete('/ajax/mdstores/version/' + encodeURIComponent(versionId), onSuccess);
this.httpDelete('/proxy/ajax/mdstores/version/' + encodeURIComponent(versionId), onSuccess);
}
resetReadingMDStoreVersion(versionId: string, onSuccess: Function) {
this.httpGet<any>('/ajax/mdstores/version/' + encodeURIComponent(versionId) + '/resetReading', onSuccess);
this.httpGet<any>('/proxy/ajax/mdstores/version/' + encodeURIComponent(versionId) + '/resetReading', onSuccess);
}
loadMDStoreVersions(mdId: string, onSuccess: Function): void {
this.httpGet<MDStoreVersion[]>('/ajax/mdstores/mdstore/' + encodeURIComponent(mdId) + '/versions', onSuccess);
this.httpGet<MDStoreVersion[]>('/proxy/ajax/mdstores/mdstore/' + encodeURIComponent(mdId) + '/versions', onSuccess);
}
loadMDStoreVersion(versionId: string, onSuccess: Function): void {
this.httpGet<MDStoreVersion>('/ajax/mdstores/version/' + encodeURIComponent(versionId), onSuccess);
this.httpGet<MDStoreVersion>('/proxy/ajax/mdstores/version/' + encodeURIComponent(versionId), onSuccess);
}
loadMDStoreVersionRecords(versionId: string, limit: number, onSuccess: Function): void {
this.httpGet<MDStoreRecord[]>('/ajax/mdstores/version/' + encodeURIComponent(versionId) + '/content/' + limit, onSuccess);
this.httpGet<MDStoreRecord[]>('/proxy/ajax/mdstores/version/' + encodeURIComponent(versionId) + '/content/' + limit, onSuccess);
}
}

View File

@ -8,7 +8,7 @@ import { ISClient } from '../common/is.client';
export class ProtocolsClient extends ISClient {
loadProtocols(onSuccess: Function): void {
this.httpGet<Protocol[]>("/ajax/dsm/protocols/", onSuccess);
this.httpGet<Protocol[]>("/proxy/ajax/dsm/protocols/", onSuccess);
}
}

View File

@ -10,27 +10,27 @@ import { ISClient } from '../common/is.client';
export class ResourcesClient extends ISClient {
loadResourceType(id: string, onSuccess: Function) {
this.httpGet<ResourceType>("/ajax/resource-manager/resourceTypes/" + encodeURIComponent(id), onSuccess);
this.httpGet<ResourceType>("/proxy/ajax/resource-manager/resourceTypes/" + encodeURIComponent(id), onSuccess);
}
loadSimpleResources(type: string, onSuccess: Function): void {
this.httpGet<SimpleResource[]>("/ajax/resource-manager/byType/" + encodeURIComponent(type), onSuccess);
this.httpGet<SimpleResource[]>("/proxy/ajax/resource-manager/byType/" + encodeURIComponent(type), onSuccess);
}
loadSimpleResourceContent(id: any, onSuccess: Function): void {
const headers = new HttpHeaders().set('Content-Type', 'text/plain; charset=utf-8');
this.httpGetWithOptions<string>("/ajax/resource-manager/resources/" + encodeURIComponent(id) + '/content', {
this.httpGetWithOptions<string>("/proxy/ajax/resource-manager/resources/" + encodeURIComponent(id) + '/content', {
headers, responseType: 'text' as 'json'
}, onSuccess);
}
saveSimpleResourceMedatata(res: SimpleResource, onSuccess: Function, relatedForm?: FormGroup): void {
this.httpPost('/ajax/resource-manager/resources/' + encodeURIComponent(res.id) + '/metadata', res, onSuccess, relatedForm);
this.httpPost('/proxy/ajax/resource-manager/resources/' + encodeURIComponent(res.id) + '/metadata', res, onSuccess, relatedForm);
}
saveSimpleResourceContent(id: string, content: string, onSuccess: Function, relatedForm?: FormGroup): void {
const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')
let body = new HttpParams().set('content', content);
this.httpPostWithOptions('/ajax/resource-manager/resources/' + encodeURIComponent(id) + '/content', body, { headers: headers }, onSuccess, relatedForm);
this.httpPostWithOptions('/proxy/ajax/resource-manager/resources/' + encodeURIComponent(id) + '/content', body, { headers: headers }, onSuccess, relatedForm);
}
addSimpleResource(name: string, type: string, subtype: string, description: string, content: string, onSuccess: Function, relatedForm?: FormGroup): void {
@ -41,11 +41,11 @@ export class ResourcesClient extends ISClient {
.set('subtype', subtype)
.set('description', description)
.set('content', content);
this.httpPostWithOptions('/ajax/resource-manager/resources/', body, { headers: headers }, onSuccess, relatedForm);
this.httpPostWithOptions('/proxy/ajax/resource-manager/resources/', body, { headers: headers }, onSuccess, relatedForm);
}
deleteSimpleResource(resourceId: string, onSuccess: Function): void {
this.httpDelete('/ajax/resource-manager/resources/' + encodeURIComponent(resourceId), onSuccess);
this.httpDelete('/proxy/ajax/resource-manager/resources/' + encodeURIComponent(resourceId), onSuccess);
}
}

View File

@ -0,0 +1 @@
<div id="swagger-ui"></div>

View File

@ -0,0 +1,33 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
declare const SwaggerUIBundle: any;
@Component({
selector: 'app-swagger-ui',
templateUrl: './swagger-ui.component.html',
styleUrls: ['./swagger-ui.component.css']
})
export class SwaggerUiComponent implements OnInit {
constructor(public route: ActivatedRoute, public router: Router) {
}
ngOnInit(): void {
this.route.params.subscribe(params => {
let serviceId = params['id'];
const ui = SwaggerUIBundle({
dom_id: '#swagger-ui',
layout: 'BaseLayout',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIBundle.SwaggerUIStandalonePreset
],
url: '/proxy/swagger-conf/' + serviceId,
docExpansion: 'none',
operationsSorter: 'alpha'
});
});
}
}

View File

@ -9,31 +9,31 @@ import { ISClient } from '../common/is.client';
export class VocabulariesClient extends ISClient {
loadVocabularies(onSuccess: Function): void {
this.httpGet<Vocabulary[]>('/ajax/vocabulary-manager/vocs/', onSuccess);
this.httpGet<Vocabulary[]>('/proxy/ajax/vocabulary-manager/vocs/', onSuccess);
}
loadVocabulary(vocId: string, onSuccess: Function): void {
this.httpGet<Vocabulary>('/ajax/vocabulary-manager/vocs/' + encodeURIComponent(vocId), onSuccess);
this.httpGet<Vocabulary>('/proxy/ajax/vocabulary-manager/vocs/' + encodeURIComponent(vocId), onSuccess);
}
loadVocabularyTerms(vocId: string, onSuccess: Function): void {
this.httpGet<VocabularyTerm[]>('/ajax/vocabulary-manager/vocs/' + encodeURIComponent(vocId) + '/terms', onSuccess);
this.httpGet<VocabularyTerm[]>('/proxy/ajax/vocabulary-manager/vocs/' + encodeURIComponent(vocId) + '/terms', onSuccess);
}
saveVocabulary(voc: Vocabulary, onSuccess: Function, relatedForm?: FormGroup): void {
this.httpPost('/ajax/vocabulary-manager/vocs/', voc, onSuccess, relatedForm);
this.httpPost('/proxy/ajax/vocabulary-manager/vocs/', voc, onSuccess, relatedForm);
}
saveVocabularyTerm(vocId: string, term: VocabularyTerm, onSuccess: Function, relatedForm?: FormGroup): void {
this.httpPost('/ajax/vocabulary-manager/vocs/' + encodeURIComponent(vocId) + '/terms', term, onSuccess, relatedForm);
this.httpPost('/proxy/ajax/vocabulary-manager/vocs/' + encodeURIComponent(vocId) + '/terms', term, onSuccess, relatedForm);
}
deleteVocabulary(vocId: string, onSuccess: Function): void {
this.httpDelete('/ajax/vocabulary-manager/vocs/' + encodeURIComponent(vocId), onSuccess);
this.httpDelete('/proxy/ajax/vocabulary-manager/vocs/' + encodeURIComponent(vocId), onSuccess);
}
deleteVocabularyTerm(vocId: string, termCode: string, onSuccess: Function): void {
this.httpDelete('/ajax/vocabulary-manager/vocs/'
this.httpDelete('/proxy/ajax/vocabulary-manager/vocs/'
+ encodeURIComponent(vocId)
+ '/terms/'
+ encodeURIComponent(termCode)

View File

@ -15,7 +15,7 @@
<mat-icon fontIcon="add"></mat-icon>
create a new term
</button>
<a mat-stroked-button color="link" href="/ajax/vocabulary-manager/vocs/{{voc?.id}}/terms" target="_blank">
<a mat-stroked-button color="link" href="/proxy/ajax/vocabulary-manager/vocs/{{voc?.id}}/terms" target="_blank">
<mat-icon fontIcon="download"></mat-icon>
Download
</a>

View File

@ -10,60 +10,60 @@ import { ISClient } from '../common/is.client';
export class WfConfsClient extends ISClient {
loadWfSections(onSuccess: Function) {
this.httpGet<WfSection[]>("/ajax/wf-manager/sections", onSuccess)
this.httpGet<WfSection[]>("/proxy/ajax/wf-manager/sections", onSuccess)
}
loadWfHistoryForConf(wfConfId: string, onSuccess: Function): void {
this.httpGet<WfHistoryEntry[]>('/ajax/wf-manager/history/byConf/' + encodeURIComponent(wfConfId), onSuccess);
this.httpGet<WfHistoryEntry[]>('/proxy/ajax/wf-manager/history/byConf/' + encodeURIComponent(wfConfId), onSuccess);
}
loadWfConfigurations(sectionId: string, onSuccess: Function): void {
this.httpGet<KeyValue[]>('/ajax/wf-manager/sections/' + encodeURIComponent(sectionId), onSuccess);
this.httpGet<KeyValue[]>('/proxy/ajax/wf-manager/sections/' + encodeURIComponent(sectionId), onSuccess);
}
loadWfConfiguration(id: string, onSuccess: Function): void {
this.httpGet<WfConf>('/ajax/wf-manager/conf/' + encodeURIComponent(id), onSuccess);
this.httpGet<WfConf>('/proxy/ajax/wf-manager/conf/' + encodeURIComponent(id), onSuccess);
}
saveWfConfiguration(conf: WfConf, onSuccess: Function, relatedForm?: FormGroup): void {
this.httpPost('/ajax/wf-manager/conf', conf, onSuccess, relatedForm);
this.httpPost('/proxy/ajax/wf-manager/conf', conf, onSuccess, relatedForm);
}
deleteWfConfiguration(id: string, onSuccess: Function): void {
this.httpDelete('/ajax/wf-manager/conf/' + encodeURIComponent(id), onSuccess);
this.httpDelete('/proxy/ajax/wf-manager/conf/' + encodeURIComponent(id), onSuccess);
}
startWfConfiguration(id: string, onSuccess: Function): void {
this.httpGet<WfProcessStatus>('/ajax/wf-manager/conf/' + encodeURIComponent(id) + '/start', onSuccess);
this.httpGet<WfProcessStatus>('/proxy/ajax/wf-manager/conf/' + encodeURIComponent(id) + '/start', onSuccess);
}
startDestroyWfConfiguration(id: string, onSuccess: Function): void {
this.httpGet<WfProcessStatus>('/ajax/wf-manager/conf/' + encodeURIComponent(id) + '/destroy', onSuccess);
this.httpGet<WfProcessStatus>('/proxy/ajax/wf-manager/conf/' + encodeURIComponent(id) + '/destroy', onSuccess);
}
findProcess(id: string, onSuccess: Function): void {
this.httpGet<WfProcessStatus>('/ajax/wf-manager/process/' + encodeURIComponent(id), onSuccess);
this.httpGet<WfProcessStatus>('/proxy/ajax/wf-manager/process/' + encodeURIComponent(id), onSuccess);
}
killProcess(id: string, onSuccess: Function): void {
this.httpDelete('/ajax/wf-manager/process/' + encodeURIComponent(id), onSuccess);
this.httpDelete('/proxy/ajax/wf-manager/process/' + encodeURIComponent(id), onSuccess);
}
findWfSubscriptions(id: string, onSuccess: Function): void {
this.httpGet<WfSubscription[]>('/ajax/wf-manager/conf/' + encodeURIComponent(id) + '/subscriptions', onSuccess);
this.httpGet<WfSubscription[]>('/proxy/ajax/wf-manager/conf/' + encodeURIComponent(id) + '/subscriptions', onSuccess);
}
saveWfSubscriptions(id: string, subscriptions: WfSubscription[], onSuccess: Function, relatedForm?: FormGroup): void {
this.httpPost('/ajax/wf-manager/conf/' + encodeURIComponent(id) + '/subscriptions', subscriptions, onSuccess, relatedForm);
this.httpPost('/proxy/ajax/wf-manager/conf/' + encodeURIComponent(id) + '/subscriptions', subscriptions, onSuccess, relatedForm);
}
loadWfTemplates(onSuccess: Function): void {
this.httpGet<SimpleResource[]>("/ajax/resource-manager/byType/wf_template", onSuccess);
this.httpGet<SimpleResource[]>("/proxy/ajax/resource-manager/byType/wf_template", onSuccess);
}
loadWfTemplate(id: any, onSuccess: Function): void {
const headers = new HttpHeaders().set('Content-Type', 'text/plain; charset=utf-8');
this.httpGetWithOptions<string>("/ajax/resource-manager/resources/" + encodeURIComponent(id) + '/content', {
this.httpGetWithOptions<string>("/proxy/ajax/resource-manager/resources/" + encodeURIComponent(id) + '/content', {
headers, responseType: 'text' as 'json'
}, onSuccess);
}

View File

@ -14,6 +14,6 @@ export class WfHistoryClient extends ISClient {
if (from && from > 0) { params = params.append('from', from); }
if (to && to > 0) { params = params.append('to', to); }
this.httpGetWithOptions<WfHistoryEntry[]>('/ajax/wf-manager/history/', { params: params }, onSuccess);
this.httpGetWithOptions<WfHistoryEntry[]>('/proxy/ajax/wf-manager/history/', { params: params }, onSuccess);
}
}

View File

@ -1,14 +1,10 @@
{
"/ajax": {
"target": "http://localhost:8888/ajax",
"/proxy": {
"target": "http://localhost:8888/proxy",
"secure": false
},
"/ajax-is": {
"target": "http://localhost:8888/ajax-is",
"secure": false
},
"/swagger": {
"target": "http://localhost:8888/swagger",
"secure": false
}
}

View File

@ -3,7 +3,6 @@ package eu.dnetlib.common.app;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ScheduledThreadPoolExecutor;
@ -11,7 +10,6 @@ import java.util.concurrent.TimeUnit;
import javax.annotation.PostConstruct;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.maven.model.Model;
@ -31,7 +29,6 @@ import io.micrometer.core.instrument.Metrics;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.servers.Server;
import io.swagger.v3.oas.models.tags.Tag;
public abstract class AbstractDnetApp {
@ -55,9 +52,6 @@ public abstract class AbstractDnetApp {
@Value("${server.description}")
private String serverDesc;
@Value("${server.public_url}")
private String serverPublicUrl;
@Value("${dnet.is.url}")
private String informationServiceUrl;
@ -65,6 +59,8 @@ public abstract class AbstractDnetApp {
private static final ScheduledThreadPoolExecutor registrationThreadPoolExecutor = new ScheduledThreadPoolExecutor(1);
public static final String SWAGGER_API_GROUP = "dnet-apis";
@PostConstruct
public void init() {
final MavenXpp3Reader reader = new MavenXpp3Reader();
@ -103,16 +99,7 @@ public abstract class AbstractDnetApp {
@Bean
public OpenAPI newSwaggerDocket() {
final List<Server> servers = new ArrayList<>();
if (StringUtils.isNotBlank(serverPublicUrl)) {
final Server server = new Server();
server.setUrl(serverPublicUrl);
server.setDescription(serverDesc);
servers.add(server);
}
return new OpenAPI()
.servers(servers)
.info(getSwaggerInfo())
.tags(getSwaggerTags());
}
@ -120,7 +107,8 @@ public abstract class AbstractDnetApp {
@Bean
public GroupedOpenApi publicApi() {
return GroupedOpenApi.builder()
.group(serverTitle)
.group(SWAGGER_API_GROUP)
.displayName(serverTitle)
.pathsToMatch("/api/**")
.build();
}