Search in sources :

Example 16 with ThriftClients

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

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

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

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

the class FossologyFileHandlerTest method setUp.

@Before
public void setUp() throws TException {
    ThriftClients thriftClients = TestUtils.failingMock(ThriftClients.class);
    doReturn(componentService).when(thriftClients).makeComponentClient();
    user = TestUtils.getAdminUser(getClass());
    fossologyFileHandler = spy(new FossologyFileHandler(attachmentConnector, fossologyUploader, thriftClients));
}
Also used : ThriftClients(org.eclipse.sw360.datahandler.thrift.ThriftClients) Before(org.junit.Before)

Example 20 with ThriftClients

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

the class ComponentAndAttachmentAwareDBTest method getThriftClients.

protected static ThriftClients getThriftClients() throws TException, IOException {
    assertTestDbNames();
    ThriftClients thriftClients = failingMock(ThriftClients.class);
    ComponentHandler componentHandler = new ComponentHandler(thriftClients);
    VendorHandler vendorHandler = new VendorHandler();
    AttachmentHandler attachmentHandler = new AttachmentHandler();
    ModerationService.Iface moderationService = failingMock(ModerationService.Iface.class);
    doNothing().when(moderationService).deleteRequestsOnDocument(anyString());
    doReturn(componentHandler).when(thriftClients).makeComponentClient();
    doReturn(vendorHandler).when(thriftClients).makeVendorClient();
    doReturn(attachmentHandler).when(thriftClients).makeAttachmentClient();
    doReturn(moderationService).when(thriftClients).makeModerationClient();
    return thriftClients;
}
Also used : ModerationService(org.eclipse.sw360.datahandler.thrift.moderation.ModerationService) AttachmentHandler(org.eclipse.sw360.attachments.AttachmentHandler) ComponentHandler(org.eclipse.sw360.components.ComponentHandler) VendorHandler(org.eclipse.sw360.vendors.VendorHandler) ThriftClients(org.eclipse.sw360.datahandler.thrift.ThriftClients)

Aggregations

TException (org.apache.thrift.TException)17 User (org.eclipse.sw360.datahandler.thrift.users.User)12 ThriftClients (org.eclipse.sw360.datahandler.thrift.ThriftClients)10 JspException (javax.servlet.jsp.JspException)3 UsedAsLiferayAction (org.eclipse.sw360.portal.common.UsedAsLiferayAction)3 HashMap (java.util.HashMap)2 JspWriter (javax.servlet.jsp.JspWriter)2 ComponentService (org.eclipse.sw360.datahandler.thrift.components.ComponentService)2 Release (org.eclipse.sw360.datahandler.thrift.components.Release)2 ProjectLink (org.eclipse.sw360.datahandler.thrift.projects.ProjectLink)2 ProjectRelationship (org.eclipse.sw360.datahandler.thrift.projects.ProjectRelationship)2 ProjectService (org.eclipse.sw360.datahandler.thrift.projects.ProjectService)2 UserService (org.eclipse.sw360.datahandler.thrift.users.UserService)2 VendorService (org.eclipse.sw360.datahandler.thrift.vendors.VendorService)2 Before (org.junit.Before)2 Joiner (com.google.common.base.Joiner)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 AttachmentHandler (org.eclipse.sw360.attachments.AttachmentHandler)1 ComponentHandler (org.eclipse.sw360.components.ComponentHandler)1