package org.rest.sec.web.controller;

import javax.servlet.http.HttpServletResponse;

import org.rest.common.util.LinkUtil;
import org.rest.common.web.WebConstants;
import org.rest.sec.web.common.URIMappingConstants;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.util.UriComponentsBuilder;

import com.google.common.net.HttpHeaders;

@Controller
@RequestMapping(value = WebConstants.PATH_SEP)
public class RootController {

    public RootController() {
        super();
    }

    // API

    // search

    @SuppressWarnings("unused")
    @RequestMapping(method = RequestMethod.GET)
    @ResponseStatus(value = HttpStatus.NO_CONTENT)
    public void root(final UriComponentsBuilder uriBuilder, final HttpServletResponse response) {
        final String userUriNew = uriBuilder.path("/" + URIMappingConstants.USERS).build().toUriString();

        final String userUri = LinkUtil.createLinkHeader(WebConstants.PATH_SEP + URIMappingConstants.USERS, LinkUtil.REL_COLLECTION);
        final String roleUri = LinkUtil.createLinkHeader(WebConstants.PATH_SEP + URIMappingConstants.ROLES, LinkUtil.REL_COLLECTION);
        final String privilegeUri = LinkUtil.createLinkHeader(WebConstants.PATH_SEP + URIMappingConstants.PRIVILEGES, LinkUtil.REL_COLLECTION);
        final String discoveredOperations = LinkUtil.gatherLinkHeaders(userUri, roleUri, privilegeUri);
        response.addHeader(HttpHeaders.LINK, discoveredOperations);
    }

}

@@ -627,56 +627,8 @@
 er%0D%0A
-@RequestMapping(value = WebConstants.PATH_SEP)%0D%0A
 publ
@@ -754,157 +754,625 @@
    @
-SuppressWarnings(%22unused%22)%0D%0A    @RequestMapping(method = RequestMethod.GET)%0D%0A    @ResponseStatus(value = HttpStatus.NO_CONTENT)%0D%0A    public void root
+RequestMapping(value = WebConstants.PATH_SEP, method = RequestMethod.GET)%0D%0A    @ResponseStatus(value = HttpStatus.NO_CONTENT)%0D%0A    public void rootWithPathSeparator(final UriComponentsBuilder uriBuilder, final HttpServletResponse response) %7B%0D%0A        rootInternal(uriBuilder, response);%0D%0A    %7D%0D%0A%0D%0A    @RequestMapping(method = RequestMethod.GET)%0D%0A    @ResponseStatus(value = HttpStatus.NO_CONTENT)%0D%0A    public void rootBare(final UriComponentsBuilder uriBuilder, final HttpServletResponse response) %7B%0D%0A        rootInternal(uriBuilder, response);%0D%0A    %7D%0D%0A%0D%0A    @SuppressWarnings(%22unused%22)%0D%0A    private void rootInternal
 (fin

work on discoverability at root