Search in sources :

Example 11 with RequestStatus

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

the class Sw360ProjectService method deleteProject.

public RequestStatus deleteProject(Project project, User sw360User) throws TException {
    ProjectService.Iface sw360ProjectClient = getThriftProjectClient();
    RequestStatus requestStatus = sw360ProjectClient.deleteProject(project.getId(), sw360User);
    if (requestStatus != RequestStatus.SUCCESS) {
        throw new RuntimeException("sw360 project with name '" + project.getName() + " cannot be deleted.");
    }
    return requestStatus;
}
Also used : ProjectService(org.eclipse.sw360.datahandler.thrift.projects.ProjectService) AddDocumentRequestStatus(org.eclipse.sw360.datahandler.thrift.AddDocumentRequestStatus) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 12 with RequestStatus

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

the class Sw360VendorService method deleteVendor.

public void deleteVendor(Vendor vendor, User sw360User) {
    try {
        VendorService.Iface sw360VendorClient = getThriftVendorClient();
        RequestStatus requestStatus = sw360VendorClient.deleteVendor(vendor.getId(), sw360User);
        if (requestStatus == RequestStatus.SUCCESS) {
            return;
        }
        throw new RuntimeException("sw360 vendor with name '" + vendor.getFullname() + " cannot be deleted.");
    } catch (TException e) {
        throw new RuntimeException(e);
    }
}
Also used : VendorService(org.eclipse.sw360.datahandler.thrift.vendors.VendorService) TException(org.apache.thrift.TException) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 13 with RequestStatus

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

the class Sw360VendorService method updateVendor.

public void updateVendor(Vendor vendor, User sw360User) {
    try {
        VendorService.Iface sw360VendorClient = getThriftVendorClient();
        RequestStatus requestStatus = sw360VendorClient.updateVendor(vendor, sw360User);
        if (requestStatus == RequestStatus.SUCCESS) {
            return;
        }
        throw new RuntimeException("sw360 vendor with full name '" + vendor.getFullname() + " cannot be updated.");
    } catch (TException e) {
        throw new RuntimeException(e);
    }
}
Also used : VendorService(org.eclipse.sw360.datahandler.thrift.vendors.VendorService) TException(org.apache.thrift.TException) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

Example 14 with RequestStatus

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

the class ProjectPortlet method removeProject.

private RequestStatus removeProject(PortletRequest request) {
    String projectId = request.getParameter(PortalConstants.PROJECT_ID);
    String encodedDeleteComment = request.getParameter(PortalConstants.MODERATION_REQUEST_COMMENT);
    final User user = UserCacheHolder.getUserFromRequest(request);
    if (encodedDeleteComment != null) {
        String deleteComment = new String(Base64.getDecoder().decode(encodedDeleteComment));
        user.setCommentMadeDuringModerationRequest(deleteComment);
    }
    try {
        deleteUnneededAttachments(user.getEmail(), projectId);
        ProjectService.Iface client = thriftClients.makeProjectClient();
        return client.deleteProject(projectId, user);
    } catch (TException e) {
        log.error("Error deleting project from backend", e);
    }
    return RequestStatus.FAILURE;
}
Also used : WrappedTException(org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException) TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User)

Example 15 with RequestStatus

use of org.eclipse.sw360.datahandler.thrift.RequestStatus 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());
}
Also used : WrappedTException(org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException) TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) JSONFactoryUtil.createJSONObject(com.liferay.portal.kernel.json.JSONFactoryUtil.createJSONObject) JSONObject(com.liferay.portal.kernel.json.JSONObject) PrintWriter(java.io.PrintWriter)

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