Skip to content

Commit

Permalink
fix: add missing command id when adapting legacy to v1
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumelamirand committed Mar 28, 2024
1 parent 221c6a8 commit d3e157b
Show file tree
Hide file tree
Showing 41 changed files with 177 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ public BridgeCommand() {
super(CockpitCommandType.BRIDGE_COMMAND);
}

public BridgeCommand(BridgePayload payload) {
public BridgeCommand(final String commandId, final BridgePayload payload) {
this();
this.id = commandId;
this.payload = payload;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public Single<BridgeCommand> adapt(
BridgeCommandPayload commandPayload = command.getPayload();

BridgeCommand bridgeCommand = new BridgeCommand(
command.getId(),
new BridgePayload(commandPayload.content())
);
bridgeCommand.setTarget(commandPayload.target());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public Single<io.gravitee.cockpit.api.command.v1.bridge.BridgeCommand> adapt(
.timeoutMillis(command.getTimeoutMillis())
.build();
return new io.gravitee.cockpit.api.command.v1.bridge.BridgeCommand(
command.getId(),
bridgeCommandPayload
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package io.gravitee.cockpit.api.command.legacy.bridge;

import io.gravitee.cockpit.api.command.legacy.CockpitReplyType;
import io.gravitee.exchange.api.command.CommandStatus;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -28,11 +29,15 @@ public class BridgeMultiReply extends BridgeReply {
private List<BridgeSimpleReply> replies;

public BridgeMultiReply() {
this(new ArrayList<>());
this(null, null, new ArrayList<>());
}

public BridgeMultiReply(List<BridgeSimpleReply> replies) {
super(CockpitReplyType.BRIDGE_MULTI_REPLY);
public BridgeMultiReply(
final String commandId,
final CommandStatus commandStatus,
final List<BridgeSimpleReply> replies
) {
super(CockpitReplyType.BRIDGE_MULTI_REPLY, commandId, commandStatus);
this.replies = replies;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
*/
public abstract class BridgeReply extends CockpitReply<Payload> {

protected BridgeReply(CockpitReplyType type) {
protected BridgeReply(final CockpitReplyType type) {
this(type, null, null);
}

protected BridgeReply(
CockpitReplyType type,
String commandId,
CommandStatus commandStatus
final CockpitReplyType type,
final String commandId,
final CommandStatus commandStatus
) {
super(type, commandId, commandStatus);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ public Single<BridgeReply> adapt(
createSimpleReplyFrom(reply, bridgeReplyContent)
)
.toList();
return new BridgeMultiReply(simpleReplies);
return new BridgeMultiReply(
reply.getCommandId(),
reply.getCommandStatus(),
simpleReplies
);
}
}
return new BridgeSimpleReply(
Expand All @@ -69,9 +73,10 @@ private BridgeSimpleReply createSimpleReplyFrom(
reply.getCommandStatus(),
reply.getErrorDetails()
);
bridgeSimpleReply.setEnvironmentId(bridgeReplyContent.environmentId());
bridgeSimpleReply.setOrganizationId(bridgeReplyContent.organizationId());
bridgeSimpleReply.setPayloadAsString(bridgeReplyContent.content());
bridgeSimpleReply.setInstallationId(bridgeReplyContent.getInstallationId());
bridgeSimpleReply.setEnvironmentId(bridgeReplyContent.getEnvironmentId());
bridgeSimpleReply.setOrganizationId(bridgeReplyContent.getOrganizationId());
bridgeSimpleReply.setPayloadAsString(bridgeReplyContent.getContent());
return bridgeSimpleReply;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ public DeployModelCommand() {
super(CockpitCommandType.DEPLOY_MODEL_COMMAND);
}

public DeployModelCommand(DeployModelCommandPayload payload) {
public DeployModelCommand(
final String commandId,
final DeployModelCommandPayload payload
) {
this();
this.id = commandId;
this.payload = payload;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public String supportType() {
public Single<DeployModelCommand> adapt(
final io.gravitee.cockpit.api.command.v1.designer.DeployModelCommand command
) {
return Single.just(new DeployModelCommand(command.getPayload()));
return Single.just(
new DeployModelCommand(command.getId(), command.getPayload())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ public DisableEnvironmentCommand() {
super(CockpitCommandType.DISABLE_ENVIRONMENT_COMMAND);
}

public DisableEnvironmentCommand(DisableEnvironmentCommandPayload payload) {
public DisableEnvironmentCommand(
final String commandId,
final DisableEnvironmentCommandPayload payload
) {
this();
this.id = commandId;
this.payload = payload;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public String supportType() {
public Single<DisableEnvironmentCommand> adapt(
final io.gravitee.cockpit.api.command.v1.environment.DisableEnvironmentCommand command
) {
return Single.just(new DisableEnvironmentCommand(command.getPayload()));
return Single.just(
new DisableEnvironmentCommand(command.getId(), command.getPayload())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ public EnvironmentCommand() {
super(CockpitCommandType.ENVIRONMENT_COMMAND);
}

public EnvironmentCommand(EnvironmentCommandPayload payload) {
public EnvironmentCommand(
final String commandId,
final EnvironmentCommandPayload payload
) {
this();
this.id = commandId;
this.payload = payload;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public String supportType() {
public Single<EnvironmentCommand> adapt(
final io.gravitee.cockpit.api.command.v1.environment.EnvironmentCommand command
) {
return Single.just(new EnvironmentCommand(command.getPayload()));
return Single.just(
new EnvironmentCommand(command.getId(), command.getPayload())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
public class HealthCheckCommand
extends CockpitCommand<NodeHealthCheckCommandPayload> {

public HealthCheckCommand() {
public HealthCheckCommand(final String commandId) {
super(CockpitCommandType.HEALTHCHECK_COMMAND);
this.id = commandId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public Single<io.gravitee.cockpit.api.command.v1.node.healthcheck.NodeHealthChec
) {
return Single.just(
new io.gravitee.cockpit.api.command.v1.node.healthcheck.NodeHealthCheckCommand(
command.getId(),
command.getPayload()
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ public HelloCommand() {
super(CockpitCommandType.HELLO_COMMAND);
}

public HelloCommand(HelloCommandPayload payload) {
public HelloCommand(
final String commandId,
final HelloCommandPayload payload
) {
this();
this.id = commandId;
this.payload = payload;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public Single<io.gravitee.cockpit.api.command.v1.hello.HelloCommand> adapt(
return Single.fromCallable(() -> {
HelloCommandPayload legacyPayload = command.getPayload();
return new io.gravitee.cockpit.api.command.v1.hello.HelloCommand(
command.getId(),
HelloCommandPayload
.builder()
.node(legacyPayload.getNode())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,18 @@ public Single<HelloReply> adapt(
reply.getCommandStatus()
);
helloReply.setMessage(reply.getErrorDetails());
helloReply.setInstallationId(reply.getPayload().getInstallationId());
helloReply.setInstallationStatus(
reply.getPayload().getInstallationStatus()
);
helloReply.setDefaultEnvironmentCockpitId(
reply.getPayload().getDefaultEnvironmentCockpitId()
);
helloReply.setDefaultOrganizationCockpitId(
reply.getPayload().getDefaultOrganizationCockpitId()
);
if (reply.getPayload() != null) {
helloReply.setInstallationId(reply.getPayload().getInstallationId());
helloReply.setInstallationStatus(
reply.getPayload().getInstallationStatus()
);
helloReply.setDefaultEnvironmentCockpitId(
reply.getPayload().getDefaultEnvironmentCockpitId()
);
helloReply.setDefaultOrganizationCockpitId(
reply.getPayload().getDefaultOrganizationCockpitId()
);
}
return helloReply;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ public InstallationCommand() {
super(CockpitCommandType.INSTALLATION_COMMAND);
}

public InstallationCommand(InstallationCommandPayload payload) {
public InstallationCommand(
final String commandId,
final InstallationCommandPayload payload
) {
this();
this.id = commandId;
this.payload = payload;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public String supportType() {
public Single<InstallationCommand> adapt(
final io.gravitee.cockpit.api.command.v1.installation.InstallationCommand command
) {
return Single.just(new InstallationCommand(command.getPayload()));
return Single.just(
new InstallationCommand(command.getId(), command.getPayload())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ public UnlinkInstallationCommand() {
super(CockpitCommandType.UNLINK_INSTALLATION_COMMAND);
}

public UnlinkInstallationCommand(UnlinkInstallationCommandPayload payload) {
public UnlinkInstallationCommand(
final String commandId,
final UnlinkInstallationCommandPayload payload
) {
this();
this.id = commandId;
this.payload = payload;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public String supportType() {
public Single<UnlinkInstallationCommand> adapt(
final io.gravitee.cockpit.api.command.v1.installation.UnlinkInstallationCommand command
) {
return Single.just(new UnlinkInstallationCommand(command.getPayload()));
return Single.just(
new UnlinkInstallationCommand(command.getId(), command.getPayload())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ public DeleteMembershipCommand() {
super(CockpitCommandType.DELETE_MEMBERSHIP_COMMAND);
}

public DeleteMembershipCommand(DeleteMembershipCommandPayload payload) {
public DeleteMembershipCommand(
final String commandId,
final DeleteMembershipCommandPayload payload
) {
this();
this.id = commandId;
this.payload = payload;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public String supportType() {
public Single<DeleteMembershipCommand> adapt(
final io.gravitee.cockpit.api.command.v1.membership.DeleteMembershipCommand command
) {
return Single.just(new DeleteMembershipCommand(command.getPayload()));
return Single.just(
new DeleteMembershipCommand(command.getId(), command.getPayload())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ public MembershipCommand() {
super(CockpitCommandType.MEMBERSHIP_COMMAND);
}

public MembershipCommand(MembershipCommandPayload payload) {
public MembershipCommand(
final String commandId,
final MembershipCommandPayload payload
) {
this();
this.id = commandId;
this.payload = payload;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public String supportType() {
public Single<MembershipCommand> adapt(
final io.gravitee.cockpit.api.command.v1.membership.MembershipCommand command
) {
return Single.just(new MembershipCommand(command.getPayload()));
return Single.just(
new MembershipCommand(command.getId(), command.getPayload())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

public class NodeCommand extends CockpitCommand<NodeCommandPayload> {

public NodeCommand() {
public NodeCommand(final String commandId) {
super(CockpitCommandType.NODE_COMMAND);
this.id = commandId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public Single<io.gravitee.cockpit.api.command.v1.node.NodeCommand> adapt(
) {
return Single.just(
new io.gravitee.cockpit.api.command.v1.node.NodeCommand(
command.getId(),
command.getPayload()
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ public DisableOrganizationCommand() {
super(CockpitCommandType.DISABLE_ORGANIZATION_COMMAND);
}

public DisableOrganizationCommand(DisableOrganizationCommandPayload payload) {
public DisableOrganizationCommand(
final String commandId,
final DisableOrganizationCommandPayload payload
) {
this();
this.id = commandId;
this.payload = payload;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public String supportType() {
public Single<DisableOrganizationCommand> adapt(
final io.gravitee.cockpit.api.command.v1.organization.DisableOrganizationCommand command
) {
return Single.just(new DisableOrganizationCommand(command.getPayload()));
return Single.just(
new DisableOrganizationCommand(command.getId(), command.getPayload())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ public OrganizationCommand() {
super(CockpitCommandType.ORGANIZATION_COMMAND);
}

public OrganizationCommand(OrganizationCommandPayload payload) {
public OrganizationCommand(
final String commandId,
final OrganizationCommandPayload payload
) {
this();
this.id = commandId;
this.payload = payload;
}
}
Loading

0 comments on commit d3e157b

Please sign in to comment.