Search in sources :

Example 71 with RequestStatus

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

the class ComponentPortletUtils method deleteRelease.

public static RequestStatus deleteRelease(PortletRequest request, Logger log) {
    String releaseId = request.getParameter(PortalConstants.RELEASE_ID);
    if (releaseId != null) {
        try {
            String deleteCommentEncoded = request.getParameter(PortalConstants.MODERATION_REQUEST_COMMENT);
            User user = UserCacheHolder.getUserFromRequest(request);
            if (deleteCommentEncoded != null) {
                String deleteComment = new String(Base64.getDecoder().decode(deleteCommentEncoded));
                user.setCommentMadeDuringModerationRequest(deleteComment);
            }
            ComponentService.Iface client = new ThriftClients().makeComponentClient();
            return client.deleteRelease(releaseId, UserCacheHolder.getUserFromRequest(request));
        } catch (TException e) {
            log.error("Could not delete release from DB", e);
        }
    }
    return RequestStatus.FAILURE;
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User)

Example 72 with RequestStatus

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

the class ComponentPortletUtils method unsubscribeComponent.

public static RequestStatus unsubscribeComponent(ResourceRequest request, Logger log) {
    String id = request.getParameter(PortalConstants.COMPONENT_ID);
    if (id != null) {
        try {
            ComponentService.Iface client = new ThriftClients().makeComponentClient();
            User user = UserCacheHolder.getUserFromRequest(request);
            return client.unsubscribeComponent(id, user);
        } catch (TException e) {
            log.error("Could not unsubscribe to component", e);
        }
    }
    return RequestStatus.FAILURE;
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User)

Example 73 with RequestStatus

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

the class ComponentPortletUtils method unsubscribeRelease.

public static RequestStatus unsubscribeRelease(ResourceRequest request, Logger log) {
    String id = request.getParameter(PortalConstants.RELEASE_ID);
    if (id != null) {
        try {
            ComponentService.Iface client = new ThriftClients().makeComponentClient();
            User user = UserCacheHolder.getUserFromRequest(request);
            return client.unsubscribeRelease(id, user);
        } catch (TException e) {
            log.error("Could not unsubscribe to release", e);
        }
    }
    return RequestStatus.FAILURE;
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User)

Example 74 with RequestStatus

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

the class ComponentPortletUtils method subscribeComponent.

public static RequestStatus subscribeComponent(ResourceRequest request, Logger log) {
    String id = request.getParameter(PortalConstants.COMPONENT_ID);
    if (id != null) {
        try {
            ComponentService.Iface client = new ThriftClients().makeComponentClient();
            User user = UserCacheHolder.getUserFromRequest(request);
            return client.subscribeComponent(id, user);
        } catch (TException e) {
            log.error("Could not subscribe to component", e);
        }
    }
    return RequestStatus.FAILURE;
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User)

Example 75 with RequestStatus

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

the class VulnerabilityDatabaseHandler method addRelationsIfNecessary.

public RequestStatus addRelationsIfNecessary(String releaseId, Map<String, List<String>> needlesToVulnerabilityIds) {
    RequestStatus requestStatus = RequestStatus.SUCCESS;
    for (Map.Entry<String, List<String>> needleWithVulnerabilityIds : needlesToVulnerabilityIds.entrySet()) {
        String usedNeedle = needleWithVulnerabilityIds.getKey();
        List<String> vulnerabilityIds = needleWithVulnerabilityIds.getValue();
        for (String vulnerabilityId : vulnerabilityIds) {
            RequestStatus singleOperationStatus = addRelationIfNecessary(releaseId, vulnerabilityId, Optional.ofNullable(usedNeedle));
            if (RequestStatus.FAILURE.equals(singleOperationStatus)) {
                requestStatus = RequestStatus.FAILURE;
            }
        }
    }
    return requestStatus;
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) RequestStatus(org.eclipse.sw360.datahandler.thrift.RequestStatus)

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