Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element minOccurs="0" name="apiVersion" type="xsd:string"/>
<xsd:element minOccurs="0" name="baseApiEndpoint" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
Expand Down Expand Up @@ -316,6 +317,7 @@
<xsd:complexContent>
<xsd:extension base="tns:ConnDevNamedInfoType">
<xsd:sequence>
<xsd:element name="displayName" type="xsd:string"/>
<xsd:element name="shortDescription" type="xsd:string"/>
<xsd:element name="subject" type="xsd:string"/>
<xsd:element name="subjectAttribute" type="xsd:string"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public static ObjectNode mapRelationsToJson(List<ConnDevRelationInfoType> 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()));
Expand All @@ -178,6 +179,7 @@ public static ObjectNode mapRelationsToJson(List<ConnDevRelationInfoType> relati
public static ConnDevRelationInfoType mapRelationFromJson(JsonNode object, List<ConnDevBasicObjectClassInfoType> 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")));
Expand All @@ -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) {
Expand Down
Loading