<commit_before>package org.jvalue.ceps.rest;


import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.inject.Inject;
import com.google.inject.name.Named;

import org.jvalue.ceps.adapter.AdapterModule;
import org.jvalue.ceps.adapter.EplAdapter;
import org.jvalue.ceps.notifications.NotificationManager;
import org.jvalue.ceps.notifications.clients.Client;
import org.jvalue.ceps.notifications.clients.ClientFactory;

import java.util.Map;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/clients")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public final class NotificationClientRegistrationApi {

	private final NotificationManager notificationManager;
	private final EplAdapter pegelOnlineAdapter;

	@Inject
	public NotificationClientRegistrationApi(
			NotificationManager notificationManager,
			@Named(AdapterModule.ADAPTER_PEGELONLINE) EplAdapter pegelOnlineAdapter) {

		this.notificationManager = notificationManager;
		this.pegelOnlineAdapter = pegelOnlineAdapter;
	}


	@POST
	public Client register(GcmClientDescription clientDescription) {
		Client client = ClientFactory.createGcmClient(clientDescription.deviceId, pegelOnlineAdapter.toEplStmt(clientDescription.eplArguments));
		notificationManager.register(client);
		return client;
	}


	@POST
	public void unregister(String clientId) {
		notificationManager.unregister(clientId);
	}


	private static final class GcmClientDescription {

		private final String deviceId;
		private final Map<String, String> eplArguments;

		@JsonCreator
		public GcmClientDescription(
				@JsonProperty("deviceId") String deviceId,
				@JsonProperty("eplArguments") Map<String, String> eplArguments) {

			this.deviceId = deviceId;
			this.eplArguments = eplArguments;
		}

	}

}<commit_msg>rest: user jaxrs validation for user input in NotificationClientRegistrationApi<commit_after>package org.jvalue.ceps.rest;


import com.google.inject.Inject;
import com.google.inject.name.Named;

import org.jvalue.ceps.adapter.AdapterModule;
import org.jvalue.ceps.adapter.EplAdapter;
import org.jvalue.ceps.notifications.NotificationManager;
import org.jvalue.ceps.notifications.clients.Client;
import org.jvalue.ceps.notifications.clients.ClientFactory;

import java.util.Map;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/clients")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public final class NotificationClientRegistrationApi {

	private final NotificationManager notificationManager;
	private final EplAdapter pegelOnlineAdapter;

	@Inject
	public NotificationClientRegistrationApi(
			NotificationManager notificationManager,
			@Named(AdapterModule.ADAPTER_PEGELONLINE) EplAdapter pegelOnlineAdapter) {

		this.notificationManager = notificationManager;
		this.pegelOnlineAdapter = pegelOnlineAdapter;
	}


	@POST
	public Client register(@Valid GcmClientDescription clientDescription) {
		Client client = ClientFactory.createGcmClient(clientDescription.deviceId, pegelOnlineAdapter.toEplStmt(clientDescription.eplArguments));
		notificationManager.register(client);
		return client;
	}


	@POST
	public void unregister(String clientId) {
		notificationManager.unregister(clientId);
	}


	private static final class GcmClientDescription {

		@NotNull private String deviceId;
		@NotNull private Map<String, String> eplArguments;

	}

}
{'fraction_non_alphanumeric': 0.08695652173913043, 'fraction_numerical': 0.0, 'mean_word_length': 6.393213572854291, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '2771562', 'n_tokens_mistral': 1159, 'n_tokens_neox': 1079, 'n_words': 205}