Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63eacf443e | ||
|
|
b32c28e9cb | ||
|
|
a5ee10e029 | ||
|
|
bb1d41d74a | ||
|
|
34b4ae0e03 | ||
|
|
036fd711f9 | ||
|
|
94aba370e0 |
@@ -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 {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 + "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user