<commit_before>/*******************************************************************************
 * Copyright (c) 2017, 2019 Stichting Yona Foundation This Source Code Form is subject to the terms of the Mozilla Public License,
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
 *******************************************************************************/
package nu.yona.server.batch.rest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.Resource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;

import nu.yona.server.batch.client.PinResetConfirmationCodeSendRequestDto;
import nu.yona.server.batch.client.SystemMessageSendRequestDto;
import nu.yona.server.batch.service.BatchJobResultDto;
import nu.yona.server.batch.service.BatchTaskService;
import nu.yona.server.exceptions.InvalidDataException;
import nu.yona.server.properties.YonaProperties;
import nu.yona.server.util.Require;

@Controller
@RequestMapping(value = "/batch", produces = { MediaType.APPLICATION_JSON_VALUE })
public class BatchTaskController
{
	@Autowired
	private YonaProperties yonaProperties;

	@Autowired
	private BatchTaskService batchTaskService;

	@PostMapping(value = "/sendPinResetConfirmationCode/")
	@ResponseStatus(HttpStatus.NO_CONTENT)
	public void requestPinResetConfirmationCode(
			@RequestBody PinResetConfirmationCodeSendRequestDto pinResetConfirmationCodeSendRequest)
	{
		batchTaskService.requestPinResetConfirmationCode(pinResetConfirmationCodeSendRequest);
	}

	@PostMapping(value = "/sendSystemMessage/")
	@ResponseStatus(HttpStatus.NO_CONTENT)
	public void sendSystemMessage(@RequestBody SystemMessageSendRequestDto systemMessageSendRequest)
	{
		batchTaskService.sendSystemMessage(systemMessageSendRequest);
	}

	// NOTICE: For integration test purposes. It executes the job synchronously.
	@PostMapping(value = "/aggregateActivities/")
	public HttpEntity<Resource<BatchJobResultDto>> aggregateActivities()
	{
		Require.that(yonaProperties.isTestServer(),
				() -> InvalidDataException.onlyAllowedOnTestServers("Endpoint //aggregateActivities/ is not available"));
		return new ResponseEntity<>(new Resource<>(batchTaskService.aggregateActivities()), HttpStatus.OK);
	}
}
<commit_msg>Corrected path in InvalidDataException<commit_after>/*******************************************************************************
 * Copyright (c) 2017, 2019 Stichting Yona Foundation This Source Code Form is subject to the terms of the Mozilla Public License,
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
 *******************************************************************************/
package nu.yona.server.batch.rest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.Resource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;

import nu.yona.server.batch.client.PinResetConfirmationCodeSendRequestDto;
import nu.yona.server.batch.client.SystemMessageSendRequestDto;
import nu.yona.server.batch.service.BatchJobResultDto;
import nu.yona.server.batch.service.BatchTaskService;
import nu.yona.server.exceptions.InvalidDataException;
import nu.yona.server.properties.YonaProperties;
import nu.yona.server.util.Require;

@Controller
@RequestMapping(value = "/batch", produces = { MediaType.APPLICATION_JSON_VALUE })
public class BatchTaskController
{
	@Autowired
	private YonaProperties yonaProperties;

	@Autowired
	private BatchTaskService batchTaskService;

	@PostMapping(value = "/sendPinResetConfirmationCode/")
	@ResponseStatus(HttpStatus.NO_CONTENT)
	public void requestPinResetConfirmationCode(
			@RequestBody PinResetConfirmationCodeSendRequestDto pinResetConfirmationCodeSendRequest)
	{
		batchTaskService.requestPinResetConfirmationCode(pinResetConfirmationCodeSendRequest);
	}

	@PostMapping(value = "/sendSystemMessage/")
	@ResponseStatus(HttpStatus.NO_CONTENT)
	public void sendSystemMessage(@RequestBody SystemMessageSendRequestDto systemMessageSendRequest)
	{
		batchTaskService.sendSystemMessage(systemMessageSendRequest);
	}

	// NOTICE: For integration test purposes. It executes the job synchronously.
	@PostMapping(value = "/aggregateActivities/")
	public HttpEntity<Resource<BatchJobResultDto>> aggregateActivities()
	{
		Require.that(yonaProperties.isTestServer(),
				() -> InvalidDataException.onlyAllowedOnTestServers("Endpoint /batch/aggregateActivities/ is not available"));
		return new ResponseEntity<>(new Resource<>(batchTaskService.aggregateActivities()), HttpStatus.OK);
	}
}

{'fraction_non_alphanumeric': 0.144, 'fraction_numerical': 0.004363636363636364, 'mean_word_length': 7.463076923076923, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 2, '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': '1376050', 'n_tokens_mistral': 1500, 'n_tokens_neox': 1454, 'n_words': 285}