Search in sources :

Example 56 with User

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

Example 57 with User

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

the class BulkReleaseEdit method doView.

@Override
public void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException {
    final User user = UserCacheHolder.getUserFromRequest(request);
    ComponentService.Iface client = thriftClients.makeComponentClient();
    try {
        final List<Release> releaseSummary = client.getReleaseSummary(user);
        request.setAttribute(RELEASE_LIST, releaseSummary);
    } catch (TException e) {
        log.error("Could not fetch releases from backend", e);
        request.setAttribute(RELEASE_LIST, Collections.emptyList());
    }
    // Proceed with page rendering
    super.doView(request, response);
}
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)

Example 58 with User

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

the class DatabaseSanitation method importLicensesFromSPDX.

private void importLicensesFromSPDX(ResourceRequest request, ResourceResponse response) throws TException {
    User user = UserCacheHolder.getUserFromRequest(request);
    LicenseService.Iface licenseClient = thriftClients.makeLicenseClient();
    RequestSummary requestSummary = licenseClient.importAllSpdxLicenses(user);
    renderRequestSummary(request, response, requestSummary);
}
Also used : User(org.eclipse.sw360.datahandler.thrift.users.User) LicenseService(org.eclipse.sw360.datahandler.thrift.licenses.LicenseService) RequestSummary(org.eclipse.sw360.datahandler.thrift.RequestSummary)

Example 59 with User

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

the class ScheduleAdminPortlet method scheduleCveSearch.

@UsedAsLiferayAction
public void scheduleCveSearch(ActionRequest request, ActionResponse response) throws PortletException, IOException {
    try {
        User user = UserCacheHolder.getUserFromRequest(request);
        RequestSummary requestSummary = new ThriftClients().makeScheduleClient().scheduleService(ThriftClients.CVESEARCH_SERVICE);
        setSessionMessage(request, requestSummary.getRequestStatus(), "Task", "schedule");
    } 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 60 with User

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

the class ScheduleAdminPortlet method unscheduleAllServices.

@UsedAsLiferayAction
public void unscheduleAllServices(ActionRequest request, ActionResponse response) throws PortletException, IOException {
    try {
        User user = UserCacheHolder.getUserFromRequest(request);
        RequestStatus requestStatus = new ThriftClients().makeScheduleClient().unscheduleAllServices(user);
        setSessionMessage(request, requestStatus, "Every 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)

Aggregations

User (org.eclipse.sw360.datahandler.thrift.users.User)169 TException (org.apache.thrift.TException)100 Release (org.eclipse.sw360.datahandler.thrift.components.Release)58 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)44 Test (org.junit.Test)30 Attachment (org.eclipse.sw360.datahandler.thrift.attachments.Attachment)27 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)26 Component (org.eclipse.sw360.datahandler.thrift.components.Component)20 ModerationRequest (org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)20 ResponseEntity (org.springframework.http.ResponseEntity)20 AttachmentContent (org.eclipse.sw360.datahandler.thrift.attachments.AttachmentContent)19 WrappedTException (org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException)18 IOException (java.io.IOException)17 RequestStatus (org.eclipse.sw360.datahandler.thrift.RequestStatus)16 UsedAsLiferayAction (org.eclipse.sw360.portal.common.UsedAsLiferayAction)16 HalResource (org.eclipse.sw360.rest.resourceserver.core.HalResource)13 RequestSummary (org.eclipse.sw360.datahandler.thrift.RequestSummary)12 SW360Exception (org.eclipse.sw360.datahandler.thrift.SW360Exception)12 Before (org.junit.Before)12 ArrayList (java.util.ArrayList)11