<commit_before>package de.fau.cs.mad.kwikshop.common.rest;

import de.fau.cs.mad.kwikshop.common.SynchronizationLease;
import de.fau.cs.mad.kwikshop.common.User;
import io.dropwizard.auth.Auth;
import io.dropwizard.hibernate.UnitOfWork;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

@Path("lease")
public interface LeaseResource {

    /**
     * Requests a new synchronization
     * @param user The user requesting the lease
     * @param clientId the id identifying the client requesting the lease
     * @return Returns the synchronization lease
     */
    @PUT
    @UnitOfWork
    @Produces(MediaType.APPLICATION_JSON)
    SynchronizationLease getSynchronizationLease(@Auth User user, @HeaderParam(Constants.KWIKSHOP_CLIENT_ID) String clientId);

    /**
     * Extends the specified lease
     * @param user The user requesting the extended lease (has to be the same user that originally created the lease)
     * @param leaseId The id of the lease to extend
     * @param clientId the id identifying the client requesting the lease (has to be the same client that originally created the lease)<commit_msg>Added request filter that ensures a calling client has a valid lease for all resources annotated with @RequiresLease<commit_after>package de.fau.cs.mad.kwikshop.common.rest;

import de.fau.cs.mad.kwikshop.common.SynchronizationLease;
import de.fau.cs.mad.kwikshop.common.User;
import io.dropwizard.auth.Auth;
import io.dropwizard.hibernate.UnitOfWork;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@Path("lease")
public interface LeaseResource {


    Response.Status LEASE_DENIED_STATUS_CODE = Response.Status.FORBIDDEN;

    /**
     * Requests a new synchronization
     * @param user The user requesting the lease
     * @param clientId the id identifying the client requesting the lease
     * @return Returns the synchronization lease
     */
    @PUT
    @UnitOfWork
    @Produces(MediaType.APPLICATION_JSON)
    SynchronizationLease getSynchronizationLease(@Auth User user, @HeaderParam(Constants.KWIKSHOP_CLIENT_ID) String clientId);

    /**
     * Extends the specified lease
     * @param user The user requesting the extended lease (has to be the same user that originally created the lease)
     * @param leaseId The id of the lease to extend
     * @param clientId the id identifying the client requesting the lease (has to be the same client that originally created the lease)
{'fraction_non_alphanumeric': 0.07667342799188641, 'fraction_numerical': 0.0, 'mean_word_length': 4.0020283975659225, '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': '6647959', 'n_tokens_mistral': 727, 'n_tokens_neox': 706, 'n_words': 235}