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'
version = '0.18.0'
version = '0.18.1'
sourceCompatibility = '17'
repositories {

View File

@@ -17,7 +17,7 @@ import stirling.software.SPDF.utils.GeneralUtils;
@EnableScheduling
public class SPdfApplication {
@Autowired
private Environment env;
@@ -29,11 +29,7 @@ public class SPdfApplication {
if (browserOpen) {
try {
String port = env.getProperty("local.server.port");
if(port == null || port.length() == 0) {
port="8080";
}
String url = "http://localhost:" + port;
String url = "http://localhost:" + getPort();
String os = System.getProperty("os.name").toLowerCase();
Runtime rt = Runtime.getRuntime();
@@ -46,7 +42,7 @@ public class SPdfApplication {
}
}
}
public static void main(String[] args) {
SpringApplication app = new SpringApplication(SPdfApplication.class);
app.addInitializers(new ConfigInitializer());
@@ -56,28 +52,28 @@ public class SPdfApplication {
System.out.println("External configuration file 'configs/settings.yml' does not exist. Using default configuration and environment configuration instead.");
}
app.run(args);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
GeneralUtils.createDir("customFiles/static/");
GeneralUtils.createDir("customFiles/templates/");
System.out.println("Stirling-PDF Started.");
String port = System.getProperty("local.server.port");
if(port == null || port.length() == 0) {
port="8080";
}
String url = "http://localhost:" + port;
String url = "http://localhost:" + getPort();
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.Pattern;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
@@ -16,23 +17,25 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.ServletContext;
import stirling.software.SPDF.SPdfApplication;
import stirling.software.SPDF.model.ApiEndpoint;
import stirling.software.SPDF.model.Role;
import org.slf4j.Logger;
@Service
public class ApiDocService {
private final Map<String, ApiEndpoint> apiDocumentation = new HashMap<>();
private static final Logger logger = LoggerFactory.getLogger(ApiDocService.class);
@Autowired
private ServletContext servletContext;
private String getApiDocsUrl() {
String contextPath = servletContext.getContextPath();
String port = System.getProperty("local.server.port");
if(port == null || port.length() == 0) {
port="8080";
}
String port = SPdfApplication.getPort();
return "http://localhost:"+ port + contextPath + "/v1/api-docs";
}
@@ -51,6 +54,7 @@ public class ApiDocService {
//@EventListener(ApplicationReadyEvent.class)
private synchronized void loadApiDocumentation() {
String apiDocsJson = "";
try {
HttpHeaders headers = new HttpHeaders();
String apiKey = getApiKeyForUser();
@@ -61,7 +65,7 @@ public class ApiDocService {
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> response = restTemplate.exchange(getApiDocsUrl(), HttpMethod.GET, entity, String.class);
String apiDocsJson = response.getBody();
apiDocsJson = response.getBody();
ObjectMapper mapper = new ObjectMapper();
apiDocsJsonRootNode = mapper.readTree(apiDocsJson);
@@ -78,7 +82,7 @@ public class ApiDocService {
});
} catch (Exception e) {
// 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 jakarta.servlet.ServletContext;
import stirling.software.SPDF.SPdfApplication;
import stirling.software.SPDF.model.PipelineConfig;
import stirling.software.SPDF.model.PipelineOperation;
import stirling.software.SPDF.model.Role;
@@ -47,7 +49,7 @@ public class PipelineProcessor {
@Autowired
private ApiDocService apiDocService;
@Autowired
@Autowired(required=false)
private UserServiceInterface userService;
@Autowired
@@ -65,7 +67,9 @@ public class PipelineProcessor {
private String getBaseUrl() {
String contextPath = servletContext.getContextPath();
return "http://localhost:8080" + contextPath + "/";
String port = SPdfApplication.getPort();
return "http://localhost:" + port + contextPath + "/";
}