Search in sources :

Example 16 with UsedAsLiferayAction

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);
    }
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) UsedAsLiferayAction(org.eclipse.sw360.portal.common.UsedAsLiferayAction)

Example 17 with UsedAsLiferayAction

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);
    }
}
Also used : VendorService(org.eclipse.sw360.datahandler.thrift.vendors.VendorService) TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) Vendor(org.eclipse.sw360.datahandler.thrift.vendors.Vendor) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) UsedAsLiferayAction(org.eclipse.sw360.portal.common.UsedAsLiferayAction)

Example 18 with UsedAsLiferayAction

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);
}
Also used : RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) UsedAsLiferayAction(org.eclipse.sw360.portal.common.UsedAsLiferayAction)

Example 19 with UsedAsLiferayAction

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);
}
Also used : User(org.eclipse.sw360.datahandler.thrift.users.User) CSVRecord(org.apache.commons.csv.CSVRecord) ComponentService(org.eclipse.sw360.datahandler.thrift.components.ComponentService) RequestSummary(org.eclipse.sw360.datahandler.thrift.RequestSummary) UsedAsLiferayAction(org.eclipse.sw360.portal.common.UsedAsLiferayAction)

Example 20 with UsedAsLiferayAction

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();
        }
    }
}
Also used : User(org.eclipse.sw360.datahandler.thrift.users.User) SW360Exception(org.eclipse.sw360.datahandler.thrift.SW360Exception) CSVRecord(org.apache.commons.csv.CSVRecord) UsedAsLiferayAction(org.eclipse.sw360.portal.common.UsedAsLiferayAction)

Aggregations

User (org.eclipse.sw360.datahandler.thrift.users.User)18 UsedAsLiferayAction (org.eclipse.sw360.portal.common.UsedAsLiferayAction)18 TException (org.apache.thrift.TException)13 RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)8 CSVRecord (org.apache.commons.csv.CSVRecord)4 RequestSummary (org.eclipse.sw360.datahandler.thrift.RequestSummary)3 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)3 AttachmentService (org.eclipse.sw360.datahandler.thrift.attachments.AttachmentService)2 VendorService (org.eclipse.sw360.datahandler.thrift.vendors.VendorService)2 WrappedTException (org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException)1 SW360Exception (org.eclipse.sw360.datahandler.thrift.SW360Exception)1 FossologyHostFingerPrint (org.eclipse.sw360.datahandler.thrift.fossology.FossologyHostFingerPrint)1 FossologyService (org.eclipse.sw360.datahandler.thrift.fossology.FossologyService)1 UserService (org.eclipse.sw360.datahandler.thrift.users.UserService)1 Vendor (org.eclipse.sw360.datahandler.thrift.vendors.Vendor)1