use of com.liferay.portal.kernel.json.JSONObject in project sw360portal by sw360.
the class ProjectPortlet method updateVulnerabilityRating.
private void updateVulnerabilityRating(ResourceRequest request, ResourceResponse response) throws IOException {
String projectId = request.getParameter(PortalConstants.PROJECT_ID);
User user = UserCacheHolder.getUserFromRequest(request);
VulnerabilityService.Iface vulClient = thriftClients.makeVulnerabilityClient();
RequestStatus requestStatus = RequestStatus.FAILURE;
try {
Optional<ProjectVulnerabilityRating> projectVulnerabilityRatings = wrapThriftOptionalReplacement(vulClient.getProjectVulnerabilityRatingByProjectId(projectId, user));
ProjectVulnerabilityRating link = ProjectPortletUtils.updateProjectVulnerabilityRatingFromRequest(projectVulnerabilityRatings, request);
requestStatus = vulClient.updateProjectVulnerabilityRating(link, user);
} catch (TException e) {
log.error("Error updating vulnerability ratings for project in backend.", e);
}
JSONObject responseData = JSONFactoryUtil.createJSONObject();
responseData.put(PortalConstants.REQUEST_STATUS, requestStatus.toString());
PrintWriter writer = response.getWriter();
writer.write(responseData.toString());
}
use of com.liferay.portal.kernel.json.JSONObject in project sw360portal by sw360.
the class Sw360Portlet method renderRemoveModerationRequestStatus.
protected void renderRemoveModerationRequestStatus(PortletRequest request, MimeResponse response, RemoveModeratorRequestStatus status) {
JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
jsonObject.put("result", status.toString());
try {
writeJSON(request, response, jsonObject);
} catch (IOException e) {
log.error("Problem rendering RemoveModerationRequestStatus", e);
}
}
use of com.liferay.portal.kernel.json.JSONObject in project sw360portal by sw360.
the class BulkReleaseEdit method serveAddVendor.
private void serveAddVendor(ResourceRequest request, ResourceResponse response) throws IOException, PortletException {
final Vendor vendor = new Vendor();
ComponentPortletUtils.updateVendorFromRequest(request, vendor);
try {
VendorService.Iface client = thriftClients.makeVendorClient();
String vendorId = client.addVendor(vendor);
JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
jsonObject.put("id", vendorId);
try {
writeJSON(request, response, jsonObject);
} catch (IOException e) {
log.error("Problem rendering VendorId", e);
}
} catch (TException e) {
log.error("Error adding vendor", e);
}
}
use of com.liferay.portal.kernel.json.JSONObject in project sw360portal by sw360.
the class ComponentPortlet method updateAllVulnerabilities.
private void updateAllVulnerabilities(ResourceRequest request, ResourceResponse response) throws PortletException, IOException {
CveSearchService.Iface cveClient = thriftClients.makeCvesearchClient();
try {
VulnerabilityUpdateStatus importStatus = cveClient.fullUpdate();
JSONObject responseData = PortletUtils.importStatusToJSON(importStatus);
PrintWriter writer = response.getWriter();
writer.write(responseData.toString());
} catch (TException e) {
log.error("Error occurred with full update of CVEs in backend.", e);
}
}
use of com.liferay.portal.kernel.json.JSONObject in project sw360portal by sw360.
the class FossologyAwarePortlet method serveFossologyStatus.
protected void serveFossologyStatus(ResourceRequest request, ResourceResponse response) throws IOException {
DataTablesParameters parameters = DataTablesParser.parametersFrom(request);
Release release = getReleaseForFossologyStatus(request);
Map<String, FossologyStatus> fossologyStatus = getFossologyStatus(release);
JSONObject jsonResponse = JSONFactoryUtil.createJSONObject();
JSONArray data = JSONFactoryUtil.createJSONArray();
for (Map.Entry<String, FossologyStatus> entry : fossologyStatus.entrySet()) {
JSONObject row = JSONFactoryUtil.createJSONObject();
row.put("0", entry.getKey());
row.put("1", ThriftEnumUtils.enumToString(entry.getValue()));
data.put(row);
}
jsonResponse.put("attachment", getFossologyUploadableAttachment(release));
jsonResponse.put("data", data);
jsonResponse.put("draw", parameters.getDraw());
jsonResponse.put("recordsTotal", fossologyStatus.size());
jsonResponse.put("recordsFiltered", fossologyStatus.size());
writeJSON(request, response, jsonResponse);
}
Aggregations