Class OperationIdIdentificationStrategy
- java.lang.Object
-
- de.hybris.platform.webservicescommons.api.restrictions.strategies.impl.OperationIdIdentificationStrategy
-
- All Implemented Interfaces:
EndpointIdentificationStrategy
public class OperationIdIdentificationStrategy extends java.lang.Object implements EndpointIdentificationStrategy
Implementation ofEndpointIdentificationStrategythat uses information in the endpoint's context to determine an endpoint ID.An endpoint ID is determined as a value of "nickname" attribute of the
ApiOperationannotation extracted from method of the endpoint controller class.In case there is no
ApiOperationannotation or "nickname" attribute, then the endpoint ID is determined by name of the endpoint method and the name of the HTTP request method specified by theRequestMappingannotation.If the
RequestMappingorApiOperationis not present the emptyOptionalis returned.The strategy caches the found endpoint IDs for methods, so the IDs are not recalculated.
-
-
Constructor Summary
Constructors Constructor Description OperationIdIdentificationStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<java.lang.String>findEndpointId(EndpointContextData endpointContextData)Finds the endpoint ID based on method attribute of the endpoint's context data.protected java.lang.StringformatEndpointId(java.lang.String endpointMethodName, java.lang.String requestMethodName)Formats endpoint ID basing on name of HTTP request method and name of endpoint method name.protected java.lang.StringgetByApiOperationNickname(java.lang.reflect.Method endpointMethod)Gets an endpoint ID as a "nickname" attribute ofApiOperationannotation of the given endpoint method.protected java.lang.StringgetByEndpointMethod(java.lang.reflect.Method endpointMethod)Gets an endpoint ID based on endpoint method information.protected java.lang.StringgetByRequestMethod(org.springframework.web.bind.annotation.RequestMapping requestMapping, java.lang.reflect.Method endpointMethod)Gets endpoint ID basing onRequestMappingannotation and endpoint method name.protected java.util.Map<java.lang.reflect.Method,java.lang.String>getEndpointIdCache()protected java.lang.StringgetRequestMethodName(org.springframework.web.bind.annotation.RequestMapping requestMapping)Gets name of HTTP request method from givenRequestMappingannotation.
-
-
-
Method Detail
-
findEndpointId
public java.util.Optional<java.lang.String> findEndpointId(EndpointContextData endpointContextData)
Finds the endpoint ID based on method attribute of the endpoint's context data.Returns the empty
Optionalin case the method is not specified or theRequestMappingmethod annotation is not present or it is unable to determine the endpoint ID.Throws
IllegalArgumentExceptionin case theendpointContextDataargument is null.- Specified by:
findEndpointIdin interfaceEndpointIdentificationStrategy- Parameters:
endpointContextData- endpoint's context data- Returns:
Optionalwith endpoint ID or empty result
-
getByEndpointMethod
protected java.lang.String getByEndpointMethod(java.lang.reflect.Method endpointMethod)
Gets an endpoint ID based on endpoint method information. If theRequestMappingannotation is not present, the method returns null value.- Parameters:
endpointMethod- endpoint method- Returns:
- endpoint identifier or null
-
getByApiOperationNickname
protected java.lang.String getByApiOperationNickname(java.lang.reflect.Method endpointMethod)
Gets an endpoint ID as a "nickname" attribute ofApiOperationannotation of the given endpoint method.Returns the endpoint ID or null if the
ApiOperationannotation or "nickname" attribute is not present.- Parameters:
endpointMethod- endpoint method- Returns:
- endpoint ID or null
-
getByRequestMethod
protected java.lang.String getByRequestMethod(org.springframework.web.bind.annotation.RequestMapping requestMapping, java.lang.reflect.Method endpointMethod)Gets endpoint ID basing onRequestMappingannotation and endpoint method name.Returns endpoint ID in the "{endpointMethodName}Using{requestMethodName}" format.
The name of HTTP request method is determined based on
RequestMappingannotation.In case there is no request method specified then the GET request method is taken.
- Parameters:
requestMapping- request mapping annotation objectendpointMethod- endpoint method- Returns:
- endpoint ID
-
getRequestMethodName
protected java.lang.String getRequestMethodName(org.springframework.web.bind.annotation.RequestMapping requestMapping)
Gets name of HTTP request method from givenRequestMappingannotation.The
RequestMethod.GETname is returned in case the "method" attribute is not present in theRequestMappingannotation.- Parameters:
requestMapping-RequestMappingannotation- Returns:
- name of HTTP request method
-
formatEndpointId
protected java.lang.String formatEndpointId(java.lang.String endpointMethodName, java.lang.String requestMethodName)Formats endpoint ID basing on name of HTTP request method and name of endpoint method name.Returns endpoint ID in the "{endpointMethodName}Using{requestMethodName}" format.
- Parameters:
endpointMethodName- name of endpoint methodrequestMethodName- name of HTTP request method- Returns:
- formatted endpoint ID
-
getEndpointIdCache
protected java.util.Map<java.lang.reflect.Method,java.lang.String> getEndpointIdCache()
-
-