io.gumga.security.GumgaSoftwareSaaS Maven / Gradle / Ivy
package io.gumga.security;
import io.gumga.core.GumgaThreadScope;
import io.gumga.core.GumgaValues;
import io.gumga.domain.saas.GumgaSaaS;
import io.gumga.presentation.CustomGumgaRestTemplate;
import io.gumga.presentation.api.GumgaJsonRestTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import java.util.Map;
import org.springframework.web.client.RestClientException;
/**
* Classe com métodos para integração Saas
*/
@RestController
@RequestMapping(path = "/api/proxy/security-saas")
public class GumgaSoftwareSaaS {
@Autowired
private GumgaValues gumgaValues;
@Autowired(required = false)
private CustomGumgaRestTemplate gumgaRestTemplate;
private String getBaseUrl() {
return gumgaValues.getGumgaSecurityUrl().replace("/publicoperations", "/api/security-saas");
}
private RestTemplate restTemplate;
private RestTemplate getRestTemplate() {
if (restTemplate == null) {
restTemplate = new GumgaJsonRestTemplate();
restTemplate = gumgaRestTemplate != null ? gumgaRestTemplate.getRestTemplate(restTemplate) : restTemplate;
}
return restTemplate;
}
/**
* Registra instância
* @param gumgaSaaS {@link GumgaSaaS}
* @return Instância
*/
@RequestMapping(value = "/instance", method = RequestMethod.POST)
public ResponseEntity registerSaaS(@RequestBody GumgaSaaS gumgaSaaS) {
return post("/instance", gumgaSaaS);
}
private ResponseEntity