<commit_before>package services;

import java.util.Date;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import domain.Actor;
import domain.Message;
import repositories.MessageRepository;
import services.form.MessageFormService;

@Service
@Transactional
public class MessageService {

	// Managed repository -----------------------------------------------------

	@Autowired
	private MessageRepository messageRepository;

	// Supporting services ----------------------------------------------------

	@Autowired
	private ActorService actorService;

	// Constructors -----------------------------------------------------------

	public MessageService() {
		super();
	}

	// Simple CRUD methods ----------------------------------------------------

	public Message create() {
		Message result;
		Actor actor;
		long segundos;
		Date momento;

		result = new Message();
		actor = actorService.findByPrincipal();
		segundos = System.currentTimeMillis() - 1;
		momento = new Date(segundos);

		result.setMoment(momento);
		Assert.notNull(actor);
		result.setSender(actor);

		return result;
	}
	
	public Message save(Message message) {
		Assert.notNull(message);
		Message result;

		result = messageRepository.save(message);
		<commit_msg>Añadida seguridad en los Mensajes<commit_after>package services;

import java.util.Date;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import domain.Actor;
import domain.Message;
import repositories.MessageRepository;
import services.form.MessageFormService;

@Service
@Transactional
public class MessageService {

	// Managed repository -----------------------------------------------------

	@Autowired
	private MessageRepository messageRepository;

	// Supporting services ----------------------------------------------------

	@Autowired
	private ActorService actorService;

	// Constructors -----------------------------------------------------------

	public MessageService() {
		super();
	}

	// Simple CRUD methods ----------------------------------------------------

	public Message create() {
		Message result;
		Actor actor;
		long segundos;
		Date momento;

		result = new Message();
		actor = actorService.findByPrincipal();
		segundos = System.currentTimeMillis() - 1;
		momento = new Date(segundos);

		result.setMoment(momento);
		Assert.notNull(actor);
		result.setSender(actor);

		return result;
	}
	
	public Message save(Message message) {
		Assert.notNull(message);
		Message result;
		Actor actor;
		long segundos;
		Date momento;
		
		actor = actorService.findByPrincipal();
		segundos = System.currentTimeMillis() - 1;
		momento = new Date(segundos);
		message.setMoment(momento);
		Assert.notNull(actor);
		message.setSender(actor);
		
		result = messageRepository.save(message);
		
{'fraction_non_alphanumeric': 0.21656841452063294, 'fraction_numerical': 0.000930809804529941, 'mean_word_length': 2.523497267759563, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3302075', 'n_tokens_mistral': 890, 'n_tokens_neox': 807, 'n_words': 189}