Skip to content

Commit

Permalink
fix Java client build after upstream changes in Ditto
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Jäckle <thomas.jaeckle@beyonnex.io>
  • Loading branch information
thjaeckle committed Oct 17, 2023
1 parent 526b34b commit 389cec4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@ public Optional<JsonValue> getEntity(final JsonSchemaVersion schemaVersion) {
return ack.getEntity(schemaVersion);
}

@Override
public T setEntity(final JsonValue entity) {
return (T) this;
}

@Override
public T setDittoHeaders(final DittoHeaders dittoHeaders) {
return (T) this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ private CompletionStage<List<Thing>> sendRetrieveThingsMessage(final RetrieveThi
@Nullable
private static Thing transformModifyResponse(final CommandResponse<?> response) {
if (response instanceof WithOptionalEntity) {
return ((WithOptionalEntity) response).getEntity(response.getImplementedSchemaVersion())
return ((WithOptionalEntity<?>) response).getEntity(response.getImplementedSchemaVersion())
.filter(JsonValue::isObject)
.map(JsonValue::asObject)
.map(ThingsModelFactory::newThing)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

import java.util.Optional;

import org.eclipse.ditto.base.model.json.JsonSchemaVersion;
import org.eclipse.ditto.client.live.commands.base.AbstractLiveCommand;
import org.eclipse.ditto.client.live.commands.base.LiveCommand;
import org.eclipse.ditto.client.live.commands.base.LiveCommandAnswerBuilder;
import org.eclipse.ditto.json.JsonValue;
import org.eclipse.ditto.base.model.json.JsonSchemaVersion;
import org.eclipse.ditto.things.model.ThingId;
import org.eclipse.ditto.things.model.signals.commands.modify.ThingModifyCommand;

Expand Down Expand Up @@ -57,4 +57,9 @@ public Optional<JsonValue> getEntity(final JsonSchemaVersion schemaVersion) {
return thingModifyCommand.getEntity(schemaVersion);
}

@Override
@SuppressWarnings("unchecked")
public T setEntity(final JsonValue entity) {
return (T) this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import javax.annotation.Nonnull;

import org.eclipse.ditto.base.model.acks.AcknowledgementLabel;
import org.eclipse.ditto.base.model.acks.DittoAcknowledgementLabel;
import org.eclipse.ditto.client.internal.AbstractHandle;
import org.eclipse.ditto.client.internal.OutgoingMessageFactory;
import org.eclipse.ditto.client.internal.bus.PointerBus;
Expand All @@ -29,12 +31,9 @@
import org.eclipse.ditto.json.JsonFieldSelector;
import org.eclipse.ditto.json.JsonObject;
import org.eclipse.ditto.json.JsonValue;
import org.eclipse.ditto.base.model.acks.AcknowledgementLabel;
import org.eclipse.ditto.base.model.acks.DittoAcknowledgementLabel;
import org.eclipse.ditto.policies.model.PoliciesModelFactory;
import org.eclipse.ditto.policies.model.Policy;
import org.eclipse.ditto.policies.model.PolicyId;
import org.eclipse.ditto.protocol.TopicPath;
import org.eclipse.ditto.policies.model.signals.commands.modify.CreatePolicy;
import org.eclipse.ditto.policies.model.signals.commands.modify.CreatePolicyResponse;
import org.eclipse.ditto.policies.model.signals.commands.modify.DeletePolicy;
Expand All @@ -43,6 +42,7 @@
import org.eclipse.ditto.policies.model.signals.commands.modify.PolicyModifyCommandResponse;
import org.eclipse.ditto.policies.model.signals.commands.query.RetrievePolicy;
import org.eclipse.ditto.policies.model.signals.commands.query.RetrievePolicyResponse;
import org.eclipse.ditto.protocol.TopicPath;

/**
* Default implementation for {@link Policies}.
Expand Down Expand Up @@ -102,9 +102,12 @@ public CompletionStage<Optional<Policy>> put(final Policy policy, final Option<?
return askPolicyCommand(outgoingMessageFactory.putPolicy(policy, options),
// response could be either CreatePolicyResponse or ModifyPolicyResponse.
PolicyModifyCommandResponse.class,
response -> response.getEntity(response.getImplementedSchemaVersion())
.map(JsonValue::asObject)
.map(PoliciesModelFactory::newPolicy)
response -> {
final Optional<JsonValue> entity = response.getEntity(response.getImplementedSchemaVersion());
return entity
.map(JsonValue::asObject)
.map(PoliciesModelFactory::newPolicy);
}
);
}

Expand Down

0 comments on commit 389cec4

Please sign in to comment.