This is an automated email from the ASF dual-hosted git repository. yasith pushed a commit to branch feat/spring-module-reorg in repository https://gitbox.apache.org/repos/asf/airavata.git
commit 5d5ea6c203b761e563b18c24a9a10e0cf4a2965b Author: yasithdev <[email protected]> AuthorDate: Fri Mar 27 22:24:02 2026 -0500 feat: create airavata-rest-server, absorb restproxy, centralize auth + OpenAPI --- airavata-rest-server/pom.xml | 133 +++++++++++++++++++ .../rest/server/AiravataRestServerConfig.java | 22 ++-- .../airavata/rest/server/config/OpenApiConfig.java | 90 +++++++++++++ .../rest/server/config/SecurityConfig.java | 132 +++++++++++++++++++ .../airavata/rest/server/config/WebMvcConfig.java | 26 ++-- .../server/controller/KafkaProxyController.java | 35 +++-- modules/restproxy/pom.xml | 102 -------------- .../src/main/assembly/restproxy-bin-assembly.xml | 75 ----------- .../src/main/resources/application.properties | 4 - .../main/resources/distribution/bin/restproxy.sh | 26 ---- .../src/main/resources/distribution/bin/setenv.sh | 146 --------------------- .../src/main/resources/distribution/conf/.gitkeep | 0 modules/restproxy/src/main/resources/log4j2.xml | 39 ------ pom.xml | 2 +- 14 files changed, 406 insertions(+), 426 deletions(-) diff --git a/airavata-rest-server/pom.xml b/airavata-rest-server/pom.xml new file mode 100644 index 0000000000..433a23fc2c --- /dev/null +++ b/airavata-rest-server/pom.xml @@ -0,0 +1,133 @@ +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> +<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.airavata</groupId> + <artifactId>airavata</artifactId> + <version>0.21-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>airavata-rest-server</artifactId> + <name>Airavata REST Server</name> + + <dependencies> + <!-- Project modules --> + <dependency> + <groupId>org.apache.airavata</groupId> + <artifactId>airavata-api</artifactId> + <version>${project.version}</version> + <exclusions> + <exclusion> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + </exclusion> + <exclusion> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + </exclusion> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.airavata</groupId> + <artifactId>research-service</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.airavata</groupId> + <artifactId>agent-service</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.airavata</groupId> + <artifactId>file-server</artifactId> + <version>${project.version}</version> + </dependency> + + <!-- Spring Boot --> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + <exclusions> + <exclusion> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-data-jpa</artifactId> + <exclusions> + <exclusion> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> + <exclusions> + <exclusion> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + + <!-- OpenAPI --> + <dependency> + <groupId>org.springdoc</groupId> + <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> + </dependency> + + <!-- Kafka --> + <dependency> + <groupId>org.apache.kafka</groupId> + <artifactId>kafka-clients</artifactId> + </dependency> + + <!-- Database --> + <dependency> + <groupId>org.mariadb.jdbc</groupId> + <artifactId>mariadb-java-client</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <release>17</release> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/modules/restproxy/src/main/java/org/apache/airavata/restproxy/RestProxyApplication.java b/airavata-rest-server/src/main/java/org/apache/airavata/rest/server/AiravataRestServerConfig.java similarity index 56% rename from modules/restproxy/src/main/java/org/apache/airavata/restproxy/RestProxyApplication.java rename to airavata-rest-server/src/main/java/org/apache/airavata/rest/server/AiravataRestServerConfig.java index 9cf5dbee33..eec0f97ca8 100644 --- a/modules/restproxy/src/main/java/org/apache/airavata/restproxy/RestProxyApplication.java +++ b/airavata-rest-server/src/main/java/org/apache/airavata/rest/server/AiravataRestServerConfig.java @@ -17,16 +17,16 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.airavata.restproxy; +package org.apache.airavata.rest.server; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.apache.airavata.agent.connection.service.config.AgentServiceConfig; +import org.apache.airavata.common.config.ConditionalOnServer; +import org.apache.airavata.file.server.config.FileServerConfig; +import org.apache.airavata.research.service.config.ResearchServiceConfig; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; -@SpringBootApplication -@EnableConfigurationProperties(RestProxyConfiguration.class) -public class RestProxyApplication { - public static void main(String[] args) { - SpringApplication.run(RestProxyApplication.class, args); - } -} +@Configuration +@ConditionalOnServer("rest") +@Import({ResearchServiceConfig.class, AgentServiceConfig.class, FileServerConfig.class}) +public class AiravataRestServerConfig {} diff --git a/airavata-rest-server/src/main/java/org/apache/airavata/rest/server/config/OpenApiConfig.java b/airavata-rest-server/src/main/java/org/apache/airavata/rest/server/config/OpenApiConfig.java new file mode 100644 index 0000000000..207bf18c1f --- /dev/null +++ b/airavata-rest-server/src/main/java/org/apache/airavata/rest/server/config/OpenApiConfig.java @@ -0,0 +1,90 @@ +/** +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ +package org.apache.airavata.rest.server.config; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.security.OAuthFlow; +import io.swagger.v3.oas.models.security.OAuthFlows; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import io.swagger.v3.oas.models.security.SecurityScheme; +import org.springdoc.core.models.GroupedOpenApi; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class OpenApiConfig { + + @Value("${airavata.security.openid-url:}") + private String openIdUrl; + + @Bean + public OpenAPI airavataOpenApi() { + return new OpenAPI() + .info(new Info() + .title("Airavata REST API") + .version("0.21-SNAPSHOT") + .description("Unified Airavata REST API")) + .components(new Components() + .addSecuritySchemes( + "oauth2-pkce", + new SecurityScheme() + .type(SecurityScheme.Type.OAUTH2) + .flows(new OAuthFlows() + .authorizationCode(new OAuthFlow() + .authorizationUrl(openIdUrl + "/protocol/openid-connect/auth") + .tokenUrl(openIdUrl + "/protocol/openid-connect/token"))))) + .addSecurityItem(new SecurityRequirement().addList("oauth2-pkce")); + } + + @Bean + public GroupedOpenApi researchGroup() { + return GroupedOpenApi.builder() + .group("research") + .pathsToMatch("/api/v1/rf/**") + .build(); + } + + @Bean + public GroupedOpenApi agentGroup() { + return GroupedOpenApi.builder() + .group("agent") + .pathsToMatch("/api/v1/agent/**", "/api/v1/plan/**", "/api/v1/exp/**") + .build(); + } + + @Bean + public GroupedOpenApi filesGroup() { + return GroupedOpenApi.builder() + .group("files") + .pathsToMatch("/api/v1/files/**") + .build(); + } + + @Bean + public GroupedOpenApi kafkaGroup() { + return GroupedOpenApi.builder() + .group("kafka") + .pathsToMatch("/api/v1/kafka/**") + .build(); + } +} diff --git a/airavata-rest-server/src/main/java/org/apache/airavata/rest/server/config/SecurityConfig.java b/airavata-rest-server/src/main/java/org/apache/airavata/rest/server/config/SecurityConfig.java new file mode 100644 index 0000000000..8caed09b3a --- /dev/null +++ b/airavata-rest-server/src/main/java/org/apache/airavata/rest/server/config/SecurityConfig.java @@ -0,0 +1,132 @@ +/** +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ +package org.apache.airavata.rest.server.config; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import org.apache.airavata.common.config.Constants; +import org.apache.airavata.common.security.UserContext; +import org.apache.airavata.model.security.AuthzToken; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class SecurityConfig { + + private static final Logger log = LoggerFactory.getLogger(SecurityConfig.class); + private static final ObjectMapper objectMapper = new ObjectMapper(); + + private static final Set<String> SKIP_PREFIXES = Set.of("/swagger-ui", "/v3/api-docs", "/actuator"); + + @Bean + public FilterRegistrationBean<Filter> authFilter() { + FilterRegistrationBean<Filter> registration = new FilterRegistrationBean<>(); + registration.setFilter(new AuthTokenFilter()); + registration.addUrlPatterns("/api/*"); + registration.setOrder(1); + return registration; + } + + private static class AuthTokenFilter implements Filter { + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { + HttpServletRequest httpReq = (HttpServletRequest) request; + HttpServletResponse httpResp = (HttpServletResponse) response; + + // Skip OPTIONS (CORS preflight) + if ("OPTIONS".equalsIgnoreCase(httpReq.getMethod())) { + chain.doFilter(request, response); + return; + } + + // Skip swagger / api-docs / actuator + String path = httpReq.getRequestURI(); + for (String prefix : SKIP_PREFIXES) { + if (path.startsWith(prefix)) { + chain.doFilter(request, response); + return; + } + } + + try { + String authHeader = httpReq.getHeader("Authorization"); + String accessToken = null; + if (authHeader != null && authHeader.startsWith("Bearer ")) { + accessToken = authHeader.substring(7); + } + + if (accessToken == null) { + httpResp.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Missing Authorization header"); + return; + } + + AuthzToken authzToken = new AuthzToken(accessToken); + + // Parse X-Claims header if present (JSON map of claim key-values) + String claimsHeader = httpReq.getHeader("X-Claims"); + Map<String, String> claimsMap = new HashMap<>(); + if (claimsHeader != null && !claimsHeader.isBlank()) { + try { + claimsMap = objectMapper.readValue(claimsHeader, new TypeReference<Map<String, String>>() {}); + } catch (Exception e) { + log.warn("Failed to parse X-Claims header: {}", e.getMessage()); + } + } + + // Also accept individual headers as fallback + if (!claimsMap.containsKey(Constants.USER_NAME)) { + String userName = httpReq.getHeader("X-User-Name"); + if (userName != null) { + claimsMap.put(Constants.USER_NAME, userName); + } + } + if (!claimsMap.containsKey(Constants.GATEWAY_ID)) { + String gatewayId = httpReq.getHeader("X-Gateway-Id"); + if (gatewayId != null) { + claimsMap.put(Constants.GATEWAY_ID, gatewayId); + } + } + + authzToken.setClaimsMap(claimsMap); + UserContext.setAuthzToken(authzToken); + + chain.doFilter(request, response); + } finally { + UserContext.clear(); + } + } + } +} diff --git a/modules/restproxy/src/main/java/org/apache/airavata/restproxy/RestProxyConfiguration.java b/airavata-rest-server/src/main/java/org/apache/airavata/rest/server/config/WebMvcConfig.java similarity index 52% rename from modules/restproxy/src/main/java/org/apache/airavata/restproxy/RestProxyConfiguration.java rename to airavata-rest-server/src/main/java/org/apache/airavata/rest/server/config/WebMvcConfig.java index 65dbf83aa0..f6bc160386 100644 --- a/modules/restproxy/src/main/java/org/apache/airavata/restproxy/RestProxyConfiguration.java +++ b/airavata-rest-server/src/main/java/org/apache/airavata/rest/server/config/WebMvcConfig.java @@ -17,20 +17,26 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.airavata.restproxy; +package org.apache.airavata.rest.server.config; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -@Component -@ConfigurationProperties -public class RestProxyConfiguration { +@Configuration +public class WebMvcConfig implements WebMvcConfigurer { - @Value("${restproxy.broker.url:airavata.host:9092}") - private String brokerUrl; + @Value("${airavata.cors.allowed-origins:*}") + private String allowedOrigins; - public String getBrokerUrl() { - return brokerUrl; + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/api/**") + .allowedOrigins(allowedOrigins.split(",")) + .allowedMethods("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS") + .allowedHeaders("*") + .allowCredentials(true) + .maxAge(3600); } } diff --git a/modules/restproxy/src/main/java/org/apache/airavata/restproxy/controller/ProxyController.java b/airavata-rest-server/src/main/java/org/apache/airavata/rest/server/controller/KafkaProxyController.java similarity index 76% rename from modules/restproxy/src/main/java/org/apache/airavata/restproxy/controller/ProxyController.java rename to airavata-rest-server/src/main/java/org/apache/airavata/rest/server/controller/KafkaProxyController.java index a7c7d8fa65..bf117c7d66 100644 --- a/modules/restproxy/src/main/java/org/apache/airavata/restproxy/controller/ProxyController.java +++ b/airavata-rest-server/src/main/java/org/apache/airavata/rest/server/controller/KafkaProxyController.java @@ -17,44 +17,52 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.airavata.restproxy.controller; +package org.apache.airavata.rest.server.controller; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.annotation.PostConstruct; +import jakarta.annotation.PreDestroy; import java.util.Properties; -import org.apache.airavata.restproxy.RestProxyConfiguration; import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.clients.producer.ProducerConfig; import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.common.serialization.StringSerializer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @RestController -public class ProxyController { - private static final Logger log = LoggerFactory.getLogger(ProxyController.class); +@RequestMapping("/api/v1/kafka") +public class KafkaProxyController { + + private static final Logger log = LoggerFactory.getLogger(KafkaProxyController.class); private KafkaProducer<String, String> producer; private final ObjectMapper objectMapper = new ObjectMapper(); - private final RestProxyConfiguration restProxyConfiguration; - public ProxyController(RestProxyConfiguration restProxyConfiguration) { - this.restProxyConfiguration = restProxyConfiguration; - } + @Value("${airavata.kafka.broker-url:localhost:9092}") + private String brokerUrl; @PostConstruct public void init() { Properties props = new Properties(); - props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, restProxyConfiguration.getBrokerUrl()); - props.put(ProducerConfig.CLIENT_ID_CONFIG, "RestProxyProducer"); + props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerUrl); + props.put(ProducerConfig.CLIENT_ID_CONFIG, "AiravataKafkaProxy"); props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName()); props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName()); producer = new KafkaProducer<>(props); } + @PreDestroy + public void destroy() { + if (producer != null) { + producer.close(); + } + } + @PostMapping(value = "/topics/{topic}", consumes = "application/vnd.kafka.json.v2+json") public ResponseEntity<?> postToKafka(@PathVariable("topic") String topic, @RequestBody String body) { try { @@ -64,16 +72,19 @@ public class ProxyController { } for (JsonNode record : root.get("records")) { JsonNode valueNode = record.get("value"); - if (valueNode == null) continue; + if (valueNode == null) { + continue; + } String valueStr = objectMapper.writeValueAsString(valueNode); log.info("Received message for topic {}: {}", topic, valueStr); var kafkaRecord = new ProducerRecord<String, String>(topic, valueStr); producer.send(kafkaRecord).get(); - log.info("RestProxyProducer posted to topic {}: {}", topic, valueStr); + log.info("Posted to topic {}: {}", topic, valueStr); producer.flush(); } return ResponseEntity.ok().build(); } catch (Exception e) { + log.error("Failed to post to Kafka topic {}", topic, e); return ResponseEntity.internalServerError().body(e.getMessage()); } } diff --git a/modules/restproxy/pom.xml b/modules/restproxy/pom.xml deleted file mode 100644 index 7a955a62de..0000000000 --- a/modules/restproxy/pom.xml +++ /dev/null @@ -1,102 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> -<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 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.airavata</groupId> - <artifactId>airavata</artifactId> - <version>0.21-SNAPSHOT</version> - <relativePath>../../pom.xml</relativePath> - </parent> - <artifactId>restproxy</artifactId> - <name>Airavata REST Proxy</name> - - <dependencies> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-web</artifactId> - <exclusions> - <exclusion> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-logging</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.kafka</groupId> - <artifactId>kafka-clients</artifactId> - </dependency> - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-databind</artifactId> - </dependency> - <dependency> - <groupId>jakarta.annotation</groupId> - <artifactId>jakarta.annotation-api</artifactId> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-actuator</artifactId> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <compilerArgs> - <arg>-parameters</arg> - </compilerArgs> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-assembly-plugin</artifactId> - <executions> - <execution> - <id>file-service-distribution-package</id> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - <configuration> - <tarLongFileMode>posix</tarLongFileMode> - <finalName>${restproxy.dist.name}</finalName> - <descriptors> - <descriptor>src/main/assembly/restproxy-bin-assembly.xml</descriptor> - </descriptors> - <attach>false</attach> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <properties> - <restproxy.dist.name>apache-airavata-restproxy-${project.version}</restproxy.dist.name> - </properties> -</project> \ No newline at end of file diff --git a/modules/restproxy/src/main/assembly/restproxy-bin-assembly.xml b/modules/restproxy/src/main/assembly/restproxy-bin-assembly.xml deleted file mode 100644 index de44ec314e..0000000000 --- a/modules/restproxy/src/main/assembly/restproxy-bin-assembly.xml +++ /dev/null @@ -1,75 +0,0 @@ - -<!-- - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - ---> -<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.2.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.2.0 http://maven.apache.org/xsd/assembly-2.2.0.xsd"> - <id>bin</id> - <includeBaseDirectory>true</includeBaseDirectory> - <baseDirectory>${restproxy.dist.name}</baseDirectory> - <formats> - <format>tar.gz</format> - </formats> - - <fileSets> - <fileSet> - <directory>src/main/resources/distribution/bin</directory> - <outputDirectory>bin</outputDirectory> - <fileMode>777</fileMode> - <includes> - <include>*.sh</include> - </includes> - </fileSet> - <fileSet> - <directory>src/main/resources/distribution/conf</directory> - <outputDirectory>conf</outputDirectory> - <includes> - <include>application.properties</include> - <include>log4j2.xml</include> - </includes> - </fileSet> - <fileSet> - <directory>./</directory> - <outputDirectory>logs</outputDirectory> - <excludes> - <exclude>*/**</exclude> - </excludes> - </fileSet> - <fileSet> - <directory>target</directory> - <outputDirectory>lib</outputDirectory> - <includes> - <include>*.jar</include> - </includes> - </fileSet> - </fileSets> - - <dependencySets> - <dependencySet> - <useProjectArtifact>false</useProjectArtifact> - <outputDirectory>lib</outputDirectory> - <includes> - <include>*</include> - </includes> - </dependencySet> - </dependencySets> - -</assembly> \ No newline at end of file diff --git a/modules/restproxy/src/main/resources/application.properties b/modules/restproxy/src/main/resources/application.properties deleted file mode 100644 index 4c3005b8b6..0000000000 --- a/modules/restproxy/src/main/resources/application.properties +++ /dev/null @@ -1,4 +0,0 @@ -restproxy.broker.url=localhost:9092 -server.port=8082 - -management.endpoints.web.exposure.include=health diff --git a/modules/restproxy/src/main/resources/distribution/bin/restproxy.sh b/modules/restproxy/src/main/resources/distribution/bin/restproxy.sh deleted file mode 100644 index 708d53aac4..0000000000 --- a/modules/restproxy/src/main/resources/distribution/bin/restproxy.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -. $(dirname $0)/setenv.sh - -SERVICE_NAME="rest-proxy" -MAIN_CLASS="org.apache.airavata.restproxy.RestProxyApplication" -JAVA_OPTS="-Dairavata.config.dir=${AIRAVATA_HOME}/conf -Dairavata.home=${AIRAVATA_HOME} -Dlog4j.configurationFile=file:${AIRAVATA_HOME}/conf/log4j2.xml -Dspring.config.location=${AIRAVATA_HOME}/conf/" - -run_service "$SERVICE_NAME" "$MAIN_CLASS" "$JAVA_OPTS" "$@" diff --git a/modules/restproxy/src/main/resources/distribution/bin/setenv.sh b/modules/restproxy/src/main/resources/distribution/bin/setenv.sh deleted file mode 100644 index 9024de1d7b..0000000000 --- a/modules/restproxy/src/main/resources/distribution/bin/setenv.sh +++ /dev/null @@ -1,146 +0,0 @@ -#!/bin/bash - -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# Resolve symlinks to get the real script location -PRG="$0" -while [ -L "$PRG" ]; do - PRG=$(readlink "$PRG") -done -PRGDIR=$(dirname "$PRG") - -# Set AIRAVATA_HOME if not already set -[ -z "$AIRAVATA_HOME" ] && AIRAVATA_HOME=$(cd "$PRGDIR/.." && pwd) - -# Build CLASSPATH from all JAR files -CLASSPATH=$(printf "%s:" "$AIRAVATA_HOME"/lib/*.jar) -CLASSPATH=${CLASSPATH%:} # Remove trailing colon - -export AIRAVATA_HOME CLASSPATH - -# Common function to run Airavata services -# Usage: run_service <service_name> <main_class> <java_opts> -run_service() { - local SERVICE_NAME="$1" MAIN_CLASS="$2" JAVA_OPTS="$3" - # Export SERVICE_NAME as environment variable for log4j2 configuration - export SERVICE_NAME - local CWD="$PWD" PID_PATH_NAME="${AIRAVATA_HOME}/bin/pid-${SERVICE_NAME}" - local DEFAULT_LOG_FILE="${AIRAVATA_HOME}/logs/${SERVICE_NAME}.log" - local LOG_FILE="$DEFAULT_LOG_FILE" DAEMON_MODE=false EXTRA_ARGS="" - - # Help text - local HELP_TEXT="Usage: ${SERVICE_NAME}.sh - -command options: - -d Run in daemon mode - -xdebug Start ${SERVICE_NAME} under JPDA debugger - -log <LOG_FILE> Where to redirect stdout/stderr (defaults to $DEFAULT_LOG_FILE) - -h Display this help and exit - -Daemon mode commands (use with -d): - start Start server in daemon mode - stop Stop server running in daemon mode - restart Restart server in daemon mode" - - cd "${AIRAVATA_HOME}/bin" - - # Helper function to stop daemon process - stop_daemon() { - if [[ -f "$PID_PATH_NAME" ]]; then - local PID=$(cat "$PID_PATH_NAME") - echo "$SERVICE_NAME stopping..." - pkill -P "$PID" - kill "$PID" - - local retry=0 - while kill -0 "$PID" 2>/dev/null && ((retry++ < 20)); do - echo "[PID: $PID] Waiting for process to stop..." - sleep 1 - done - - if kill -0 "$PID" 2>/dev/null; then - echo "[PID: $PID] Forcefully killing non-responsive process..." - pkill -9 -P "$PID" - kill -9 "$PID" - fi - - echo "$SERVICE_NAME is now stopped." - rm "$PID_PATH_NAME" - return 0 - else - echo "$SERVICE_NAME is not running." - return 1 - fi - } - - # Helper function to start daemon process - start_daemon() { - echo "Starting $SERVICE_NAME ..." - if [[ ! -f "$PID_PATH_NAME" ]]; then - nohup java $JAVA_OPTS -classpath "$CLASSPATH" "$MAIN_CLASS" "$@" >"$LOG_FILE" 2>&1 & - echo $! >"$PID_PATH_NAME" - echo "$SERVICE_NAME now running: PID $(cat "$PID_PATH_NAME")" - else - echo "$SERVICE_NAME already running: PID $(cat "$PID_PATH_NAME")" - fi - } - - # Parse command arguments - while (($# > 0)); do - case "$1" in - -d) DAEMON_MODE=true ;; - -xdebug) JAVA_OPTS+=" -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=*:8000" ;; - -log) - shift - LOG_FILE="$1" - [[ "$LOG_FILE" != /* ]] && LOG_FILE="${CWD}/${LOG_FILE}" - ;; - start | stop | restart) - if [[ "$DAEMON_MODE" == true ]]; then - case "$1" in - start) start_daemon "$@" ;; - stop) stop_daemon ;; - restart) - stop_daemon - start_daemon "$@" - ;; - esac - exit 0 - else - EXTRA_ARGS+=" $1" - fi - ;; - -h) - echo "$HELP_TEXT" - exit 0 - ;; - *) EXTRA_ARGS+=" $1" ;; - esac - shift - done - - # Validate daemon mode usage - if [[ "$DAEMON_MODE" == true ]]; then - echo "Error: Daemon mode (-d) requires one of: start, stop, restart" - echo "Use -h for help" - exit 1 - fi - - # Run in foreground mode - java $JAVA_OPTS -classpath "$CLASSPATH" "$MAIN_CLASS" $EXTRA_ARGS -} diff --git a/modules/restproxy/src/main/resources/distribution/conf/.gitkeep b/modules/restproxy/src/main/resources/distribution/conf/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/modules/restproxy/src/main/resources/log4j2.xml b/modules/restproxy/src/main/resources/log4j2.xml deleted file mode 100644 index 6e085a7f43..0000000000 --- a/modules/restproxy/src/main/resources/log4j2.xml +++ /dev/null @@ -1,39 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - ---> -<Configuration status="WARN"> - <Appenders> - <Console name="Console" target="SYSTEM_OUT"> - <PatternLayout pattern="%d [%t] %-5p %c{30} %X - %m%n" /> - </Console> - </Appenders> - <Loggers> - <logger name="ch.qos.logback" level="WARN" /> - <logger name="org.apache.helix" level="WARN" /> - <logger name="org.apache.zookeeper" level="ERROR" /> - <logger name="org.apache.airavata" level="INFO" /> - <logger name="org.hibernate" level="ERROR" /> - <Root level="INFO"> - <AppenderRef ref="Console" /> - </Root> - </Loggers> -</Configuration> \ No newline at end of file diff --git a/pom.xml b/pom.xml index 47eb746ce7..d202121e86 100644 --- a/pom.xml +++ b/pom.xml @@ -74,7 +74,7 @@ under the License. <module>modules/file-server</module> <module>modules/agent-framework/agent-service</module> <module>modules/research-framework/research-service</module> - <module>modules/restproxy</module> + <module>airavata-rest-server</module> </modules> <properties>
