Search in sources :

Example 1 with EntityTags

use of com.netflix.spinnaker.front50.model.tag.EntityTags in project front50 by spinnaker.

the class EntityTagsController method tag.

@RequestMapping(value = "/**", method = RequestMethod.GET)
public EntityTags tag(HttpServletRequest request) {
    String pattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
    final String searchTerm = new AntPathMatcher().extractPathWithinPattern(pattern, request.getServletPath());
    return taggedEntityDAO.map(it -> it.findById(searchTerm)).orElseThrow(() -> new NotFoundException(format("No tags found for '%s'", searchTerm)));
}
Also used : java.util(java.util) Logger(org.slf4j.Logger) MediaType(org.springframework.http.MediaType) HttpServletResponse(javax.servlet.http.HttpServletResponse) LoggerFactory(org.slf4j.LoggerFactory) EntityTags(com.netflix.spinnaker.front50.model.tag.EntityTags) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Strings(com.google.common.base.Strings) HttpStatus(org.springframework.http.HttpStatus) HttpServletRequest(javax.servlet.http.HttpServletRequest) HandlerMapping(org.springframework.web.servlet.HandlerMapping) BadRequestException(com.netflix.spinnaker.front50.exception.BadRequestException) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) EntityTagsDAO(com.netflix.spinnaker.front50.model.tag.EntityTagsDAO) AntPathMatcher(org.springframework.util.AntPathMatcher) NotFoundException(com.netflix.spinnaker.kork.web.exceptions.NotFoundException) NotFoundException(com.netflix.spinnaker.kork.web.exceptions.NotFoundException) AntPathMatcher(org.springframework.util.AntPathMatcher)

Aggregations

Strings (com.google.common.base.Strings)1 BadRequestException (com.netflix.spinnaker.front50.exception.BadRequestException)1 EntityTags (com.netflix.spinnaker.front50.model.tag.EntityTags)1 EntityTagsDAO (com.netflix.spinnaker.front50.model.tag.EntityTagsDAO)1 NotFoundException (com.netflix.spinnaker.kork.web.exceptions.NotFoundException)1 String.format (java.lang.String.format)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 HttpStatus (org.springframework.http.HttpStatus)1 MediaType (org.springframework.http.MediaType)1 AntPathMatcher (org.springframework.util.AntPathMatcher)1 org.springframework.web.bind.annotation (org.springframework.web.bind.annotation)1 HandlerMapping (org.springframework.web.servlet.HandlerMapping)1