ProductInfoConsolePlugin.java
5.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.servlet.Servlet
* javax.servlet.http.HttpServletRequest
* javax.servlet.http.HttpServletResponse
* org.apache.commons.lang3.StringEscapeUtils
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.ConfigurationPolicy
* org.apache.felix.scr.annotations.Property
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.Service
* org.apache.felix.webconsole.BrandingPlugin
* org.apache.felix.webconsole.ConfigurationPrinter
* org.apache.felix.webconsole.SimpleWebConsolePlugin
* org.osgi.framework.Version
*/
package com.adobe.granite.license.impl;
import com.adobe.granite.license.License;
import com.adobe.granite.license.ProductInfo;
import com.adobe.granite.license.ProductInfoService;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.Servlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.ConfigurationPolicy;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.felix.webconsole.BrandingPlugin;
import org.apache.felix.webconsole.ConfigurationPrinter;
import org.apache.felix.webconsole.SimpleWebConsolePlugin;
import org.osgi.framework.Version;
@Component(policy=ConfigurationPolicy.IGNORE)
@Service(value={Servlet.class, BrandingPlugin.class, ConfigurationPrinter.class})
public class ProductInfoConsolePlugin
extends SimpleWebConsolePlugin
implements BrandingPlugin,
ConfigurationPrinter {
@Property(name="felix.webconsole.label")
private static final String LABEL = "productinfo";
@Property(name="felix.webconsole.title")
private static final String TITLE = "Product Information";
@Reference
private ProductInfoService productInfo;
public ProductInfoConsolePlugin() {
super("productinfo", "Product Information", null);
}
protected void renderContent(HttpServletRequest req, HttpServletResponse res) throws IOException {
License license = this.productInfo.getLicense();
ProductInfo[] infos = this.productInfo.getInfos();
PrintWriter pw = res.getWriter();
Object[] arrobject = new Object[1];
arrobject[0] = infos == null || infos.length == 0 ? "None" : Integer.valueOf(infos.length);
pw.printf("<p class='statline ui-state-highlight'>Installed Products: %s</p>%n", arrobject);
pw.println("<table class='nicetable ui-widget'>");
pw.printf("<tr><th colspan='2' class='ui-widget-header'>License</th></tr>", new Object[0]);
if (license != null) {
pw.printf("<tr><td>Customer</td><td>%s</td></tr>", StringEscapeUtils.escapeHtml4((String)license.getCustomerName()));
pw.printf("<tr><td>Download ID</td><td>%s</td></tr>", license.getDownloadId());
pw.printf("<tr><td>Product</td><td>%s (%s)</td></tr>", license.getProductName(), license.getProductVersion());
} else {
pw.printf("<tr><td colspan='2'>No License configured !</td></tr>", new Object[0]);
}
pw.println("</table>");
pw.println("<p> </p>");
pw.println("<table class='nicetable ui-widget'>");
pw.printf("<tr><th class='ui-widget-header'>Installed Products</th></tr>", new Object[0]);
if (infos == null) {
pw.printf("<tr><td>None</td></tr>", new Object[0]);
} else {
for (ProductInfo info : infos) {
pw.printf("<tr><td>%s (%s)</td></tr>", new Object[]{info.getName(), info.getVersion()});
}
}
pw.println("</table>");
}
public void printConfiguration(PrintWriter pw) {
License license = this.productInfo.getLicense();
pw.println("License");
pw.printf(" Customer: %s%n", license.getCustomerName());
pw.printf(" Download ID: %s%n", license.getDownloadId());
pw.printf(" Product : %s (%s)%n", license.getProductName(), license.getProductVersion());
pw.println();
pw.println("Installed Products");
ProductInfo[] infos = this.productInfo.getInfos();
if (infos == null) {
pw.printf("None%n", new Object[0]);
} else {
for (ProductInfo info : infos) {
pw.printf(" %s (%s)%n", new Object[]{info.getName(), info.getVersion()});
}
}
}
public String getBrandName() {
ProductInfo[] infos = this.productInfo.getInfos();
return infos != null && infos.length > 0 ? infos[0].getName() + " Web Console" : "Web Console";
}
public String getProductName() {
return this.getBrandName();
}
public String getProductURL() {
return "http://www.adobe.com";
}
public String getProductImage() {
return "/" + this.getLabel() + "/res/granite/logo.gif";
}
public String getVendorName() {
return "Adobe Systems";
}
public String getVendorURL() {
return "http://www.adobe.com";
}
public String getVendorImage() {
return "/" + this.getLabel() + "/res/granite/logo.gif";
}
public String getFavIcon() {
return "/" + this.getLabel() + "/res/granite/favicon.ico";
}
public String getMainStyleSheet() {
return "/" + this.getLabel() + "/res/granite/webconsole.css";
}
protected void bindProductInfo(ProductInfoService productInfoService) {
this.productInfo = productInfoService;
}
protected void unbindProductInfo(ProductInfoService productInfoService) {
if (this.productInfo == productInfoService) {
this.productInfo = null;
}
}
}