-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
#238 [refactor] 회의 ID 디코딩 로직 리팩토링
- Loading branch information
Showing
4 changed files
with
45 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
src/main/java/com/asap/server/config/resolver/meeting/MeetingPathResolver.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/com/asap/server/config/resolver/meeting/MeetingPathVariableResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.asap.server.config.resolver.meeting; | ||
|
||
import com.asap.server.common.utils.SecureUrlUtil; | ||
import com.asap.server.exception.model.BadRequestException; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.core.MethodParameter; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.bind.support.WebDataBinderFactory; | ||
import org.springframework.web.context.request.NativeWebRequest; | ||
import org.springframework.web.method.support.HandlerMethodArgumentResolver; | ||
import org.springframework.web.method.support.ModelAndViewContainer; | ||
import org.springframework.web.servlet.HandlerMapping; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import java.util.Map; | ||
|
||
import static com.asap.server.exception.Error.INVALID_MEETING_URL_EXCEPTION; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class MeetingPathVariableResolver implements HandlerMethodArgumentResolver { | ||
private static final String MEETING_PATH_VARIABLE = "meetingId"; | ||
private final SecureUrlUtil secureUrlUtil; | ||
|
||
@Override | ||
public boolean supportsParameter(MethodParameter parameter) { | ||
return parameter.hasParameterAnnotation(MeetingPathVariable.class); | ||
} | ||
|
||
@Override | ||
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { | ||
final HttpServletRequest request = (HttpServletRequest) webRequest.getNativeRequest(); | ||
final Map<String, String> pathVariables = (Map<String, String>) request.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE); | ||
|
||
final String meetingId = pathVariables.get(MEETING_PATH_VARIABLE); | ||
try { | ||
return secureUrlUtil.decodeUrl(meetingId); | ||
} catch (NumberFormatException e) { | ||
throw new BadRequestException(INVALID_MEETING_URL_EXCEPTION); | ||
} | ||
} | ||
} |