-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: ch.sbb.polarion.extension.generic usage (#36)
- Loading branch information
Showing
67 changed files
with
388 additions
and
2,523 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,5 @@ replay_pid* | |
|
||
target/ | ||
*.iml | ||
hooks/*.iml | ||
dependency-reduced-pom.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
replay_pid* | ||
.idea/* | ||
|
||
# code style config | ||
!.idea/codeStyles | ||
.idea/codeStyles/* | ||
!.idea/codeStyles/Project.xml | ||
!.idea/codeStyles/codeStyleConfig.xml | ||
|
||
target/ | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
replay_pid* | ||
.idea/* | ||
|
||
# code style config | ||
!.idea/codeStyles | ||
.idea/codeStyles/* | ||
!.idea/codeStyles/Project.xml | ||
!.idea/codeStyles/codeStyleConfig.xml | ||
|
||
target/ | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
replay_pid* | ||
.idea/* | ||
|
||
# code style config | ||
!.idea/codeStyles | ||
.idea/codeStyles/* | ||
!.idea/codeStyles/Project.xml | ||
!.idea/codeStyles/codeStyleConfig.xml | ||
|
||
target/ | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
replay_pid* | ||
.idea/* | ||
|
||
# code style config | ||
!.idea/codeStyles | ||
.idea/codeStyles/* | ||
!.idea/codeStyles/Project.xml | ||
!.idea/codeStyles/codeStyleConfig.xml | ||
|
||
target/ | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
replay_pid* | ||
.idea/* | ||
|
||
# code style config | ||
!.idea/codeStyles | ||
.idea/codeStyles/* | ||
!.idea/codeStyles/Project.xml | ||
!.idea/codeStyles/codeStyleConfig.xml | ||
|
||
target/ | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 5 additions & 51 deletions
56
src/main/java/ch/sbb/polarion/extension/interceptor/InterceptorAdminUiServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,14 @@ | ||
package ch.sbb.polarion.extension.interceptor; | ||
|
||
import com.polarion.core.util.logging.Logger; | ||
import org.apache.commons.io.IOUtils; | ||
import org.jetbrains.annotations.NotNull; | ||
import ch.sbb.polarion.extension.generic.GenericUiServlet; | ||
|
||
import javax.servlet.ServletOutputStream; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.Serial; | ||
|
||
public class InterceptorAdminUiServlet extends HttpServlet { | ||
|
||
private static final Logger logger = Logger.getLogger(InterceptorAdminUiServlet.class); | ||
|
||
public class InterceptorAdminUiServlet extends GenericUiServlet { | ||
@Serial | ||
private static final long serialVersionUID = 4323903250755251706L; | ||
private static final String WEB_APP_NAME = "interceptor-admin"; | ||
|
||
private static void setContentType(@NotNull String uri, @NotNull HttpServletResponse response) { | ||
if (uri.endsWith(".js")) { | ||
response.setContentType("text/javascript"); | ||
} else if (uri.endsWith(".html")) { | ||
response.setContentType("text/html"); | ||
} else if (uri.endsWith(".png")) { | ||
response.setContentType("image/png"); | ||
} else if (uri.endsWith(".css")) { | ||
response.setContentType("text/css"); | ||
} | ||
} | ||
|
||
@Override | ||
protected void service(HttpServletRequest request, HttpServletResponse response) { | ||
String uri = request.getRequestURI(); | ||
String relativeUri = uri.substring("/polarion/".length()); | ||
|
||
if (relativeUri.startsWith(WEB_APP_NAME + "/ui/")) { | ||
serveResource(response, relativeUri.substring((WEB_APP_NAME + "/ui").length())); | ||
} | ||
} | ||
|
||
private void serveResource(@NotNull HttpServletResponse response, @NotNull String uri) { | ||
try (InputStream inputStream = getServletContext().getResourceAsStream(uri)) { | ||
private static final long serialVersionUID = 1652935384860901702L; | ||
|
||
if (inputStream == null) { | ||
response.sendError(HttpServletResponse.SC_NOT_FOUND); | ||
} else { | ||
try (ServletOutputStream outputStream = response.getOutputStream()) { | ||
setContentType(uri, response); | ||
IOUtils.copy(inputStream, outputStream); | ||
} | ||
} | ||
} catch (IOException e) { | ||
logger.error(e.getMessage(), e); | ||
} | ||
public InterceptorAdminUiServlet() { | ||
super("interceptor-admin"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.