Search in sources :

Example 66 with RequestStatus

use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.

the class ProjectPortlet method update.

@UsedAsLiferayAction
public void update(ActionRequest request, ActionResponse response) throws PortletException, IOException {
    String id = request.getParameter(PROJECT_ID);
    User user = UserCacheHolder.getUserFromRequest(request);
    RequestStatus requestStatus;
    try {
        ProjectService.Iface client = thriftClients.makeProjectClient();
        if (id != null) {
            Project project = client.getProjectByIdForEdit(id, user);
            ProjectPortletUtils.updateProjectFromRequest(request, project);
            String ModerationRequestCommentMsg = request.getParameter(MODERATION_REQUEST_COMMENT);
            user.setCommentMadeDuringModerationRequest(ModerationRequestCommentMsg);
            requestStatus = client.updateProject(project, user);
            setSessionMessage(request, requestStatus, "Project", "update", printName(project));
            cleanUploadHistory(user.getEmail(), id);
            response.setRenderParameter(PAGENAME, PAGENAME_DETAIL);
            response.setRenderParameter(PROJECT_ID, request.getParameter(PROJECT_ID));
        } else {
            // Add project
            Project project = new Project();
            ProjectPortletUtils.updateProjectFromRequest(request, project);
            AddDocumentRequestSummary summary = client.addProject(project, user);
            AddDocumentRequestStatus status = summary.getRequestStatus();
            switch(status) {
                case SUCCESS:
                    String successMsg = "Project " + printName(project) + " added successfully";
                    SessionMessages.add(request, "request_processed", successMsg);
                    response.setRenderParameter(PROJECT_ID, summary.getId());
                    response.setRenderParameter(PAGENAME, PAGENAME_EDIT);
                    break;
                case DUPLICATE:
                    setSW360SessionError(request, ErrorMessages.PROJECT_DUPLICATE);
                    response.setRenderParameter(PAGENAME, PAGENAME_EDIT);
                    prepareRequestForEditAfterDuplicateError(request, project, user);
                    break;
                default:
                    setSW360SessionError(request, ErrorMessages.PROJECT_NOT_ADDED);
                    response.setRenderParameter(PAGENAME, PAGENAME_VIEW);
            }
        }
    } catch (TException e) {
        log.error("Error updating project in backend!", e);
        setSW360SessionError(request, ErrorMessages.DEFAULT_ERROR_MESSAGE);
    }
}
Also used : WrappedTException(org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException) TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User)

Example 67 with RequestStatus

use of org.eclipse.sw360.datahandler.thrift.RequestStatus in project sw360portal by sw360.

the class BulkReleaseEdit method updateRelease.

private void updateRelease(ResourceRequest request, ResourceResponse response) {
    final User user = UserCacheHolder.getUserFromRequest(request);
    RequestStatus requestStatus = RequestStatus.FAILURE;
    String releaseId = request.getParameter(RELEASE_ID);
    if (releaseId != null) {
        try {
            ComponentService.Iface client = thriftClients.makeComponentClient();
            Release release = client.getReleaseById(releaseId, user);
            ComponentPortletUtils.updateReleaseFromRequest(request, release);
            requestStatus = client.updateRelease(release, user);
        } catch (TException e) {
            log.error("Release update failed", e);
            requestStatus = RequestStatus.FAILURE;
        }
    }
    renderRequestStatus(request, response, requestStatus);
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) ComponentService(org.eclipse.sw360.datahandler.thrift.components.ComponentService) Release(org.eclipse.sw360.datahandler.thrift.components.Release) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 68 with RequestStatus

use of org.eclipse.sw360.datahandler.thrift.RequestStatus 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 69 with RequestStatus

use of org.eclipse.sw360.datahandler.thrift.RequestStatus 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 70 with RequestStatus

use of org.eclipse.sw360.datahandler.thrift.RequestStatus 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)

Aggregations

RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)52 TException (org.apache.thrift.TException)27 User (org.eclipse.sw360.datahandler.thrift.users.User)24 Test (org.junit.Test)16 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)13 UsedAsLiferayAction (org.eclipse.sw360.portal.common.UsedAsLiferayAction)10 ModerationRequest (org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)5 TestUtils.assertTestString (org.eclipse.sw360.datahandler.TestUtils.assertTestString)4 AddDocumentRequestStatus (org.eclipse.sw360.datahandler.thrift.AddDocumentRequestStatus)4 SW360Exception (org.eclipse.sw360.datahandler.thrift.SW360Exception)4 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)4 VendorService (org.eclipse.sw360.datahandler.thrift.vendors.VendorService)4 WrappedTException (org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException)3 Release (org.eclipse.sw360.datahandler.thrift.components.Release)3 Vulnerability (org.eclipse.sw360.datahandler.thrift.vulnerabilities.Vulnerability)3 JSONObject (com.liferay.portal.kernel.json.JSONObject)2 PrintWriter (java.io.PrintWriter)2 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)2 Component (org.eclipse.sw360.datahandler.thrift.components.Component)2 UpdateType (org.eclipse.sw360.datahandler.thrift.cvesearch.UpdateType)2