Skip to content

Commit

Permalink
Integration of the functionality to map the DCAT-AP metadata of the f…
Browse files Browse the repository at this point in the history
…ederated catalogues in a Context Broker (#111)

* Updates for Docker secrets management

* Fixed a bug in adding a remote catalogue

* Adding .github/fiware/config.json

* Deleting .github/fiware/config.json

* Adding .github/fiware/config.json

* Deleting .github/fiware/config.json

* Adding .github/fiware/config.json

* Updates

* Updates

* Deleting .github/fiware/config.json

* Adding .github/fiware/config.json

* Updates for the Ngsi_ld Broker Manager and Orion DCAT-AP catalogue

* Updates in configuration properties

* News in Portal for the Ngsi_ld Broker Manager and Orion DCAT-AP Catalog

* News for the Ngsi_ld Broker Manager and Orion DCAT-AP Catalog

* Updates for the Ngsi_ld Broker Manager part

* Updates for the Ngsi_ld Broker Manager part

* Updates in Idra Portal for the NGSI-LD Broker Manager

* Updates in Idra core for the NGSI-LD Broker Manager

* Fixed bugs for the NGSI-LD integration

* Fixed bugs in the Ckan Connector

* Fixed bugs for the NGSI-LD integration

* Repository change for java-checkstyle action

Co-authored-by: fdagresti <fdagresti@host.docker.internal>
Co-authored-by: fdagresti <fdagresti@FDAGRESTIW.mshome.net>
  • Loading branch information
3 people committed Jan 21, 2022
1 parent 7bace09 commit 15bfd3f
Show file tree
Hide file tree
Showing 32 changed files with 2,747 additions and 33 deletions.
20 changes: 20 additions & 0 deletions .github/fiware/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"enabler": "Idra - Open Data Federation Platform",
"chapter": "data publication",
"academy": "/data publication/idra",
"readthedocs": "idra",
"helpdesk": "",
"coverall": "",
"github": ["OPSILab/Idra"],
"dockerbuild": "./workflows/docker-push.yml",
"dockerregistry": ["hub.docker.com"],
"docker": ["idraopendata/idra"],
"email": "idra@eng.it",
"status": "full member",
"compose": "https://raw.githubusercontent.com/OPSILab/Idra/master/docker/docker-compose.yml",
"exclude": ["mongo"],
"stackexchange": [""],
"unit-test": "",
"smoke-test": "",
"dockerfile": "https://raw.githubusercontent.com/OPSILab/Idra/master/docker/Dockerfile"
}
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Run Java Checkstyle
uses: Justintime50/java-checkstyle-action@v1
uses: nikitasavinov/checkstyle-action@master
with:
directory: /Idra/src/main/java/it/eng/idra

Expand Down
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

93 changes: 92 additions & 1 deletion Idra/src/main/java/it/eng/idra/api/AdministrationApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
import it.eng.idra.utils.GsonUtil;
import it.eng.idra.utils.GsonUtilException;
import it.eng.idra.utils.PropertyManager;
import it.eng.idra.utils.restclient.RestClient;
import it.eng.idra.utils.restclient.RestClientImpl;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand All @@ -71,6 +73,7 @@
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.ws.rs.Consumes;
Expand Down Expand Up @@ -100,6 +103,7 @@
import javax.ws.rs.core.StreamingOutput;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
Expand All @@ -119,7 +123,10 @@ public class AdministrationApi {

/** The client. */
private static Client client;


private static String urlOrionmanager =
PropertyManager.getProperty(IdraProperty.ORION_MANAGER_URL);

/**
* getVersion.
*
Expand Down Expand Up @@ -270,6 +277,11 @@ public Response registerOdmsCatalogue(@FormDataParam("dump") InputStream fileInp
if (node.isActive() == null) {
node.setActive(false);
}

if (node.isFederatedInCb() == null) {
node.setFederatedInCb(false);
}


if (node.isActive()) {
FederationCore.registerOdmsCatalogue(node);
Expand Down Expand Up @@ -648,9 +660,86 @@ public Response unregisterOdmsCatalogue(@PathParam("nodeId") String nodeId) {
node = FederationCore.getOdmsCatalogue(Integer.parseInt(nodeId));
logger.info("Deleting ODMS catalogue with host: " + node.getHost() + " and id " + nodeId
+ " - START");

logger.info("Deletion of the Catalogue also in the CB. "
+ "Calling the Broker Manager component.");
HashMap<String, String> conf = FederationCore.getSettings();
if (!conf.get("orionUrl").equals("")) {
Map<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json");
RestClient client = new RestClientImpl();

String api = urlOrionmanager + "deleteCatalogue";
String data = "{ \"catalogueId\": \"" + node.getId() + "\", \"contextBrokerUrl\": \""
+ conf.get("orionUrl") + "\" }";
logger.info("Context Broker enabled, deleting NODEID: " + data);

HttpResponse response = client.sendPostRequest(api, data,
MediaType.APPLICATION_JSON_TYPE, headers);
// int status = client.getStatus(response);

if (response == null) {
logger.info("STATUS POST Delete in the CB, from BROKER MANAGER: -1"
+ ". The NGSI-LD Broker Manager is not running.");
} else {
String body = client.getHttpResponseBody(response);
JSONObject objResponse = new JSONObject(body);
int status = objResponse.getInt("status");

if (status != 200 && status != 207 && status != 204
&& status != 201 && status != 301) {
// the deletion was not successful, still federated in the CB
node.setFederatedInCb(true);
if (status == 400) {
logger.info("STATUS POST Delete in the CB, from BROKER MANAGER: " + status
+ ". Bad Request. Deletion from the CB failed.");
} else {
logger.info("STATUS POST Delete in the CB, from BROKER MANAGER: " + status
+ ". Deletion from the CB failed.");
}
// throw new Exception("------------ STATUS POST DELETE "
// + "CATALOGUE ID - BROKER MANAGER: " + status);
} else {
node.setFederatedInCb(false);
logger.info("Catalogue deleted from the CB.");
}
}


} else {
node.setFederatedInCb(false);
logger.info("Context Broker NOT enabled");
}


FederationCore.unregisterOdmsCatalogue(node);
logger.info(
"Deleting ODMS node with id: " + node.getHost() + " and id " + nodeId + " - COMPLETE");

if (node.getNodeType().equals(OdmsCatalogueType.NGSILD_CB)) {
logger.info("Deletion of the Subscription of the Catalogue, if present");
Map<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json");
RestClient client = new RestClientImpl();

HttpResponse response = client.sendGetRequest(node.getHost()
+ "/ngsi-ld/v1/subscriptions/urn:ngsi-ld:Subscription:" + node.getId(), headers);
int status = client.getStatus(response);
if (status == 200) {
logger.info("The NGSI_LD Catalogue had a Subscription, deleting");
response = client.sendDeleteRequest(node.getHost()
+ "/ngsi-ld/v1/subscriptions/urn:ngsi-ld:Subscription:" + node.getId(), headers);

status = client.getStatus(response);
if (status != 200 && status != 207 && status != 204 && status != -1
&& status != 201 && status != 301) {
throw new Exception("------------ STATUS POST DELETE "
+ "SUBSCRIPTION: " + status);
}
}


}
return Response.status(Response.Status.OK).build();

} catch (NumberFormatException e) {
Expand Down Expand Up @@ -682,6 +771,8 @@ public Response startOdmsCatalogueSynch(@PathParam("nodeId") String nodeId) {
try {
logger.info("Forcing the synchronization for node " + nodeId);
FederationCore.startOdmsCatalogueSynch(nodeIdentifier);

logger.info("Fine funzione sync");
return Response.status(Response.Status.OK).build();

} catch (OdmsCatalogueNotFoundException e) {
Expand Down

0 comments on commit 15bfd3f

Please sign in to comment.