<commit_before>/*
 * Copyright 2016 RedRoma, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package tech.aroma.application.service.reactions.actions;

import java.util.List;
import org.apache.thrift.TException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sir.wellington.alchemy.collections.lists.Lists;
import tech.aroma.data.InboxRepository;
import tech.aroma.thrift.Message;
import tech.aroma.thrift.User;
import tech.aroma.thrift.service.AromaServiceConstants;
import tech.sirwellington.alchemy.annotations.access.Internal;
import tech.sirwellington.alchemy.annotations.designs.patterns.StrategyPattern;

import static tech.sirwellington.alchemy.annotations.designs.patterns.StrategyPattern.Role.CONCRETE_BEHAVIOR;
import static tech.sirwellington.alchemy.arguments.Arguments.checkThat;
import static tech.sirwellington.alchemy.arguments.assertions.Assertions.notNull;

/**
 * This Action actually save a message in a User's Inbox.
 *
 * @author SirWellington
 */
@Internal
@StrategyPattern(role = CONCRETE_BEHAVIOR)
final class StoreInInboxAction implements Action
{

    private final static Logger LOG = LoggerFactory.getLogger(StoreInInboxAction.class);

    private final InboxRepository inboxRepo;
    private final User user;

    StoreInInboxAction(InboxRepository inboxRepo, User user)
    {
        checkThat(inboxRepo, user)
            .are(notNull());

        this.inboxRepo = inboxRepo;
        this.user = user;
    }

    @Override
    public List<Action> actOnMessage(Message message) throws TException
    {
        Action.checkMessage(message);

        inboxRepo.saveMessageForUser(user, message, AromaServiceConstants.DEFAULT_INBOX_LIFETIME);
        LOG.debug("Saved Message {} in Inbox of User {}", message.messageId, user);

        return Lists.emptyList();<commit_msg>StoreInInboxAction: Log statement update<commit_after>/*
 * Copyright 2016 RedRoma, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package tech.aroma.application.service.reactions.actions;

import java.util.List;
import org.apache.thrift.TException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sir.wellington.alchemy.collections.lists.Lists;
import tech.aroma.data.InboxRepository;
import tech.aroma.thrift.Message;
import tech.aroma.thrift.User;
import tech.aroma.thrift.service.AromaServiceConstants;
import tech.sirwellington.alchemy.annotations.access.Internal;
import tech.sirwellington.alchemy.annotations.designs.patterns.StrategyPattern;

import static tech.sirwellington.alchemy.annotations.designs.patterns.StrategyPattern.Role.CONCRETE_BEHAVIOR;
import static tech.sirwellington.alchemy.arguments.Arguments.checkThat;
import static tech.sirwellington.alchemy.arguments.assertions.Assertions.notNull;

/**
 * This Action actually save a message in a User's Inbox.
 *
 * @author SirWellington
 */
@Internal
@StrategyPattern(role = CONCRETE_BEHAVIOR)
final class StoreInInboxAction implements Action
{

    private final static Logger LOG = LoggerFactory.getLogger(StoreInInboxAction.class);

    private final InboxRepository inboxRepo;
    private final User user;

    StoreInInboxAction(InboxRepository inboxRepo, User user)
    {
        checkThat(inboxRepo, user)
            .are(notNull());

        this.inboxRepo = inboxRepo;
        this.user = user;
    }

    @Override
    public List<Action> actOnMessage(Message message) throws TException
    {
        Action.checkMessage(message);

        inboxRepo.saveMessageForUser(user, message, AromaServiceConstants.DEFAULT_INBOX_LIFETIME);
        LOG.debug("Saved Message {}/{} in Inbox of User {}", message.applicationId, message.messageId, user);

        return Lists.emptyList();
{'fraction_non_alphanumeric': 0.08662581871962814, 'fraction_numerical': 0.0042256496936403974, 'mean_word_length': 4.349152542372881, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3527500', 'n_tokens_mistral': 1396, 'n_tokens_neox': 1353, 'n_words': 367}