Compare commits

...

7 Commits

Author SHA1 Message Date
Anthony Stirling
63eacf443e Merge pull request #610 from Frooodle/fix
required false
2023-12-30 02:20:34 +00:00
Anthony Stirling
b32c28e9cb Update build.gradle 2023-12-30 02:20:16 +00:00
Anthony Stirling
a5ee10e029 required flase 2023-12-30 02:19:30 +00:00
Anthony Stirling
bb1d41d74a Merge pull request #605 from Frooodle/expose-port
refactor: expose local application server port
2023-12-29 23:27:59 +00:00
sbplat
34b4ae0e03 refactor: reflect changes to pipeline release 2023-12-29 17:13:36 -05:00
sbplat
036fd711f9 Merge branch 'main' into expose-port 2023-12-29 17:01:49 -05:00
sbplat
94aba370e0 refactor: expose local application server port 2023-12-29 13:05:01 -05:00
4 changed files with 35 additions and 31 deletions

View File

@@ -8,7 +8,7 @@ plugins {
} }
group = 'stirling.software' group = 'stirling.software'
version = '0.18.0' version = '0.18.1'
sourceCompatibility = '17' sourceCompatibility = '17'
repositories { repositories {

View File

@@ -29,11 +29,7 @@ public class SPdfApplication {
if (browserOpen) { if (browserOpen) {
try { try {
String port = env.getProperty("local.server.port"); String url = "http://localhost:" + getPort();
if(port == null || port.length() == 0) {
port="8080";
}
String url = "http://localhost:" + port;
String os = System.getProperty("os.name").toLowerCase(); String os = System.getProperty("os.name").toLowerCase();
Runtime rt = Runtime.getRuntime(); Runtime rt = Runtime.getRuntime();
@@ -67,17 +63,17 @@ public class SPdfApplication {
GeneralUtils.createDir("customFiles/static/"); GeneralUtils.createDir("customFiles/static/");
GeneralUtils.createDir("customFiles/templates/"); GeneralUtils.createDir("customFiles/templates/");
System.out.println("Stirling-PDF Started."); System.out.println("Stirling-PDF Started.");
String port = System.getProperty("local.server.port"); String url = "http://localhost:" + getPort();
if(port == null || port.length() == 0) {
port="8080";
}
String url = "http://localhost:" + port;
System.out.println("Navigate to " + url); System.out.println("Navigate to " + url);
} }
public static String getPort() {
String port = System.getProperty("local.server.port");
if (port == null || port.isEmpty()) {
port = "8080";
}
return port;
}
} }

View File

@@ -4,6 +4,7 @@ import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
@@ -16,22 +17,24 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.ServletContext; import jakarta.servlet.ServletContext;
import stirling.software.SPDF.SPdfApplication;
import stirling.software.SPDF.model.ApiEndpoint; import stirling.software.SPDF.model.ApiEndpoint;
import stirling.software.SPDF.model.Role; import stirling.software.SPDF.model.Role;
import org.slf4j.Logger;
@Service @Service
public class ApiDocService { public class ApiDocService {
private final Map<String, ApiEndpoint> apiDocumentation = new HashMap<>(); private final Map<String, ApiEndpoint> apiDocumentation = new HashMap<>();
private static final Logger logger = LoggerFactory.getLogger(ApiDocService.class);
@Autowired @Autowired
private ServletContext servletContext; private ServletContext servletContext;
private String getApiDocsUrl() { private String getApiDocsUrl() {
String contextPath = servletContext.getContextPath(); String contextPath = servletContext.getContextPath();
String port = System.getProperty("local.server.port"); String port = SPdfApplication.getPort();
if(port == null || port.length() == 0) {
port="8080";
}
return "http://localhost:"+ port + contextPath + "/v1/api-docs"; return "http://localhost:"+ port + contextPath + "/v1/api-docs";
} }
@@ -51,6 +54,7 @@ public class ApiDocService {
//@EventListener(ApplicationReadyEvent.class) //@EventListener(ApplicationReadyEvent.class)
private synchronized void loadApiDocumentation() { private synchronized void loadApiDocumentation() {
String apiDocsJson = "";
try { try {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
String apiKey = getApiKeyForUser(); String apiKey = getApiKeyForUser();
@@ -61,7 +65,7 @@ public class ApiDocService {
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> response = restTemplate.exchange(getApiDocsUrl(), HttpMethod.GET, entity, String.class); ResponseEntity<String> response = restTemplate.exchange(getApiDocsUrl(), HttpMethod.GET, entity, String.class);
String apiDocsJson = response.getBody(); apiDocsJson = response.getBody();
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
apiDocsJsonRootNode = mapper.readTree(apiDocsJson); apiDocsJsonRootNode = mapper.readTree(apiDocsJson);
@@ -78,7 +82,7 @@ public class ApiDocService {
}); });
} catch (Exception e) { } catch (Exception e) {
// Handle exceptions // Handle exceptions
e.printStackTrace(); logger.error("Error grabbing swagger doc, body result {}", apiDocsJson);
} }
} }

View File

@@ -34,6 +34,8 @@ import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import jakarta.servlet.ServletContext; import jakarta.servlet.ServletContext;
import stirling.software.SPDF.SPdfApplication;
import stirling.software.SPDF.model.PipelineConfig; import stirling.software.SPDF.model.PipelineConfig;
import stirling.software.SPDF.model.PipelineOperation; import stirling.software.SPDF.model.PipelineOperation;
import stirling.software.SPDF.model.Role; import stirling.software.SPDF.model.Role;
@@ -47,7 +49,7 @@ public class PipelineProcessor {
@Autowired @Autowired
private ApiDocService apiDocService; private ApiDocService apiDocService;
@Autowired @Autowired(required=false)
private UserServiceInterface userService; private UserServiceInterface userService;
@Autowired @Autowired
@@ -65,7 +67,9 @@ public class PipelineProcessor {
private String getBaseUrl() { private String getBaseUrl() {
String contextPath = servletContext.getContextPath(); String contextPath = servletContext.getContextPath();
return "http://localhost:8080" + contextPath + "/"; String port = SPdfApplication.getPort();
return "http://localhost:" + port + contextPath + "/";
} }