Package org.cibseven.webapp.providers
Class SevenProviderBase
java.lang.Object
org.cibseven.webapp.providers.SevenProviderBase
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BaseUserProvider<? extends org.cibseven.webapp.auth.rest.StandardLogin>protected Stringprotected CustomRestTemplateprotected Stringprotected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringaddQueryParameter(String param, String name, Optional<String> value, boolean encode) protected org.springframework.http.HttpHeaderscreateAuthHeader(CIBUser user) Creates new Http headers and adds Authorization User tokenprotected org.springframework.web.client.RestTemplateCreates a new RestTemplate instance configured for PATCH operations.protected voidprotected <T> org.springframework.http.ResponseEntity<T>protected <T> org.springframework.http.ResponseEntity<T>protected <T> org.springframework.http.ResponseEntity<T>doGet(org.springframework.web.util.UriComponentsBuilder builder, Class<T> neededClass, CIBUser user) protected <T> org.springframework.http.ResponseEntity<T>doGetWithHeader(String url, Class<T> neededClass, CIBUser user, Boolean encoded, org.springframework.http.MediaType mediaType) protected <T> org.springframework.http.ResponseEntity<T>protected <T> org.springframework.http.ResponseEntity<T>protected <T> org.springframework.http.ResponseEntity<T>doPost(String url, com.fasterxml.jackson.databind.node.ObjectNode body, Class<T> neededClass, CIBUser user) protected <T> org.springframework.http.ResponseEntity<T>protected <T> org.springframework.http.ResponseEntity<T>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 dataprotected <T> org.springframework.http.ResponseEntity<T>doPostParameterized(String url, Map<String, Object> body, org.springframework.core.ParameterizedTypeReference<T> neededClass, CIBUser user) protected voidprotected voidprotected StringencodeQueryParams(Map<String, Object> queryParams) static Collection<Authorization>filterResources(Collection<Authorization> authorizations, int resourceType) protected StringConstructs the base engine REST URL without engine context.protected StringgetEngineRestUrl(CIBUser user) Constructs the full engine REST base URL using the engine ID from the user object.protected org.springframework.http.HttpEntity<?>httpEntity(org.springframework.http.HttpHeaders httpHeaders) Headers-only variant — used for GET-style requests that send no body.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.protected static RuntimeExceptionwrapException(org.springframework.web.client.HttpStatusCodeException cause, CIBUser user)
-
Field Details
-
USER_ID_HEADER
- See Also:
-
cibsevenUrl
-
engineRestPath
-
customRestTemplate
-
baseUserProvider
@Autowired @Lazy protected BaseUserProvider<? extends org.cibseven.webapp.auth.rest.StandardLogin> baseUserProvider
-
-
Constructor Details
-
SevenProviderBase
public SevenProviderBase()
-
-
Method Details
-
getEngineRestUrl
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
Constructs the base engine REST URL without engine context. Use this for engine-agnostic operations.- Returns:
- the base engine REST URL
-
createAuthHeader
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
-
doGetWithHeader
-
doGet
-
doGet
-
doPost
-
doPost
-
doPostParameterized
-
doPost
-
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 toformData- the multipart form data containing files and parametersneededClass- the expected response classuser- the user context for authentication- Returns:
- the response entity
-
doPut
-
doPut
-
doDelete
-
doPatch
-
doPatch
-
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
-
encodeQueryParams
-