package org.crunchytorch.coddy;

import org.glassfish.jersey.server.ResourceConfig;
import org.springframework.stereotype.Component;
import org.crunchytorch.coddy.application.exception.mapper.*;
import org.crunchytorch.coddy.user.api.User;
import org.crunchytorch.coddy.user.exception.mapper.AuthenticationMapper;
import org.crunchytorch.coddy.user.exception.mapper.NotAuthorizedMapper;
import org.crunchytorch.coddy.application.api.Hello;
import org.crunchytorch.coddy.snippet.api.Snippet;
import org.crunchytorch.coddy.user.exception.mapper.ForbiddenMapper;
import org.crunchytorch.coddy.user.filter.AuthorizationRequestFilter;
import org.crunchytorch.coddy.user.filter.TokenResponseFilter;

import javax.ws.rs.ApplicationPath;

@Component
@ApplicationPath("/api/v1")
public class JerseyConfig extends ResourceConfig {

    public JerseyConfig() {
        // register api endpoint
        register(Hello.class);
        register(User.class);
        register(Snippet.class);

        //register mapper
        // user mapper
        register(SecurityManager.class);
        register(AuthenticationMapper.class);
        register(ForbiddenMapper.class);
        register(NotAuthorizedMapper.class);
        // generic mapper
        register(ExceptMapper.class);
        register(NotFoundMapper.class);
        register(NotSupportedMapper.class);
        register(EntityExistsMapper.class);
        register(EntityNotFoundMapper.class);
        register(NotAllowedMapper.class);

        //register request and response filter
        register(AuthorizationRequestFilter.class);
        register(TokenResponseFilter.class);
    }
}

@@ -77,16 +77,86 @@
 Config;%0A
+import org.glassfish.jersey.server.filter.RolesAllowedDynamicFeature;%0A
 import o
@@ -1033,32 +1033,104 @@
 nippet.class);%0A%0A
+        //security%0A        register(RolesAllowedDynamicFeature.class);%0A%0A
         //regist
@@ -1327,32 +1327,33 @@
 dMapper.class);%0A
+%0A
         // gener

allow rolesAllowed annotation