-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of Linked Alerts
When the cot_uuid matches and existing CoT UUID a new CoT event is built and a link tag is added to the new alert Cot
- Loading branch information
Keith Williams
committed
Apr 15, 2021
1 parent
e251ca1
commit d60d084
Showing
6 changed files
with
142 additions
and
36 deletions.
There are no files selected for viewing
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
61 changes: 61 additions & 0 deletions
61
...server-sender-plugin-mcs/src/main/java/tak/server/plugins/missionapi/TakServerCoTApi.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,61 @@ | ||
package tak.server.plugins.missionapi; | ||
|
||
import java.util.concurrent.Future; | ||
|
||
import org.apache.hc.client5.http.async.methods.SimpleHttpRequest; | ||
import org.apache.hc.client5.http.async.methods.SimpleHttpRequests; | ||
import org.apache.hc.client5.http.async.methods.SimpleHttpResponse; | ||
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient; | ||
import org.apache.hc.client5.http.impl.async.HttpAsyncClients; | ||
import org.apache.hc.core5.concurrent.FutureCallback; | ||
import org.apache.hc.core5.http.HttpHost; | ||
import org.apache.hc.core5.reactor.IOReactorConfig; | ||
import org.apache.hc.core5.util.Timeout; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class TakServerCoTApi { | ||
private static final Logger logger = LoggerFactory.getLogger(TakServerCoTApi.class); | ||
|
||
public static void queryForCotEvent(String targetAddress, int targetPort, String uuid, TakServerCoTCallback callback) { | ||
try { | ||
final IOReactorConfig ioReactorConfig = IOReactorConfig.custom() | ||
.setSoTimeout(Timeout.ofSeconds(5)) | ||
.build(); | ||
|
||
final CloseableHttpAsyncClient client = HttpAsyncClients.custom() | ||
.setIOReactorConfig(ioReactorConfig) | ||
.build(); | ||
|
||
client.start(); | ||
|
||
String requestUri = "/Marti/api/cot/xml/" + uuid; | ||
final HttpHost target = new HttpHost(targetAddress, targetPort); | ||
final SimpleHttpRequest httpget = SimpleHttpRequests.get(target, requestUri); | ||
logger.info("Executing request " + httpget.getMethod() + " " + httpget.getUri()); | ||
final Future<SimpleHttpResponse> future = client.execute( | ||
httpget, | ||
new FutureCallback<SimpleHttpResponse>() { | ||
@Override | ||
public void completed(final SimpleHttpResponse response) { | ||
callback.cotResult(response.getCode() == 200, response.getBody().getBodyText()); | ||
} | ||
|
||
@Override | ||
public void failed(final Exception ex) { | ||
logger.error(target.toURI() + requestUri + "->" + ex); | ||
callback.cotResult(false, ""); | ||
} | ||
|
||
@Override | ||
public void cancelled() { | ||
logger.error(target.toURI() + requestUri + " cancelled"); | ||
callback.cotResult(false, ""); | ||
} | ||
}); | ||
} | ||
catch (Exception e) { | ||
logger.info("exception making HTTP request", e); | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...r-sender-plugin-mcs/src/main/java/tak/server/plugins/missionapi/TakServerCoTCallback.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,5 @@ | ||
package tak.server.plugins.missionapi; | ||
|
||
public interface TakServerCoTCallback { | ||
void cotResult(Boolean success, String cot); | ||
} |
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