-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle duplicate context path's (#27)
Fixes https://github.com/camunda/connector-sdk-inbound-webhook/issues/25 Co-authored-by: Igor Petrov <[email protected]>
- Loading branch information
1 parent
6db4b44
commit e757b09
Showing
14 changed files
with
613 additions
and
121 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/main/java/io/camunda/connector/inbound/feel/FeelConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.camunda.connector.inbound.feel; | ||
|
||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class FeelConfiguration { | ||
|
||
/** | ||
* Provides a {@link FeelEngineWrapper} unless already present in the Spring Context | ||
* (as also used by other applications - as soon as we switch to use the one from util | ||
*/ | ||
@Bean | ||
//@ConditionalOnMissingBean(FeelEngineWrapper.class) | ||
public FeelEngineWrapper feelEngine() { | ||
return new FeelEngineWrapper(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
181 changes: 181 additions & 0 deletions
181
src/main/java/io/camunda/connector/inbound/operate/OperateClientLifecycle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
package io.camunda.connector.inbound.operate; | ||
|
||
import io.camunda.operate.CamundaOperateClient; | ||
import io.camunda.operate.dto.*; | ||
import io.camunda.operate.exception.OperateException; | ||
import io.camunda.operate.search.SearchQuery; | ||
import io.camunda.zeebe.model.bpmn.BpmnModelInstance; | ||
import org.apache.hc.core5.http.ClassicHttpRequest; | ||
import org.apache.hc.core5.http.Header; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.SmartLifecycle; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
import java.util.function.Supplier; | ||
|
||
/** | ||
* Lifecycle implementation that also directly acts as a CamundaOperateClient by delegating all methods to the | ||
* CamundaOperateClient that is controlled (and kept in the delegate field) | ||
* | ||
*/ | ||
@Component | ||
public class OperateClientLifecycle extends CamundaOperateClient implements SmartLifecycle, Supplier<CamundaOperateClient> { | ||
|
||
public static final int PHASE = 22222; | ||
protected boolean autoStartup = true; | ||
protected boolean running = false; | ||
protected boolean runningInTestContext = false; | ||
|
||
protected final OperateClientFactory factory; | ||
protected CamundaOperateClient delegate; | ||
|
||
@Autowired | ||
public OperateClientLifecycle(final OperateClientFactory factory) { | ||
this.factory = factory; | ||
} | ||
|
||
/** | ||
* Allows to set the delegate being used manually, helpful for test cases | ||
*/ | ||
public OperateClientLifecycle(final CamundaOperateClient delegate) { | ||
this.factory = null; | ||
this.delegate = delegate; | ||
} | ||
|
||
@Override | ||
public void start() { | ||
if (factory!=null) { | ||
try { | ||
delegate = factory.camundaOperateClient(); | ||
} catch (OperateException e) { | ||
throw new RuntimeException("Could not start Camunda Operate Client: "+ e.getMessage(), e); | ||
} | ||
this.running = true; | ||
} else { | ||
// in test cases we have injected a delegate already | ||
runningInTestContext = true; | ||
} | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
try { | ||
delegate = null; | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} finally { | ||
running = false; | ||
} | ||
} | ||
|
||
|
||
@Override | ||
public CamundaOperateClient get() { | ||
if (!isRunning()) { | ||
throw new IllegalStateException("CamundaOperateClient is not yet created!"); | ||
} | ||
return delegate; | ||
} | ||
|
||
@Override | ||
public boolean isAutoStartup() { | ||
return autoStartup; | ||
} | ||
|
||
|
||
@Override | ||
public boolean isRunning() { | ||
return running; | ||
} | ||
|
||
@Override | ||
public int getPhase() { | ||
return PHASE; | ||
} | ||
|
||
@Override | ||
public ProcessDefinition getProcessDefinition(Long key) throws OperateException { | ||
return delegate.getProcessDefinition(key); | ||
} | ||
|
||
@Override | ||
public List<ProcessDefinition> searchProcessDefinitions(SearchQuery query) throws OperateException { | ||
return delegate.searchProcessDefinitions(query); | ||
} | ||
|
||
@Override | ||
public String getProcessDefinitionXml(Long key) throws OperateException { | ||
return delegate.getProcessDefinitionXml(key); | ||
} | ||
|
||
@Override | ||
public BpmnModelInstance getProcessDefinitionModel(Long key) throws OperateException { | ||
return delegate.getProcessDefinitionModel(key); | ||
} | ||
|
||
@Override | ||
public ProcessInstance getProcessInstance(Long key) throws OperateException { | ||
return delegate.getProcessInstance(key); | ||
} | ||
|
||
@Override | ||
public List<ProcessInstance> searchProcessInstances(SearchQuery query) throws OperateException { | ||
return delegate.searchProcessInstances(query); | ||
} | ||
|
||
@Override | ||
public FlownodeInstance getFlownodeInstance(Long key) throws OperateException { | ||
return delegate.getFlownodeInstance(key); | ||
} | ||
|
||
@Override | ||
public List<FlownodeInstance> searchFlownodeInstances(SearchQuery query) throws OperateException { | ||
return delegate.searchFlownodeInstances(query); | ||
} | ||
|
||
@Override | ||
public Incident getIncident(Long key) throws OperateException { | ||
return delegate.getIncident(key); | ||
} | ||
|
||
@Override | ||
public List<Incident> searchIncidents(SearchQuery query) throws OperateException { | ||
return delegate.searchIncidents(query); | ||
} | ||
|
||
@Override | ||
public Variable getVariable(Long key) throws OperateException { | ||
return delegate.getVariable(key); | ||
} | ||
|
||
@Override | ||
public List<Variable> searchVariables(SearchQuery query) throws OperateException { | ||
return delegate.searchVariables(query); | ||
} | ||
|
||
@Override | ||
public String getOperateUrl() { | ||
return delegate.getOperateUrl(); | ||
} | ||
|
||
@Override | ||
public void setOperateUrl(String operateUrl) { | ||
delegate.setOperateUrl(operateUrl); | ||
} | ||
|
||
@Override | ||
public Header getAuthHeader() { | ||
return delegate.getAuthHeader(); | ||
} | ||
|
||
@Override | ||
public void setAuthHeader(Header authHeader) { | ||
delegate.setAuthHeader(authHeader); | ||
} | ||
|
||
@Override | ||
public void setTokenExpiration(int tokenExpiration) { | ||
delegate.setTokenExpiration(tokenExpiration); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.