mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-19 12:15:28 +00:00
renam bundle from com.sap.sailing.debranding to com.sap.sse.debranding
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1 @@
|
||||
/bin
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.sap.sse.debranding</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,15 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
@@ -0,0 +1,15 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: debranding
|
||||
Bundle-SymbolicName: com.sap.sse.debranding
|
||||
Automatic-Module-Name: com.sap.sse.debranding
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: SAP
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Import-Package: javax.servlet;version="3.1.0",
|
||||
javax.servlet.http;version="3.1.0",
|
||||
org.apache.http
|
||||
Bundle-ClassPath: .
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Require-Bundle: org.apache.commons.io
|
||||
Export-Package: com.sap.sse.debranding
|
||||
@@ -0,0 +1,4 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<artifactId>root</artifactId>
|
||||
<groupId>com.sap.sailing</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>com.sap.sse.debranding</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
package com.sap.sse.debranding;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.HttpStatus;
|
||||
|
||||
/**
|
||||
* Use ${[variable name]} to get strings replaced within static pages.
|
||||
* These variables are available at the moment:
|
||||
* <table border="1">
|
||||
* <tr>
|
||||
* <th>Variablename</th>
|
||||
* <th>branded value</th>
|
||||
* <th>debranded/whitelabeled</th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>SAP</td>
|
||||
* <td>SAP </td>
|
||||
* <td></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>faviconPath</td>
|
||||
* <td>images/sap.ico</td>
|
||||
* <td>images/whitelabel.ico</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>appiconPath</td>
|
||||
* <td>images/sap-sailing-app-icon.png</td>
|
||||
* <td>images/sailing-app-icon.png</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>debrandingActive</td>
|
||||
* <td>false</td>
|
||||
* <td>true</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>saplogoBrowserInfo</td>
|
||||
* <td>{@code <a class="sapLogo" href="http://www.sap.com"><img class="sapLogoImage" src="/images/logo-small@2x.png" alt="SAP Website"/></a>}</td>
|
||||
* <td></td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* @see com.sap.sailing.server.gateway.test.support.WhitelabelSwitchServlet
|
||||
* @author Georg Herdt
|
||||
*
|
||||
*/
|
||||
public class ClientConfigurationServlet extends HttpServlet {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ClientConfigurationServlet.class.getName());
|
||||
|
||||
/** serial version uid */
|
||||
private static final long serialVersionUID = -2228462977010198686L;
|
||||
|
||||
public static final String DEBRANDING_PROPERTY_NAME = "com.sap.sse.debranding";
|
||||
|
||||
private final ConcurrentHashMap<String, byte[]> cache = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
final boolean deBrandingActive = Boolean.valueOf(System.getProperty(DEBRANDING_PROPERTY_NAME, "false"));
|
||||
final String servletPath = req.getServletPath();
|
||||
byte[] cachedPage = null;
|
||||
if ((cachedPage = cache.get(generateKey(servletPath, deBrandingActive))) != null) {
|
||||
IOUtils.write(cachedPage, resp.getOutputStream());
|
||||
return;
|
||||
}
|
||||
try (InputStream in = this.getServletContext().getResourceAsStream(servletPath);) {
|
||||
byte[] buffer = IOUtils.toByteArray(in);
|
||||
|
||||
String content = new String(buffer);
|
||||
for (Map.Entry<String, String> item : createReplacementMap(deBrandingActive).entrySet()) {
|
||||
content = content.replace("${" + item.getKey() + "}", item.getValue());
|
||||
}
|
||||
|
||||
byte[] bytes = content.getBytes();
|
||||
IOUtils.write(bytes, resp.getOutputStream());
|
||||
cache.computeIfAbsent(generateKey(servletPath, deBrandingActive), key -> bytes);
|
||||
} catch (RuntimeException e) {
|
||||
logger.log(Level.WARNING, "could not process or read resource " + servletPath, e);
|
||||
resp.sendError(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
private String generateKey(String servletPath, boolean active) {
|
||||
return servletPath + "_" + active;
|
||||
}
|
||||
|
||||
private Map<String,String> createReplacementMap(boolean deBrandingActive) {
|
||||
final Map<String,String> map = new HashMap<>();
|
||||
final String title;
|
||||
final String faviconPath;
|
||||
final String appiconPath;
|
||||
final String saplogoBrowserInfo;
|
||||
final String ribDashboardIcon;
|
||||
if (deBrandingActive) {
|
||||
title = "";
|
||||
faviconPath = "images/whitelabel.ico";
|
||||
appiconPath = "images/sailing-app-icon.png";
|
||||
saplogoBrowserInfo = "";
|
||||
ribDashboardIcon = "images/dashboardicon-whitelabeled.png";
|
||||
} else {
|
||||
title = "SAP ";
|
||||
faviconPath = "images/sap.ico";
|
||||
appiconPath = "images/sap-sailing-app-icon.png";
|
||||
saplogoBrowserInfo = "<a class=\"sapLogo\" href=\"http://www.sap.com\"><img class=\"sapLogoImage\" src=\"/images/logo-small@2x.png\" alt=\"SAP Website\"/></a>\r\n";
|
||||
ribDashboardIcon = "images/dashboardicon.png";
|
||||
}
|
||||
map.put("SAP", title);
|
||||
map.put("faviconPath", faviconPath);
|
||||
map.put("appiconPath", appiconPath);
|
||||
map.put("debrandingActive", Boolean.toString(deBrandingActive));
|
||||
map.put("saplogoBrowserInfo", saplogoBrowserInfo);
|
||||
map.put("ribDashboardIcon", ribDashboardIcon);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user