Skip to content

Commit

Permalink
migrate LegacyDevice to repository pattern
Browse files Browse the repository at this point in the history
infeo committed Mar 20, 2024

Verified

This commit was signed with the committer’s verified signature.
infeo Armin Schrenk
1 parent 1bb99fc commit 2a6aa47
Showing 3 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -63,6 +63,8 @@ public class DeviceResource {
DeviceRepository deviceRepo;
@Inject
LegacyAccessTokenRepository legacyAccessTokenRepo;
@Inject
LegacyDeviceRepository legacyDeviceRepo;

@Inject
JsonWebToken jwt;
@@ -98,8 +100,8 @@ public Response createOrUpdate(@Valid @NotNull DeviceDto dto, @PathParam("device
device.setCreationTime(Instant.now().truncatedTo(ChronoUnit.MILLIS));
device.setType(dto.type != null ? dto.type : Device.Type.DESKTOP); // default to desktop for backwards compatibilit);

if (LegacyDevice.deleteById(device.getId())) {
assert LegacyDevice.findById(device.getId()) == null;
if (legacyDeviceRepo.deleteById(device.getId())) {
assert legacyDeviceRepo.findById(device.getId()) == null;
LOG.info("Deleted Legacy Device during re-registration of Device " + deviceId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.cryptomator.hub.api;

import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase;
import jakarta.enterprise.context.ApplicationScoped;
import org.cryptomator.hub.entities.LegacyDevice;

@ApplicationScoped
@Deprecated
public class LegacyDeviceRepository implements PanacheRepositoryBase<LegacyDevice, String> {
}
Original file line number Diff line number Diff line change
@@ -9,14 +9,30 @@
@Deprecated
@Entity
@Table(name = "device_legacy")
public class LegacyDevice extends PanacheEntityBase {
public class LegacyDevice {

@Id
@Column(name = "id", nullable = false)
public String id;
String id;

@Column(name = "owner_id", nullable = false)
public String ownerId;
String ownerId;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getOwnerId() {
return ownerId;
}

public void setOwnerId(String ownerId) {
this.ownerId = ownerId;
}

// Further attributes omitted, as they are no longer used. The above ones are exceptions, as they are referenced via JPQL for joining.

0 comments on commit 2a6aa47

Please sign in to comment.