Class SevenProviderBase

java.lang.Object
org.cibseven.webapp.providers.SevenProviderBase

public abstract class SevenProviderBase extends Object
  • Field Details

    • USER_ID_HEADER

      protected static final String USER_ID_HEADER
      See Also:
    • cibsevenUrl

      @Value("${cibseven.webclient.engineRest.url:./}") protected String cibsevenUrl
    • engineRestPath

      @Value("${cibseven.webclient.engineRest.path:/engine-rest}") protected String engineRestPath
    • customRestTemplate

      @Autowired protected CustomRestTemplate customRestTemplate
    • baseUserProvider

      @Autowired @Lazy protected BaseUserProvider<? extends org.cibseven.webapp.auth.rest.StandardLogin> baseUserProvider
  • Constructor Details

    • SevenProviderBase

      public SevenProviderBase()
  • Method Details

    • getEngineRestUrl

      protected String getEngineRestUrl(CIBUser user)
      Constructs the full engine REST base URL using the engine ID from the user object. The engine ID format is "{url}|{path}|{engineName}". Example: "http://localhost:8080|/engine-rest|default"
      Parameters:
      user - the user object containing the engine ID
      Returns:
      the complete engine REST URL
    • getEngineRestUrl

      protected String getEngineRestUrl()
      Constructs the base engine REST URL without engine context. Use this for engine-agnostic operations.
      Returns:
      the base engine REST URL
    • createAuthHeader

      protected org.springframework.http.HttpHeaders createAuthHeader(CIBUser user)
      Creates new Http headers and adds Authorization User token
      Parameters:
      user - user with authorization to add if null No authorization is added
      Returns:
    • httpEntity

      protected <T> org.springframework.http.HttpEntity<T> httpEntity(T body, org.springframework.http.HttpHeaders httpHeaders)
      Creates an HttpEntity with body and headers, converting HttpHeaders to a LinkedMultiValueMap to avoid IncompatibleClassChangeError in Spring 7 where HttpHeaders no longer implements MultiValueMap.
    • httpEntity

      protected org.springframework.http.HttpEntity<?> httpEntity(org.springframework.http.HttpHeaders httpHeaders)
      Headers-only variant — used for GET-style requests that send no body.
    • doGet

      protected <T> org.springframework.http.ResponseEntity<T> doGet(String url, Class<T> neededClass, CIBUser user, Boolean encoded)
    • doGetWithHeader

      protected <T> org.springframework.http.ResponseEntity<T> doGetWithHeader(String url, Class<T> neededClass, CIBUser user, Boolean encoded, org.springframework.http.MediaType mediaType)
    • doGet

      protected <T> org.springframework.http.ResponseEntity<T> doGet(org.springframework.web.util.UriComponentsBuilder builder, Class<T> neededClass, CIBUser user)
    • doGet

      protected <T> org.springframework.http.ResponseEntity<T> doGet(String url, org.springframework.core.ParameterizedTypeReference<T> neededClass, CIBUser user)
    • doPost

      protected <T> org.springframework.http.ResponseEntity<T> doPost(String url, Map<String,Object> body, Class<T> neededClass, CIBUser user)
    • doPost

      protected <T> org.springframework.http.ResponseEntity<T> doPost(String url, com.fasterxml.jackson.databind.node.ObjectNode body, Class<T> neededClass, CIBUser user)
    • doPostParameterized

      protected <T> org.springframework.http.ResponseEntity<T> doPostParameterized(String url, Map<String,Object> body, org.springframework.core.ParameterizedTypeReference<T> neededClass, CIBUser user)
    • doPost

      protected <T> org.springframework.http.ResponseEntity<T> doPost(String url, String body, Class<T> neededClass, CIBUser user)
    • doPostMultipart

      protected <T> org.springframework.http.ResponseEntity<T> doPostMultipart(String url, org.springframework.util.MultiValueMap<String,Object> formData, Class<T> neededClass, CIBUser user)
      Performs a POST request with multipart form data
      Parameters:
      url - the URL to post to
      formData - the multipart form data containing files and parameters
      neededClass - the expected response class
      user - the user context for authentication
      Returns:
      the response entity
    • doPut

      protected void doPut(String url, String body, CIBUser user)
    • doPut

      protected void doPut(String url, Map<String,Object> body, CIBUser user)
    • doDelete

      protected void doDelete(String url, CIBUser user)
    • doPatch

      protected <T> org.springframework.http.ResponseEntity<T> doPatch(String url, Map<String,Object> body, Class<T> neededClass, CIBUser user)
    • doPatch

      protected <T> org.springframework.http.ResponseEntity<T> doPatch(String url, String body, Class<T> neededClass, CIBUser user)
    • createPatchRestTemplate

      protected org.springframework.web.client.RestTemplate createPatchRestTemplate()
      Creates a new RestTemplate instance configured for PATCH operations. IMPORTANT: This method creates a new RestTemplate instance instead of modifying the shared customRestTemplate. Modifying the shared RestTemplate would cause ConcurrentModificationException in multi-threaded environments for the following reasons: 1. RestTemplate's message converters list is not thread-safe for modifications 2. When multiple threads simultaneously call methods that use RestTemplate (like doGet), they can attempt to modify the message converters list at the same time 3. This causes java.util.ConcurrentModificationException in ArrayList$ArrayListSpliterator.forEachRemaining when the RestTemplate tries to iterate through its converters while another thread is modifying them By creating a new RestTemplate instance for each call, we avoid shared state modification while still benefiting from the configuration of the customRestTemplate by copying its converters.
      Returns:
      A newly configured RestTemplate instance
    • filterResources

      public static Collection<Authorization> filterResources(Collection<Authorization> authorizations, int resourceType)
    • wrapException

      protected static RuntimeException wrapException(org.springframework.web.client.HttpStatusCodeException cause, CIBUser user)
    • addQueryParameter

      protected String addQueryParameter(String param, String name, Optional<String> value, boolean encode)
    • encodeQueryParams

      protected String encodeQueryParams(Map<String,Object> queryParams)