Class OperationIdIdentificationStrategy

java.lang.Object
de.hybris.platform.webservicescommons.api.restrictions.strategies.impl.OperationIdIdentificationStrategy
All Implemented Interfaces:
EndpointIdentificationStrategy

public class OperationIdIdentificationStrategy extends Object implements EndpointIdentificationStrategy
Implementation of EndpointIdentificationStrategy that uses information in the endpoint's context to determine an endpoint ID.

An endpoint ID is determined as a value of "operationId" attribute of the Operation annotation extracted from method of the endpoint controller class.

In case there is no Operation annotation or "operationId" attribute, then the endpoint ID is determined by name of the endpoint method and the name of the HTTP request method specified by the RequestMapping annotation.

If the RequestMapping or Operation is not present the empty Optional is returned.

The strategy caches the found endpoint IDs for methods, so the IDs are not recalculated.

  • Constructor Details

    • OperationIdIdentificationStrategy

      public OperationIdIdentificationStrategy()
  • Method Details

    • findEndpointId

      public Optional<String> findEndpointId(EndpointContextData endpointContextData)
      Finds the endpoint ID based on method attribute of the endpoint's context data.

      Returns the empty Optional in case the method is not specified or the RequestMapping method annotation is not present or it is unable to determine the endpoint ID.

      Throws IllegalArgumentException in case the endpointContextData argument is null.

      Specified by:
      findEndpointId in interface EndpointIdentificationStrategy
      Parameters:
      endpointContextData - endpoint's context data
      Returns:
      Optional with endpoint ID or empty result
    • getByEndpointMethod

      protected String getByEndpointMethod(Method endpointMethod)
      Gets an endpoint ID based on endpoint method information. If the RequestMapping annotation is not present, the method returns null value.
      Parameters:
      endpointMethod - endpoint method
      Returns:
      endpoint identifier or null
    • getByApiOperationNickname

      protected String getByApiOperationNickname(Method endpointMethod)
      Gets an endpoint ID as a "operationId" attribute of Operation annotation of the given endpoint method.

      Returns the endpoint ID or null if the Operation annotation or "operationId" attribute is not present.

      Parameters:
      endpointMethod - endpoint method
      Returns:
      endpoint ID or null
    • getByRequestMethod

      protected String getByRequestMethod(org.springframework.web.bind.annotation.RequestMapping requestMapping, Method endpointMethod)
      Gets endpoint ID basing on RequestMapping annotation and endpoint method name.

      Returns endpoint ID in the "{endpointMethodName}Using{requestMethodName}" format.

      The name of HTTP request method is determined based on RequestMapping annotation.

      In case there is no request method specified then the GET request method is taken.

      Parameters:
      requestMapping - request mapping annotation object
      endpointMethod - endpoint method
      Returns:
      endpoint ID
    • getRequestMethodName

      protected String getRequestMethodName(org.springframework.web.bind.annotation.RequestMapping requestMapping)
      Gets name of HTTP request method from given RequestMapping annotation.

      The RequestMethod.GET name is returned in case the "method" attribute is not present in the RequestMapping annotation.

      Parameters:
      requestMapping - RequestMapping annotation
      Returns:
      name of HTTP request method
    • formatEndpointId

      protected String formatEndpointId(String endpointMethodName, 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 method
      requestMethodName - name of HTTP request method
      Returns:
      formatted endpoint ID
    • getEndpointIdCache

      protected Map<Method,String> getEndpointIdCache()