From ee200db289ba74297ddb5cc6492f77df9a79ce35 Mon Sep 17 00:00:00 2001 From: Jan Kamenicky Date: Mon, 4 May 2026 11:09:44 +0000 Subject: [PATCH 1/2] Smart integration: restore metadata on session restore, add apiVersion to schema --- .../public/common/common-connector-dev-3.xsd | 2 + .../conndev/ConnectorDevelopmentBackend.java | 40 +++++++++++++++++++ .../smart/impl/conndev/RestBackend.java | 4 ++ .../impl/mappings/ConnDevJsonMapper.java | 4 +- 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/infra/schema/src/main/resources/xml/ns/public/common/common-connector-dev-3.xsd b/infra/schema/src/main/resources/xml/ns/public/common/common-connector-dev-3.xsd index 554cde41a7b..3ed721ccbc2 100644 --- a/infra/schema/src/main/resources/xml/ns/public/common/common-connector-dev-3.xsd +++ b/infra/schema/src/main/resources/xml/ns/public/common/common-connector-dev-3.xsd @@ -94,6 +94,7 @@ + @@ -316,6 +317,7 @@ + diff --git a/model/smart-impl/src/main/java/com/evolveum/midpoint/smart/impl/conndev/ConnectorDevelopmentBackend.java b/model/smart-impl/src/main/java/com/evolveum/midpoint/smart/impl/conndev/ConnectorDevelopmentBackend.java index bb1c5c79d19..c28c696fed9 100644 --- a/model/smart-impl/src/main/java/com/evolveum/midpoint/smart/impl/conndev/ConnectorDevelopmentBackend.java +++ b/model/smart-impl/src/main/java/com/evolveum/midpoint/smart/impl/conndev/ConnectorDevelopmentBackend.java @@ -466,6 +466,46 @@ protected void restoreAttributes(ServiceClient.RestorationClient client) throws } } + protected void restoreMetadata(ServiceClient.RestorationClient client) throws IOException { + var app = developmentObject().getApplication(); + if (app == null) return; + + var infoMetadata = JSON_FACTORY.objectNode(); + + if (app.getApplicationName() != null) { + infoMetadata.set("name", JSON_FACTORY.textNode(app.getApplicationName().getOrig())); + } + if (app.getVersion() != null) { + infoMetadata.set("applicationVersion", JSON_FACTORY.textNode(app.getVersion())); + } + if (app.getApiVersion() != null) { + infoMetadata.set("apiVersion", JSON_FACTORY.textNode(app.getApiVersion())); + } + if (app.getIntegrationType() != null) { + var apiTypeArray = JSON_FACTORY.arrayNode(); + apiTypeArray.add(app.getIntegrationType().value()); + infoMetadata.set("apiType", apiTypeArray); + } + if (app.getBaseApiEndpoint() != null) { + var endpointEntry = JSON_FACTORY.objectNode(); + endpointEntry.set("uri", JSON_FACTORY.textNode(app.getBaseApiEndpoint())); + endpointEntry.set("type", JSON_FACTORY.textNode("constant")); + var endpointsArray = JSON_FACTORY.arrayNode(); + endpointsArray.add(endpointEntry); + infoMetadata.set("baseApiEndpoint", endpointsArray); + } + + var body = JSON_FACTORY.objectNode(); + body.set("infoMetadata", infoMetadata); + var bodyText = body.toPrettyString(); + + client.put("digester/{sessionId}/metadata", () -> + EntityBuilder.create() + .setContentType(ContentType.APPLICATION_JSON) + .setText(bodyText) + .build()); + } + protected void restoreRelations(ServiceClient.RestorationClient client) throws IOException { var app = developmentObject().getApplication(); if (app == null) return; diff --git a/model/smart-impl/src/main/java/com/evolveum/midpoint/smart/impl/conndev/RestBackend.java b/model/smart-impl/src/main/java/com/evolveum/midpoint/smart/impl/conndev/RestBackend.java index 1151fdd6eef..88ebdba138d 100644 --- a/model/smart-impl/src/main/java/com/evolveum/midpoint/smart/impl/conndev/RestBackend.java +++ b/model/smart-impl/src/main/java/com/evolveum/midpoint/smart/impl/conndev/RestBackend.java @@ -49,6 +49,9 @@ public ConnDevApplicationInfoType discoverBasicInformation(boolean skipCache) { if (jsonInfo.get("applicationVersion") != null) { ret.version(jsonInfo.get("applicationVersion").asText()); } + if (jsonInfo.get("apiVersion") != null) { + ret.apiVersion(jsonInfo.get("apiVersion").asText()); + } // FIXME for proper detection ret.integrationType(ConnDevIntegrationType.REST); if (jsonInfo.get("baseApiEndpoint") != null) { @@ -226,6 +229,7 @@ private String generateObjectClassScript(ConnDevArtifactType artifactSpec, Strin @Override protected void restoreSession(ServiceClient.RestorationClient client) throws IOException { + restoreMetadata(client); ensureDocumentationIsUploaded(client); restoreObjectClasses(client); restoreRelations(client); diff --git a/model/smart-impl/src/main/java/com/evolveum/midpoint/smart/impl/mappings/ConnDevJsonMapper.java b/model/smart-impl/src/main/java/com/evolveum/midpoint/smart/impl/mappings/ConnDevJsonMapper.java index 844e211f3bf..ae5f4cf20d7 100644 --- a/model/smart-impl/src/main/java/com/evolveum/midpoint/smart/impl/mappings/ConnDevJsonMapper.java +++ b/model/smart-impl/src/main/java/com/evolveum/midpoint/smart/impl/mappings/ConnDevJsonMapper.java @@ -163,6 +163,7 @@ public static ObjectNode mapRelationsToJson(List relati for (var relationInfo : relations) { var object = JSON.objectNode(); object.set("name", JSON.textNode(relationInfo.getName())); + object.set("displayName", JSON.textNode(relationInfo.getDisplayName())); object.set("shortDescription", JSON.textNode(relationInfo.getShortDescription())); object.set("subject", JSON.textNode(relationInfo.getSubject())); object.set("subjectAttribute", JSON.textNode(relationInfo.getSubjectAttribute())); @@ -178,6 +179,7 @@ public static ObjectNode mapRelationsToJson(List relati public static ConnDevRelationInfoType mapRelationFromJson(JsonNode object, List discovered) { var ret = new ConnDevRelationInfoType(); ret.setName(toText(object.get("name"))); + ret.setDisplayName(toText(object.get("displayName"))); ret.setObject(toText(object.get("object"))); ret.setObjectAttribute(toText(object.get("objectAttribute"))); ret.setSubject(toText(object.get("subject"))); @@ -187,7 +189,7 @@ public static ConnDevRelationInfoType mapRelationFromJson(JsonNode object, List< ret.setObject(normalize(ret.getObject(), discovered)); ret.setSubject(normalize(ret.getSubject(), discovered)); - if (ret.getSubject() == null) { + if (ret.getSubject() == null || ret.getObject() == null) { return null; } if (ret.getName() == null) { From 2ed8ecaa0c963cabbe6c8c7c639f7fff6c2abe64 Mon Sep 17 00:00:00 2001 From: Jan Kamenicky Date: Tue, 5 May 2026 10:46:35 +0000 Subject: [PATCH 2/2] Smart integration: fix discovery task token return in submitDiscoverObjectClassDetails --- .../smart/impl/conndev/ConnectorDevelopmentServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model/smart-impl/src/main/java/com/evolveum/midpoint/smart/impl/conndev/ConnectorDevelopmentServiceImpl.java b/model/smart-impl/src/main/java/com/evolveum/midpoint/smart/impl/conndev/ConnectorDevelopmentServiceImpl.java index 0664e277912..5c3c3ef39c8 100644 --- a/model/smart-impl/src/main/java/com/evolveum/midpoint/smart/impl/conndev/ConnectorDevelopmentServiceImpl.java +++ b/model/smart-impl/src/main/java/com/evolveum/midpoint/smart/impl/conndev/ConnectorDevelopmentServiceImpl.java @@ -134,8 +134,8 @@ public String submitDiscoverObjectClassEndpoints(String objectClass, Task task, @Deprecated @Override public String submitDiscoverObjectClassDetails(String objectClass, Task task, OperationResult result) { - submitDiscoverObjectClassAttributes(objectClass, task, result); - return submitDiscoverObjectClassEndpoints(objectClass, task, result); + submitDiscoverObjectClassEndpoints(objectClass, task, result); + return submitDiscoverObjectClassAttributes(objectClass, task, result); } @Override