com.fivefaces.cloud.workflow.function.DeleteStructure Maven / Gradle / Ivy
package com.fivefaces.cloud.workflow.function;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fivefaces.common.util.JsonUtils;
import org.json.JSONObject;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.util.UriComponentsBuilder;
public class DeleteStructure extends Function {
public static final String FUNCTION_NAME = "DELETE_STRUCTURE";
public DeleteStructure(RestTemplateBuilder restTemplateBuilder) {
super(restTemplateBuilder);
}
@Override
public void setup(JSONObject jsonObject) {
}
@Override
public JSONObject process(JSONObject jsonParameters) throws JsonProcessingException {
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8081/api/v1/structure/deleteFromWorkflow");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
MultiValueMap requestMap = new LinkedMultiValueMap<>();
JSONObject inputJson = (JSONObject) jsonParameters.get("delete");
requestMap.add("queryJSON", new JsonUtils().marshall(inputJson.toString()));
HttpEntity> request = new HttpEntity<>(requestMap, headers);
restTemplateBuilder.build().postForEntity(builder.build().encode().toUri(), request, String.class);
return new JSONObject("{}");
}
@Override
public void cleanup(JSONObject jsonObject) {
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy