Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
590e2a5
Add external service commons module with core interfaces and command …
jorge-romero Dec 9, 2025
b98b164
Add external service commons module to the project
jorge-romero Dec 9, 2025
fc69ebb
Add unit tests for ExternalServiceRegistry functionality
jorge-romero Dec 9, 2025
d1007c3
Add health indicators and integration tests for external services
jorge-romero Dec 9, 2025
48ff25d
Refactor external service integration to use command pattern and add …
jorge-romero Jan 23, 2026
91b865e
Refactor Bitbucket service to work with the command pattern
jorge-romero Jan 23, 2026
de999dc
feat: Openshift service to work with the command pattern
jorge-romero Jan 26, 2026
953b9d4
feat: Openshift service to work with the command pattern
jorge-romero Jan 26, 2026
1036994
test: Enable Openshift integration tests based on environment variable
jorge-romero Jan 26, 2026
9207053
feat: Webhook proxy use the command pattern
jorge-romero Jan 26, 2026
aad1f3c
feat: Update JWT dependencies and set test scope for WireMock
jorge-romero Jan 27, 2026
d5c7d53
feat: UIPath service to work with the command pattern
jorge-romero Jan 27, 2026
9b2e3d7
Add integration and unit tests for AAP commands and services
jorge-romero Jan 29, 2026
3993651
Fix code after detecting issues with integration tests.
jorge-romero Jan 30, 2026
f439ce3
refactor: remove unused commands and requests for AAP and OCP services
jorge-romero Feb 2, 2026
8f5823f
chore: update Spring Boot version to 3.5.10 in pom.xml
jorge-romero Feb 2, 2026
32d273f
chore: Change version
jorge-romero Feb 2, 2026
82609e6
feat: implement TriggerBuildCommand and TriggerBuildRequest with inte…
jorge-romero Feb 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ target/

# NetBeans files
nbproject/private/
build/
nbbuild/
/build**
/nbbuild/**
dist/
nbdist/
.nb-gradle/
Expand Down
2 changes: 1 addition & 1 deletion api-project-platform/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opendevstack.apiservice</groupId>
<artifactId>devstack-api-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.2-SNAPSHOT</version>
</parent>

<artifactId>api-project-platform</artifactId>
Expand Down
5 changes: 1 addition & 4 deletions api-project-users/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opendevstack.apiservice</groupId>
<artifactId>devstack-api-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.2-SNAPSHOT</version>
</parent>

<artifactId>api-project-users</artifactId>
Expand Down Expand Up @@ -50,17 +50,14 @@
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.12.3</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.12.3</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.12.3</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.HttpMediaTypeNotSupportedException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.MissingPathVariableException;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import org.springframework.web.servlet.NoHandlerFoundException;
import org.opendevstack.apiservice.externalservice.aap.exception.AutomationPlatformException;

import java.util.ArrayList;
Expand Down Expand Up @@ -164,6 +168,82 @@ public ResponseEntity<BaseApiResponse> handleHttpMessageNotReadableException(
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(errorResponse);
}

/**
* Handles unsupported media type exceptions (wrong Content-Type header).
*/
@ExceptionHandler(HttpMediaTypeNotSupportedException.class)
public ResponseEntity<BaseApiResponse> handleHttpMediaTypeNotSupportedException(
HttpMediaTypeNotSupportedException ex) {

logger.warn("Unsupported media type: {}", ex.getMessage());

String supportedTypes = ex.getSupportedMediaTypes().stream()
.map(MediaType::toString)
.collect(Collectors.joining(", "));

String errorMessage = String.format(
"Content type '%s' is not supported. Supported media types are: %s",
ex.getContentType() != null ? ex.getContentType() : "unknown",
supportedTypes);

BaseApiResponse errorResponse = new BaseApiResponse();
errorResponse.setSuccess(false);
errorResponse.setMessage(errorMessage);
errorResponse.setError(ErrorCodes.PROJECT_USER_ERROR);
errorResponse.setTimestamp(java.time.OffsetDateTime.now());
return ResponseEntity.status(HttpStatus.UNSUPPORTED_MEDIA_TYPE).body(errorResponse);
}

/**
* Handles unsupported HTTP method exceptions (wrong HTTP method used).
*/
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public ResponseEntity<BaseApiResponse> handleHttpRequestMethodNotSupportedException(
HttpRequestMethodNotSupportedException ex) {

logger.warn("Unsupported HTTP method: {}", ex.getMessage());

String supportedMethods = ex.getSupportedHttpMethods() != null
? ex.getSupportedHttpMethods().stream()
.map(Object::toString)
.collect(Collectors.joining(", "))
: "unknown";

String errorMessage = String.format(
"HTTP method '%s' is not supported for this endpoint. Supported methods are: %s",
ex.getMethod(),
supportedMethods);

BaseApiResponse errorResponse = new BaseApiResponse();
errorResponse.setSuccess(false);
errorResponse.setMessage(errorMessage);
errorResponse.setError(ErrorCodes.PROJECT_USER_ERROR);
errorResponse.setTimestamp(java.time.OffsetDateTime.now());
return ResponseEntity.status(HttpStatus.METHOD_NOT_ALLOWED).body(errorResponse);
}

/**
* Handles no handler found exceptions (endpoint does not exist).
*/
@ExceptionHandler(NoHandlerFoundException.class)
public ResponseEntity<BaseApiResponse> handleNoHandlerFoundException(
NoHandlerFoundException ex) {

logger.warn("No endpoint found: {}", ex.getMessage());

String errorMessage = String.format(
"No endpoint '%s %s' found",
ex.getHttpMethod(),
ex.getRequestURL());

BaseApiResponse errorResponse = new BaseApiResponse();
errorResponse.setSuccess(false);
errorResponse.setMessage(errorMessage);
errorResponse.setError(ErrorCodes.PROJECT_USER_ERROR);
errorResponse.setTimestamp(java.time.OffsetDateTime.now());
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(errorResponse);
}

/**
* Handles missing path variable exceptions.
*/
Expand Down Expand Up @@ -306,6 +386,22 @@ public ResponseEntity<BaseApiResponse> handleInvalidRoleException(
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(errorResponse);
}

/**
* Handles invalid token exceptions.
*/
@ExceptionHandler(InvalidTokenException.class)
public ResponseEntity<BaseApiResponse> handleInvalidTokenException(
InvalidTokenException ex) {

logger.warn("Invalid token: {}", ex.getMessage());
BaseApiResponse errorResponse = new BaseApiResponse();
errorResponse.setSuccess(false);
errorResponse.setMessage(ex.getMessage());
errorResponse.setError(ex.getErrorCode());
errorResponse.setTimestamp(java.time.OffsetDateTime.now());
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(errorResponse);
}

/**
* Handles automation platform exceptions.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package org.opendevstack.apiservice.projectusers.exception;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
* Exception thrown when an invalid token is provided.
*/
@ResponseStatus(HttpStatus.BAD_REQUEST)
public class InvalidTokenException extends ProjectUserException {
public InvalidTokenException(String message) {
super(message, ErrorCodes.INVALID_TOKEN);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.opendevstack.apiservice.projectusers.service.impl;

import org.opendevstack.apiservice.externalservice.aap.command.ExecuteWorkflowRequest;
import org.opendevstack.apiservice.externalservice.aap.model.AutomationExecutionResult;
import org.opendevstack.apiservice.externalservice.aap.service.AutomationPlatformService;
import org.opendevstack.apiservice.externalservice.commons.command.ExternalServiceCommand;
import org.opendevstack.apiservice.externalservice.commons.registry.ExternalServiceRegistry;
import org.opendevstack.apiservice.projectusers.exception.AutomationPlatformException;
import org.opendevstack.apiservice.projectusers.exception.ProjectNotFoundException;
import org.opendevstack.apiservice.projectusers.model.AddUserToProjectRequest;
Expand All @@ -17,7 +19,7 @@

/**
* Implementation of ProjectUserService that manages project users and integrates with automation platform.
* This is a stateless implementation that uses the automation platform for persistence.
* This is a stateless implementation that uses the automation platform for persistence via command pattern.
*/
@Service("projectUserService")
public class ProjectUserServiceImpl implements ProjectUserService {
Expand All @@ -27,12 +29,12 @@ public class ProjectUserServiceImpl implements ProjectUserService {
@Value("${apis.project-users.ansible-workflow-name}")
private String addUserWorkflow;

private final AutomationPlatformService automationPlatformService;
private final ExternalServiceRegistry registry;
private final MembershipRequestTokenService tokenService;

public ProjectUserServiceImpl(AutomationPlatformService automationPlatformService,
public ProjectUserServiceImpl(ExternalServiceRegistry registry,
MembershipRequestTokenService membershipRequestTokenService) {
this.automationPlatformService = automationPlatformService;
this.registry = registry;
this.tokenService = membershipRequestTokenService;
}

Expand All @@ -59,8 +61,23 @@ public MembershipRequestResponse addUserToProject(String projectKey, AddUserToPr
parameters.put("comments", request.getComments());
parameters.put("reference", uipathReference);

// Execute workflow on automation platform
AutomationExecutionResult result = automationPlatformService.executeWorkflow(addUserWorkflow, parameters);
// Execute workflow via command pattern
ExternalServiceCommand<ExecuteWorkflowRequest, AutomationExecutionResult> command =
registry.getCommand("aap", "execute-workflow");

if (command == null) {
throw new AutomationPlatformException(
"Execute workflow command not found for automation platform service", null);
}

// Create the proper request object
ExecuteWorkflowRequest workflowRequest = ExecuteWorkflowRequest.builder()
.workflowName(addUserWorkflow)
.parameters(parameters)
.async(false)
.build();

AutomationExecutionResult result = command.execute(workflowRequest);

if (result.isSuccessful()) {
// Create request token for status tracking
Expand Down Expand Up @@ -95,7 +112,7 @@ public MembershipRequestResponse addUserToProject(String projectKey, AddUserToPr
"Failed to add user through automation platform: " + result.getMessage(), null);
}

} catch (org.opendevstack.apiservice.externalservice.aap.exception.AutomationPlatformException e) {
} catch (Exception e) {
logger.error("Failed to add user '{}' to project '{}': {}", request.getUser(), projectKey, e.getMessage(), e);
throw new AutomationPlatformException(
"Automation platform execution failed", e);
Expand Down
Loading
Loading