From 8796e5a0479142ae9995dcb287bc3e1b12bb4d61 Mon Sep 17 00:00:00 2001 From: Jad El-khoury Date: Wed, 14 Jun 2023 15:05:57 +0200 Subject: [PATCH] Ability to extend authentication imports. --- .../files/generateAdaptorApplication.mtl | 52 ++++++++++--------- .../services/adaptorInterfaceServices.mtl | 36 ++++++++----- 2 files changed, 52 insertions(+), 36 deletions(-) diff --git a/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateAdaptorApplication.mtl b/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateAdaptorApplication.mtl index 2080227c..74192f7f 100644 --- a/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateAdaptorApplication.mtl +++ b/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/files/generateAdaptorApplication.mtl @@ -26,30 +26,7 @@ [import org::eclipse::lyo::oslc4j::codegenerator::services::serviceProviderCatalogServices/] [import org::eclipse::lyo::oslc4j::codegenerator::services::osgiServices/] -[template public additionalResourceClasses(anAdaptorInterface : AdaptorInterface) post (trim())] -[/template] - -[template public generateAdaptorApplication(anAdaptorInterface : AdaptorInterface)] -[file (javaClassFullFileNameForAdaptorApplication(anAdaptorInterface), false, 'UTF-8')] -// [protected ('Copyright')] -/* - * Copyright (c) 2020 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 Distribution License 1.0 which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: BSD-3-Simple - * - * This file is generated by Lyo Designer (https://www.eclipse.org/lyo/) - */ -// [/protected] - -package [javaClassPackageNameForAdaptorApplication(anAdaptorInterface) /]; - +[template public generateImports(anAdaptorInterface : AdaptorInterface)] import java.net.URISyntaxException; import java.util.Collections; import java.util.HashMap; @@ -111,6 +88,33 @@ import org.eclipse.lyo.oslc4j.trs.server.service.TrackedResourceSetService; // [protected ('imports')] // [/protected] +[/template] + +[template public additionalResourceClasses(anAdaptorInterface : AdaptorInterface) post (trim())] +[/template] + +[template public generateAdaptorApplication(anAdaptorInterface : AdaptorInterface)] +[file (javaClassFullFileNameForAdaptorApplication(anAdaptorInterface), false, 'UTF-8')] +// [protected ('Copyright')] +/* + * Copyright (c) 2020 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 Distribution License 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: BSD-3-Simple + * + * This file is generated by Lyo Designer (https://www.eclipse.org/lyo/) + */ +// [/protected] + +package [javaClassPackageNameForAdaptorApplication(anAdaptorInterface) /]; + +[generateImports(anAdaptorInterface)/] // [protected ('pre_class_code')] // [/protected] diff --git a/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/services/adaptorInterfaceServices.mtl b/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/services/adaptorInterfaceServices.mtl index 13788159..a5f013e3 100644 --- a/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/services/adaptorInterfaceServices.mtl +++ b/org.eclipse.lyo.oslc4j.codegenerator/src/org/eclipse/lyo/oslc4j/codegenerator/services/adaptorInterfaceServices.mtl @@ -45,26 +45,38 @@ JAXRSConcatURISegments(anAdaptorInterface.getApplicationBaseUrl(), anAdaptorInte JAXRSConcatURISegments(anAdaptorInterface.configuration.applicationContextPath, anAdaptorInterface.getServletPath()) /] -[query public authenticationOauthRealm(anAdaptorInterface : AdaptorInterface) : String = -anAdaptorInterface.configuration.authenticationConfiguration.oauthRealm -/] - -[query public authenticationApplicationName(anAdaptorInterface : AdaptorInterface) : String = -anAdaptorInterface.configuration.authenticationConfiguration.applicationName -/] - -[query public authenticationEnabled(anAdaptorInterface : AdaptorInterface) : Boolean = +[query public getAuthenticationConfiguration(anAdaptorInterface : AdaptorInterface) : AuthenticationConfiguration = (if (anAdaptorInterface.configuration.oclIsUndefined()) then - false + null else (if anAdaptorInterface.configuration.authenticationConfiguration.oclIsUndefined() then - false + null else - true + anAdaptorInterface.configuration.authenticationConfiguration endif) endif) /] +[query public authenticationEnabled(anAdaptorInterface : AdaptorInterface) : Boolean = +not anAdaptorInterface.getAuthenticationConfiguration().oclIsUndefined() +/] + +[query public authenticationOauthRealm(anAdaptorInterface : AdaptorInterface) : String = +(if anAdaptorInterface.authenticationEnabled() then + anAdaptorInterface.getAuthenticationConfiguration().oauthRealm +else + null +endif) +/] + +[query public authenticationApplicationName(anAdaptorInterface : AdaptorInterface) : String = +(if anAdaptorInterface.authenticationEnabled() then + anAdaptorInterface.getAuthenticationConfiguration().applicationName +else + null +endif) +/] + [query public swaggerDocumentationEnabled(anAdaptorInterface : AdaptorInterface) : Boolean = (if anAdaptorInterface.swaggerDocumentation.oclIsUndefined() then false