Search in sources :

Example 6 with UsedAsLiferayAction

use of org.eclipse.sw360.portal.common.UsedAsLiferayAction in project sw360portal by sw360.

the class LicensesPortlet method delete.

@UsedAsLiferayAction
public void delete(ActionRequest request, ActionResponse response) throws PortletException, IOException {
    RequestStatus requestStatus = deleteLicense(request);
    setSessionMessage(request, requestStatus, "License", "remove");
}
Also used : RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) UsedAsLiferayAction(org.eclipse.sw360.portal.common.UsedAsLiferayAction)

Example 7 with UsedAsLiferayAction

use of org.eclipse.sw360.portal.common.UsedAsLiferayAction in project sw360portal by sw360.

the class LicensesPortlet method update.

@UsedAsLiferayAction
public void update(ActionRequest request, ActionResponse response) throws PortletException, IOException {
    LicenseService.Iface client = thriftClients.makeLicenseClient();
    String licenseId = request.getParameter(LICENSE_ID);
    User user = UserCacheHolder.getUserFromRequest(request);
    License license = prepareLicenseForUpdate(request, client, licenseId, user);
    boolean isNewLicense = isNullOrEmpty(licenseId);
    boolean isAttemptToOverwriteExistingByNew = isAttemptToOverwriteExistingByNew(license, user, isNewLicense, client);
    RequestStatus requestStatus = updateLicense(license, user, isAttemptToOverwriteExistingByNew, client);
    if (isAttemptToOverwriteExistingByNew) {
        response.setRenderParameter(PAGENAME, PAGENAME_EDIT);
        setSW360SessionError(request, ErrorMessages.LICENSE_SHORTNAME_TAKEN);
        request.setAttribute(KEY_LICENSE_DETAIL, license);
    } else if (isNewLicense) {
        response.setRenderParameter(PAGENAME, PAGENAME_VIEW);
        setSessionMessage(request, requestStatus, "License", "adde");
    } else {
        response.setRenderParameter(LICENSE_ID, licenseId);
        response.setRenderParameter(PAGENAME, PAGENAME_DETAIL);
        response.setRenderParameter(SELECTED_TAB, "Details");
        setSessionMessage(request, requestStatus, "License", "update");
    }
}
Also used : User(org.eclipse.sw360.datahandler.thrift.users.User) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus) UsedAsLiferayAction(org.eclipse.sw360.portal.common.UsedAsLiferayAction)

Example 8 with UsedAsLiferayAction

use of org.eclipse.sw360.portal.common.UsedAsLiferayAction in project sw360portal by sw360.

the class ComponentUploadPortlet method updateComponentAttachments.

@UsedAsLiferayAction
public void updateComponentAttachments(ActionRequest request, ActionResponse response) throws PortletException, IOException, TException {
    List<CSVRecord> attachmentRecords = getCSVFromRequest(request, "file");
    FluentIterable<ComponentAttachmentCSVRecord> compCSVRecords = convertCSVRecordsToComponentAttachmentCSVRecords(attachmentRecords);
    log.trace("read records <" + Joiner.on("\n").join(compCSVRecords) + ">");
    final ComponentService.Iface componentClient = thriftClients.makeComponentClient();
    final AttachmentService.Iface attachmentClient = thriftClients.makeAttachmentClient();
    User user = UserCacheHolder.getUserFromRequest(request);
    final RequestSummary requestSummary = writeAttachmentsToDatabase(compCSVRecords, user, componentClient, attachmentClient);
    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) AttachmentService(org.eclipse.sw360.datahandler.thrift.attachments.AttachmentService) UsedAsLiferayAction(org.eclipse.sw360.portal.common.UsedAsLiferayAction)

Example 9 with UsedAsLiferayAction

use of org.eclipse.sw360.portal.common.UsedAsLiferayAction in project sw360portal by sw360.

the class FossologyAdminPortlet method setFingerPrints.

@UsedAsLiferayAction
public void setFingerPrints(ActionRequest request, ActionResponse response) throws PortletException, IOException {
    List<FossologyHostFingerPrint> fingerPrints;
    FossologyService.Iface client;
    try {
        client = thriftClients.makeFossologyClient();
        fingerPrints = client.getFingerPrints();
    } catch (TException e) {
        log.error("Error retrieving fingerprints when setting", e);
        return;
    }
    for (FossologyHostFingerPrint fingerPrint : fingerPrints) {
        String bool = request.getParameter(fingerPrint.fingerPrint);
        fingerPrint.trusted = "on".equals(bool);
    }
    try {
        client.setFingerPrints(fingerPrints);
    } catch (TException e) {
        log.error("Problems setting finger prints", e);
    }
}
Also used : TException(org.apache.thrift.TException) FossologyService(org.eclipse.sw360.datahandler.thrift.fossology.FossologyService) FossologyHostFingerPrint(org.eclipse.sw360.datahandler.thrift.fossology.FossologyHostFingerPrint) UsedAsLiferayAction(org.eclipse.sw360.portal.common.UsedAsLiferayAction)

Example 10 with UsedAsLiferayAction

use of org.eclipse.sw360.portal.common.UsedAsLiferayAction in project sw360portal by sw360.

the class ComponentPortlet method updateComponent.

// ! Actions
@UsedAsLiferayAction
public void updateComponent(ActionRequest request, ActionResponse response) throws PortletException, IOException {
    String id = request.getParameter(COMPONENT_ID);
    final User user = UserCacheHolder.getUserFromRequest(request);
    try {
        ComponentService.Iface client = thriftClients.makeComponentClient();
        if (id != null) {
            Component component = client.getComponentByIdForEdit(id, user);
            ComponentPortletUtils.updateComponentFromRequest(request, component);
            String ModerationRequestCommentMsg = request.getParameter(MODERATION_REQUEST_COMMENT);
            user.setCommentMadeDuringModerationRequest(ModerationRequestCommentMsg);
            RequestStatus requestStatus = client.updateComponent(component, user);
            setSessionMessage(request, requestStatus, "Component", "update", component.getName());
            cleanUploadHistory(user.getEmail(), id);
            response.setRenderParameter(PAGENAME, PAGENAME_DETAIL);
            response.setRenderParameter(COMPONENT_ID, request.getParameter(COMPONENT_ID));
        } else {
            Component component = new Component();
            ComponentPortletUtils.updateComponentFromRequest(request, component);
            AddDocumentRequestSummary summary = client.addComponent(component, user);
            AddDocumentRequestStatus status = summary.getRequestStatus();
            switch(status) {
                case SUCCESS:
                    String successMsg = "Component " + component.getName() + " added successfully";
                    SessionMessages.add(request, "request_processed", successMsg);
                    response.setRenderParameter(COMPONENT_ID, summary.getId());
                    response.setRenderParameter(PAGENAME, PAGENAME_EDIT);
                    break;
                case DUPLICATE:
                    setSW360SessionError(request, ErrorMessages.COMPONENT_DUPLICATE);
                    response.setRenderParameter(PAGENAME, PAGENAME_EDIT);
                    prepareRequestForEditAfterDuplicateError(request, component);
                    break;
                default:
                    setSW360SessionError(request, ErrorMessages.COMPONENT_NOT_ADDED);
                    response.setRenderParameter(PAGENAME, PAGENAME_VIEW);
            }
        }
    } catch (TException e) {
        log.error("Error fetching component from backend!", e);
    }
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User)

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