Search in sources :

Example 1 with ThriftClients

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

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

Example 3 with ThriftClients

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

the class ScheduleAdminPortlet method prepareStandardView.

private void prepareStandardView(RenderRequest request, RenderResponse response) {
    try {
        User user = UserCacheHolder.getUserFromRequest(request);
        ScheduleService.Iface scheduleClient = new ThriftClients().makeScheduleClient();
        boolean isCveSearchScheduled = isCveSearchScheduled(scheduleClient, user);
        request.setAttribute(PortalConstants.CVESEARCH_IS_SCHEDULED, isCveSearchScheduled);
        boolean isAnyServiceScheduled = isAnyServiceScheduled(scheduleClient, user);
        request.setAttribute(PortalConstants.ANY_SERVICE_IS_SCHEDULED, isAnyServiceScheduled);
        int offsetInSeconds = scheduleClient.getFirstRunOffset(ThriftClients.CVESEARCH_SERVICE);
        request.setAttribute(PortalConstants.CVESEARCH_OFFSET, CommonUtils.formatTime(offsetInSeconds));
        int intervalInSeconds = scheduleClient.getInterval(ThriftClients.CVESEARCH_SERVICE);
        request.setAttribute(PortalConstants.CVESEARCH_INTERVAL, CommonUtils.formatTime(intervalInSeconds));
        String nextSync = scheduleClient.getNextSync(ThriftClients.CVESEARCH_SERVICE);
        request.setAttribute(PortalConstants.CVESEARCH_NEXT_SYNC, nextSync);
    } catch (TException te) {
        log.error(te.getMessage());
    }
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) ScheduleService(org.eclipse.sw360.datahandler.thrift.schedule.ScheduleService)

Example 4 with ThriftClients

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

the class ComponentPortletUtils method subscribeRelease.

public static RequestStatus subscribeRelease(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.subscribeRelease(id, user);
        } catch (TException e) {
            log.error("Could not subscribe to release", e);
        }
    }
    return RequestStatus.FAILURE;
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User)

Example 5 with ThriftClients

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

the class ComponentPortletUtils method deleteComponent.

public static RequestStatus deleteComponent(PortletRequest request, Logger log) {
    String id = request.getParameter(PortalConstants.COMPONENT_ID);
    if (id != 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.deleteComponent(id, user);
        } catch (TException e) {
            log.error("Could not delete component from DB", e);
        }
    }
    return RequestStatus.FAILURE;
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User)

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