Search in sources :

Example 1 with ScheduleService

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

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

the class ScheduleHandler method scheduleService.

@Override
public RequestSummary scheduleService(String serviceName) throws TException {
    if (ScheduleConstants.invalidConfiguredServices.contains(serviceName)) {
        log.info("Could not schedule " + serviceName + " because of invalid configuration.");
        return new RequestSummary(RequestStatus.FAILURE);
    }
    Scheduler.cancelSyncJobOfService(serviceName);
    boolean successSync = false;
    switch(serviceName) {
        case ThriftClients.CVESEARCH_SERVICE:
            successSync = wrapSupplierException(() -> thriftClients.makeCvesearchClient().update(), serviceName);
            break;
        default:
            log.error("Could not schedule service: " + serviceName + ". Reason: service is not registered in ThriftClients.");
    }
    if (successSync) {
        RequestSummary summary = new RequestSummary(RequestStatus.SUCCESS);
        summary.setMessage(SW360Utils.getDateTimeString(Scheduler.getNextSync()));
        return summary;
    } else {
        return new RequestSummary(RequestStatus.FAILURE);
    }
}
Also used : RequestSummary(org.eclipse.sw360.datahandler.thrift.RequestSummary)

Aggregations

TException (org.apache.thrift.TException)1 RequestSummary (org.eclipse.sw360.datahandler.thrift.RequestSummary)1 User (org.eclipse.sw360.datahandler.thrift.users.User)1 UsedAsLiferayAction (org.eclipse.sw360.portal.common.UsedAsLiferayAction)1