<commit_before>package org.mitallast.queue.action.queue.enqueue;

import com.google.inject.Inject;
import org.mitallast.queue.action.AbstractAction;
import org.mitallast.queue.action.ActionListener;
import org.mitallast.queue.action.ActionRequestValidationException;
import org.mitallast.queue.common.settings.Settings;
import org.mitallast.queue.queue.QueueTypeMismatch;
import org.mitallast.queue.queue.service.QueueService;
import org.mitallast.queue.queues.QueueMissingException;
import org.mitallast.queue.queues.QueuesService;

public class EnQueueAction extends AbstractAction<EnQueueRequest, EnQueueResponse> {

    private final QueuesService queuesService;

    @Inject
    public EnQueueAction(Settings settings, QueuesService queuesService) {
        super(settings);
        this.queuesService = queuesService;
    }

    @Override
    @SuppressWarnings("unchecked")
    public void execute(EnQueueRequest request, ActionListener<EnQueueResponse> listener) {
        ActionRequestValidationException validationException = request.validate();
        if (validationException != null) {
            listener.onFailure(validationException);
            return;
        }
        if (!queuesService.hasQueue(request.getQueue())) {
            listener.onFailure(new QueueMissingException(request.getQueue()));
        }
        QueueService queueService = queuesService.queue(request.getQueue());
        if (queueService == null) {
            throw new QueueMissingException(request.getQueue());
        }
        if (!queueService.isSupported(request.getMessage())) {
            listener.onFailure(new QueueTypeMismatch());
        }
        queueService.enqueue(request.getMessage());
        listener.onResponse(new EnQueueResponse(request.getMessage().getUuid()));
    }
}<commit_msg>fix enqueue action<commit_after>package org.mitallast.queue.action.queue.enqueue;

import com.google.inject.Inject;
import org.mitallast.queue.action.AbstractAction;
import org.mitallast.queue.action.ActionListener;
import org.mitallast.queue.action.ActionRequestValidationException;
import org.mitallast.queue.common.settings.Settings;
import org.mitallast.queue.queue.QueueMessageUuidDuplicateException;
import org.mitallast.queue.queue.QueueTypeMismatch;
import org.mitallast.queue.queue.service.QueueService;
import org.mitallast.queue.queues.QueueMissingException;
import org.mitallast.queue.queues.QueuesService;

public class EnQueueAction extends AbstractAction<EnQueueRequest, EnQueueResponse> {

    private final QueuesService queuesService;

    @Inject
    public EnQueueAction(Settings settings, QueuesService queuesService) {
        super(settings);
        this.queuesService = queuesService;
    }

    @Override
    @SuppressWarnings("unchecked")
    public void execute(EnQueueRequest request, ActionListener<EnQueueResponse> listener) {
        ActionRequestValidationException validationException = request.validate();
        if (validationException != null) {
            listener.onFailure(validationException);
            return;
        }
        if (!queuesService.hasQueue(request.getQueue())) {
            listener.onFailure(new QueueMissingException(request.getQueue()));
            return;
        }
        QueueService queueService = queuesService.queue(request.getQueue());
        if (queueService == null) {
            listener.onFailure(new QueueMissingException(request.getQueue()));
            return;
        }
        if (!queueService.isSupported(request.getMessage())) {
            listener.onFailure(new QueueTypeMismatch());
            return;
        }
        try {
            queueService.enqueue(request.getMessage());
            listener.onResponse(new EnQueueResponse(request.getMessage().getUuid()));
        } catch (QueueMessageUuidDuplicateException e) {
            listener.onFailure(e);
        }
    }
}
{'fraction_non_alphanumeric': 0.09736570247933884, 'fraction_numerical': 0.0, 'mean_word_length': 3.688861985472155, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5028698', 'n_tokens_mistral': 1015, 'n_tokens_neox': 1019, 'n_words': 161}