class DefaultCompleteDataSetRegistrationExchangeService implements CompleteDataSetRegistrationExchangeService {

    public void validate( ExportParams params )
        throws IllegalQueryException
    {
        ErrorMessage error = null;

        if ( params == null )
        {
            throw new IllegalQueryException( ErrorCode.E2000 );
        }

        if ( params.getDataSets().isEmpty() )
        {
            error = new ErrorMessage( ErrorCode.E2013 );
        }

        if ( !params.hasPeriods() && !params.hasStartEndDate() && !params.hasCreated() && !params.hasCreatedDuration() )
        {
            error = new ErrorMessage( ErrorCode.E2002 );
        }

        if ( params.hasPeriods() && params.hasStartEndDate() )
        {
            error = new ErrorMessage( ErrorCode.E2003 );
        }

        if ( params.hasStartEndDate() && params.getStartDate().after( params.getEndDate() ) )
        {
            error = new ErrorMessage( ErrorCode.E2004 );
        }

        if ( params.hasCreatedDuration() && DateUtils.getDuration( params.getCreatedDuration() ) == null )
        {
            error = new ErrorMessage( ErrorCode.E2005 );
        }

        if ( !params.hasOrganisationUnits() && !params.hasOrganisationUnitGroups() )
        {
            error = new ErrorMessage( ErrorCode.E2006 );
        }

        if ( params.isIncludeChildren() && params.hasOrganisationUnitGroups() )
        {
            error = new ErrorMessage( ErrorCode.E2007 );
        }

        if ( params.isIncludeChildren() && !params.hasOrganisationUnits() )
        {
            error = new ErrorMessage( ErrorCode.E2008 );
        }

        if ( params.hasLimit() && params.getLimit() < 0 )
        {
            error = new ErrorMessage( ErrorCode.E2009 );
        }

        if ( error != null )
        {
            log.warn( String.format( "Complete data set registration validation failed, code: '%s', message: '%s'",
                error.getErrorCode(), error.getMessage() ) );

            throw new IllegalQueryException( error );
        }

        limitToValidIdSchemes( params );
    }

    public  DefaultCompleteDataSetRegistrationExchangeService(
        CompleteDataSetRegistrationExchangeStore cdsrStore,
        IdentifiableObjectManager idObjManager,
        OrganisationUnitService orgUnitService,
        Notifier notifier,
        I18nManager i18nManager,
        BatchHandlerFactory batchHandlerFactory,
        SystemSettingManager systemSettingManager,
        CategoryService categoryService,
        PeriodService periodService,
        CurrentUserService currentUserService,
        CompleteDataSetRegistrationService registrationService,
        InputUtils inputUtils,
        AggregateAccessManager accessManager,
        DataSetNotificationEventPublisher notificationPublisher,
        MessageService messageService,
        ObjectMapper jsonMapper );

}