-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
License list moved to the main plugin
- Loading branch information
Showing
7 changed files
with
270 additions
and
1 deletion.
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
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
74 changes: 74 additions & 0 deletions
74
openedge-plugin/src/main/java/org/sonar/plugins/openedge/web/OpenEdgeWebService.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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* OpenEdge plugin for SonarQube | ||
* Copyright (C) 2013-2020 Riverside Software | ||
* contact AT riverside DASH software DOT fr | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 | ||
*/ | ||
package org.sonar.plugins.openedge.web; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.ZoneOffset; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.Base64; | ||
|
||
import org.sonar.api.server.ws.Request; | ||
import org.sonar.api.server.ws.RequestHandler; | ||
import org.sonar.api.server.ws.Response; | ||
import org.sonar.api.server.ws.WebService; | ||
import org.sonar.api.utils.text.JsonWriter; | ||
import org.sonar.plugins.openedge.api.LicenseRegistration.License; | ||
import org.sonar.plugins.openedge.foundation.OpenEdgeComponents; | ||
|
||
public class OpenEdgeWebService implements WebService { | ||
private final OpenEdgeComponents components; | ||
|
||
public OpenEdgeWebService(OpenEdgeComponents components) { | ||
this.components = components; | ||
} | ||
|
||
@Override | ||
public void define(Context context) { | ||
NewController controller = context.createController("api/openedge").setDescription("OpenEdge plugin web service"); | ||
controller.createAction("licenses").setDescription("Licenses list").setHandler( | ||
new LicenseRequestHandler()).setSince("2.0.3").setResponseExample( | ||
getClass().getResource("/org/sonar/openedge-licenses-response-example.json")); | ||
controller.done(); | ||
} | ||
|
||
private class LicenseRequestHandler implements RequestHandler { | ||
|
||
@Override | ||
public void handle(Request request, Response response) throws Exception { | ||
try (JsonWriter writer = response.newJsonWriter()) { | ||
writer.beginObject().name("licenses").beginArray(); | ||
for (License lic : components.getLicenses()) { | ||
writer.beginObject() // | ||
.prop("permanentId", lic.getPermanentId()) // | ||
.prop("product", lic.getProduct().toString()) // | ||
.prop("customer", lic.getCustomerName()) // | ||
.prop("repository", lic.getRepositoryName()) // | ||
.prop("type", lic.getType().name()) // | ||
.prop("signature", Base64.getEncoder().encodeToString(lic.getSig())) // | ||
.prop("expiration", LocalDateTime.ofEpochSecond(lic.getExpirationDate() / 1000, 0, ZoneOffset.UTC).format( | ||
DateTimeFormatter.ISO_LOCAL_DATE_TIME)) // | ||
.endObject(); | ||
} | ||
writer.endArray().endObject(); | ||
} | ||
} | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
openedge-plugin/src/main/java/org/sonar/plugins/openedge/web/UiPageDefinition.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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* OpenEdge plugin for SonarQube | ||
* Copyright (C) 2013-2020 Riverside Software | ||
* contact AT riverside DASH software DOT fr | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 | ||
*/ | ||
package org.sonar.plugins.openedge.web; | ||
|
||
import org.sonar.api.web.page.Context; | ||
import org.sonar.api.web.page.Page; | ||
import org.sonar.api.web.page.PageDefinition; | ||
|
||
public class UiPageDefinition implements PageDefinition { | ||
@Override | ||
public void define(Context context) { | ||
context.addPage(Page.builder("openedge/license_recap").setName("OpenEdge rules licenses").setAdmin(true).build()); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
openedge-plugin/src/main/resources/org/sonar/openedge-licenses-response-example.json
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,20 @@ | ||
{ | ||
"licenses": [ | ||
{ | ||
"permanentId": "123456789", | ||
"customer": "Riverside Software", | ||
"repository": "rssw-oe-main", | ||
"type": "COMMERCIAL", | ||
"signature": "Base64SignatureHere", | ||
"expiration": "2039-12-31T23:00:00" | ||
}, | ||
{ | ||
"permanentId": "sonarlint-123456789", | ||
"customer": "Riverside Software", | ||
"repository": "rssw-oe-main", | ||
"type": "COMMERCIAL", | ||
"signature": "Base64SignatureHere", | ||
"expiration": "2039-12-31T23:00:00" | ||
} | ||
] | ||
} |
127 changes: 127 additions & 0 deletions
127
openedge-plugin/src/main/resources/static/license_recap.js
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,127 @@ | ||
window.registerExtension('openedge/license_recap', function (options) { | ||
var isDisplayed = true; | ||
window.SonarRequest.getJSON('/api/openedge/licenses', { }).then(function (response) { | ||
if (isDisplayed) { | ||
options.el.className = 'page page-limited'; | ||
|
||
var header = document.createElement('h1'); | ||
header.textContent = 'CABL rules • Licenses'; | ||
options.el.appendChild(header); | ||
|
||
var tbl = document.createElement('table'); | ||
tbl.className = 'data zebra zebra-hover'; | ||
tbl.style.cssText = 'table-layout: fixed;'; | ||
options.el.appendChild(tbl); | ||
|
||
var thead = document.createElement('thead'); | ||
tbl.appendChild(thead); | ||
var theadLine = document.createElement('tr'); | ||
thead.appendChild(theadLine); | ||
|
||
var theadCol = document.createElement('th'); | ||
theadCol.textContent = 'Company name'; | ||
theadLine.appendChild(theadCol); | ||
|
||
theadCol = document.createElement('th'); | ||
theadCol.textContent = 'Server ID'; | ||
theadCol.width = 200 | ||
theadLine.appendChild(theadCol); | ||
|
||
theadCol = document.createElement('th'); | ||
theadCol.textContent = 'Product'; | ||
theadCol.width = 150 | ||
theadLine.appendChild(theadCol); | ||
|
||
theadCol = document.createElement('th'); | ||
theadCol.textContent = 'Repository'; | ||
theadCol.width = 130 | ||
theadLine.appendChild(theadCol); | ||
|
||
theadCol = document.createElement('th'); | ||
theadCol.textContent = 'Expiration'; | ||
theadCol.width = 200 | ||
theadLine.appendChild(theadCol); | ||
|
||
var bdy = document.createElement('tbody'); | ||
tbl.appendChild(bdy); | ||
|
||
for (var i = 0; i < response.licenses.length ; i++) { | ||
var ln = document.createElement('tr'); | ||
bdy.appendChild(ln); | ||
|
||
var fld1 = document.createElement('td'); | ||
fld1.textContent = response.licenses[i].customer; | ||
ln.appendChild(fld1); | ||
|
||
var fld2 = document.createElement('td'); | ||
fld2.textContent = response.licenses[i].permanentId; | ||
ln.appendChild(fld2); | ||
|
||
var fld3 = document.createElement('td'); | ||
fld3.textContent = response.licenses[i].product; | ||
ln.appendChild(fld3); | ||
|
||
var fld4 = document.createElement('td'); | ||
fld4.textContent = response.licenses[i].repository; | ||
ln.appendChild(fld4); | ||
|
||
var fld5 = document.createElement('td'); | ||
fld5.textContent = response.licenses[i].expiration; | ||
ln.appendChild(fld5); | ||
} | ||
|
||
var hr1 = document.createElement('hr'); | ||
hr1.style.cssText = 'height: 8px; margin-top: 10px; margin-bottom: 10px;'; | ||
options.el.appendChild(hr1); | ||
var header2 = document.createElement('h1'); | ||
header2.textContent = 'CABL rules • Request new license'; | ||
options.el.appendChild(header2); | ||
|
||
var tbl2 = document.createElement('table'); | ||
options.el.appendChild(tbl2); | ||
var bdy2 = document.createElement('tbody'); | ||
tbl2.appendChild(bdy2); | ||
|
||
var ln4 = document.createElement('tr'); | ||
bdy2.appendChild(ln4); | ||
var col3 = document.createElement('td'); | ||
col3.style.cssText = 'padding: 10px;'; | ||
ln4.appendChild(col3); | ||
|
||
var ln2 = document.createElement('tr'); | ||
bdy2.appendChild(ln2); | ||
var col1 = document.createElement('td'); | ||
col1.style.cssText = 'padding: 10px;'; | ||
col1.innerHTML = 'Your CABL licenses can be managed at <a href="https://cabl.riverside-software.fr">https://cabl.riverside-software.fr</a>. '; | ||
ln2.appendChild(col1); | ||
var ln3 = document.createElement('tr'); | ||
bdy2.appendChild(ln3); | ||
var col2 = document.createElement('td'); | ||
col2.style.cssText = 'padding: 10px;'; | ||
ln3.appendChild(col2); | ||
var pre2 = document.createElement('pre'); | ||
pre2.id = 'cabl-input'; | ||
pre2.style.cssText = 'width: 600px; overflow: auto; background-color: #bbbbbb; border: 1px solid #898989; padding: 5px; white-space: pre-wrap; '; | ||
col2.appendChild(pre2); | ||
var code2 = document.createElement('code'); | ||
pre2.appendChild(code2); | ||
|
||
window.SonarRequest.getJSON('/api/riverside/oeinfo', { }).then(function (response) { | ||
code2.textContent = JSON.stringify(response); | ||
|
||
var cablLink = document.createElement('a'); | ||
cablLink.href = 'https://cabl.riverside-software.fr/#/licenses?licenseRequest=' + encodeURI(JSON.stringify(response)); | ||
cablLink.textContent = 'Acquire or renew license for this server'; | ||
cablLink.rel = 'noopener noreferrer'; | ||
cablLink.target = '_blank'; | ||
col3.appendChild(cablLink); | ||
}).catch(function (error) { | ||
code2.textContent = "Riverside Rules plugin is not installed..."; | ||
}); | ||
} | ||
}); | ||
|
||
return function () { | ||
isDisplayed = false; | ||
}; | ||
}); |
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