use of org.eclipse.sw360.portal.common.UsedAsLiferayAction in project sw360portal by sw360.
the class ScheduleAdminPortlet method unscheduleCveSearch.
@UsedAsLiferayAction
public void unscheduleCveSearch(ActionRequest request, ActionResponse response) throws PortletException, IOException {
try {
User user = UserCacheHolder.getUserFromRequest(request);
RequestStatus requestStatus = new ThriftClients().makeScheduleClient().unscheduleService(ThriftClients.CVESEARCH_SERVICE, user);
setSessionMessage(request, requestStatus, "Task", "unschedule");
} catch (TException e) {
log.error(e);
}
}
use of org.eclipse.sw360.portal.common.UsedAsLiferayAction in project sw360portal by sw360.
the class VendorPortlet method updateVendor.
@UsedAsLiferayAction
public void updateVendor(ActionRequest request, ActionResponse response) throws PortletException, IOException {
String id = request.getParameter(VENDOR_ID);
final User user = UserCacheHolder.getUserFromRequest(request);
if (id != null) {
try {
VendorService.Iface vendorClient = thriftClients.makeVendorClient();
Vendor vendor = vendorClient.getByID(id);
ComponentPortletUtils.updateVendorFromRequest(request, vendor);
RequestStatus requestStatus = vendorClient.updateVendor(vendor, user);
setSessionMessage(request, requestStatus, "Vendor", "update", vendor.getShortname());
} catch (TException e) {
log.error("Error fetching release from backend!", e);
}
} else {
addVendor(request);
}
}
use of org.eclipse.sw360.portal.common.UsedAsLiferayAction in project sw360portal by sw360.
the class VendorPortlet method removeVendor.
@UsedAsLiferayAction
public void removeVendor(ActionRequest request, ActionResponse response) throws IOException, PortletException {
final RequestStatus requestStatus = ComponentPortletUtils.deleteVendor(request, log);
setSessionMessage(request, requestStatus, "Vendor", "delete");
response.setRenderParameter(PAGENAME, PAGENAME_VIEW);
}
use of org.eclipse.sw360.portal.common.UsedAsLiferayAction in project sw360portal by sw360.
the class ComponentUploadPortlet method updateReleaseLinks.
@UsedAsLiferayAction
public void updateReleaseLinks(ActionRequest request, ActionResponse response) throws PortletException, IOException, TException {
List<CSVRecord> releaseLinkRecords = getCSVFromRequest(request, "file");
FluentIterable<ReleaseLinkCSVRecord> csvRecords = convertCSVRecordsToReleaseLinkCSVRecords(releaseLinkRecords);
log.trace("read records <" + Joiner.on("\n").join(csvRecords) + ">");
final ComponentService.Iface componentClient = thriftClients.makeComponentClient();
User user = UserCacheHolder.getUserFromRequest(request);
final RequestSummary requestSummary = writeReleaseLinksToDatabase(csvRecords, componentClient, user);
renderRequestSummary(request, response, requestSummary);
}
use of org.eclipse.sw360.portal.common.UsedAsLiferayAction in project sw360portal by sw360.
the class ComponentUploadPortlet method updateLicenses.
@UsedAsLiferayAction
public void updateLicenses(ActionRequest request, ActionResponse response) throws PortletException, IOException, TException {
final HashMap<String, InputStream> inputMap = new HashMap<>();
User user = UserCacheHolder.getUserFromRequest(request);
try {
fillFilenameInputStreamMap(request, inputMap);
if (ZipTools.isValidLicenseArchive(inputMap)) {
final LicenseService.Iface licenseClient = thriftClients.makeLicenseClient();
log.debug("Parsing risk categories ...");
Map<Integer, RiskCategory> riskCategoryMap = getIdentifierToTypeMapAndWriteMissingToDatabase(licenseClient, inputMap.get(RISK_CATEGORY_FILE), RiskCategory.class, Integer.class, user);
log.debug("Parsing risks ...");
Map<Integer, Risk> riskMap = getIntegerRiskMap(licenseClient, riskCategoryMap, inputMap.get(RISK_FILE), user);
log.debug("Parsing obligations ...");
Map<Integer, Obligation> obligationMap = getIdentifierToTypeMapAndWriteMissingToDatabase(licenseClient, inputMap.get(OBLIGATION_FILE), Obligation.class, Integer.class, user);
log.debug("Parsing obligation todos ...");
List<CSVRecord> obligationTodoRecords = readAsCSVRecords(inputMap.get(OBLIGATION_TODO_FILE));
Map<Integer, Set<Integer>> obligationTodoMapping = convertRelationalTableWithIntegerKeys(obligationTodoRecords);
log.debug("Parsing license types ...");
Map<Integer, LicenseType> licenseTypeMap = getIdentifierToTypeMapAndWriteMissingToDatabase(licenseClient, inputMap.get(LICENSETYPE_FILE), LicenseType.class, Integer.class, user);
log.debug("Parsing todos ...");
Map<Integer, Todo> todoMap = getTodoMapAndWriteMissingToDatabase(licenseClient, obligationMap, obligationTodoMapping, inputMap.get(TODO_FILE), user);
if (inputMap.containsKey(CUSTOM_PROPERTIES_FILE)) {
log.debug("Parsing custom properties ...");
Map<Integer, PropertyWithValue> customPropertiesMap = getCustomPropertiesWithValuesByIdAndWriteMissingToDatabase(licenseClient, inputMap.get(CUSTOM_PROPERTIES_FILE), user);
log.debug("Parsing todo custom properties relation ...");
List<CSVRecord> todoPropertiesRecord = readAsCSVRecords(inputMap.get(TODO_CUSTOM_PROPERTIES_FILE));
Map<Integer, Set<Integer>> todoPropertiesMap = convertRelationalTableWithIntegerKeys(todoPropertiesRecord);
todoMap = updateTodoMapWithCustomPropertiesAndWriteToDatabase(licenseClient, todoMap, customPropertiesMap, todoPropertiesMap, user);
}
log.debug("Parsing license todos ...");
List<CSVRecord> licenseTodoRecord = readAsCSVRecords(inputMap.get(LICENSE_TODO_FILE));
Map<String, Set<Integer>> licenseTodoMap = convertRelationalTable(licenseTodoRecord);
log.debug("Parsing license risks ...");
List<CSVRecord> licenseRiskRecord = readAsCSVRecords(inputMap.get(LICENSE_RISK_FILE));
Map<String, Set<Integer>> licenseRiskMap = convertRelationalTable(licenseRiskRecord);
log.debug("Parsing licenses ...");
List<CSVRecord> licenseRecord = readAsCSVRecords(inputMap.get(LICENSE_FILE));
final List<License> licensesToAdd = ConvertRecord.fillLicenses(licenseRecord, licenseTypeMap, todoMap, riskMap, licenseTodoMap, licenseRiskMap);
addLicenses(licenseClient, licensesToAdd, log, user);
} else {
throw new SW360Exception("Invalid file format");
}
} finally {
for (InputStream inputStream : inputMap.values()) {
inputStream.close();
}
}
}
Aggregations