Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamic consumer version #7

Merged
merged 27 commits into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
31d82e8
use Object instead of generic types
hknots Jul 5, 2024
769bdb6
use Object instead of String
hknots Jul 5, 2024
f79d97a
move packages & remove T of SyncPage
hknots Aug 27, 2024
262be67
move SyncType to metadata & remove reduntant types of sync pages
hknots Aug 30, 2024
f14ea17
add identifikators instead of resource in response
hknots Sep 27, 2024
926ec9a
revert removal of SyncPageEntry & add comment to identifikators
hknots Sep 27, 2024
4a9227c
use interface instead of object for resource
hknots Sep 27, 2024
8ba4907
implement FintResource
hknots Sep 27, 2024
a186e7d
rename to EventIdentifikator
hknots Sep 27, 2024
46ec7a2
add default constructor for list
hknots Sep 27, 2024
bbd0e0c
revert identifikator & interface changes
hknots Sep 30, 2024
c9a665a
remove api & unecessary library
hknots Oct 1, 2024
de90ac4
move SyncType to SyncPage & create types for each SyncType
hknots Oct 1, 2024
7ac5b92
convert value to String
hknots Oct 29, 2024
c282bfd
add syncType in constructor
hknots Oct 29, 2024
1c69bd7
add VALIDATION
hknots Nov 28, 2024
37463d7
add validation to operationtype comments
hknots Nov 28, 2024
74e2a3a
add conflicted field
hknots Nov 29, 2024
90175ee
add conflictReason
hknots Nov 29, 2024
88cca41
handle message & statusCode within static private static methods
hknots Nov 29, 2024
c3465d4
add ResponseStatus
hknots Nov 29, 2024
bd4e7fd
rename argument
hknots Nov 29, 2024
5fbdeb3
add DELETE
hknots Nov 29, 2024
945437a
rename class
hknots Nov 29, 2024
4d5104e
feat: add ResourceEvictionPayload
hknots Mar 19, 2025
96b2761
feat: add field unixTimestamp
hknots Mar 19, 2025
ace08e0
refactor: add default constructor
hknots Mar 20, 2025
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
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ javadoc {
title("FINT Core Infrastructure Models")
}

dependencies {
dependencies {''
implementation 'org.springframework.boot:spring-boot-starter-webflux'

implementation 'org.jetbrains:annotations:23.0.0'

implementation 'no.fint:fint-model-resource:0.4.1'
implementation 'no.fintlabs:fint-model-resource:0.5.0'

//compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/no/fintlabs/adapter/models/DeleteSyncPage.java

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions src/main/java/no/fintlabs/adapter/models/DeltaSyncPage.java

This file was deleted.

This file was deleted.

8 changes: 0 additions & 8 deletions src/main/java/no/fintlabs/adapter/models/FintEvent.java

This file was deleted.

11 changes: 0 additions & 11 deletions src/main/java/no/fintlabs/adapter/models/FullSyncPage.java

This file was deleted.

This file was deleted.

37 changes: 0 additions & 37 deletions src/main/java/no/fintlabs/adapter/models/SyncPage.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package no.fintlabs.adapter.models.event;

import lombok.Builder;
import lombok.Data;
import org.springframework.beans.factory.parsing.Problem;
import org.springframework.util.ObjectUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;

@Data
@Builder
public class EventBodyResponse implements Serializable {

private static final long serialVersionUID = -1075199100920918308L;
/**
* This message should be set if something goes wrong. It should typically describe what went wrong,
* for example a stack trace or an error message.
*/
private String message;

/**
* This status code should be set to some code that can be used to trace the origin of the error
* in the back end system.
*/
private String statusCode;

/**
* Shows the status of the event that was processed by the adapter.
*/
private ResponseStatus responseStatus;

/**
* Shows the problems the system has found when processing this event's request.
*/
private List<Problem> problems;

public static EventBodyResponse ofResponseEvent(ResponseFintEvent responseEvent) {
return EventBodyResponse.builder()
.message(getMessage(responseEvent))
.statusCode(getStatusCode(responseEvent))
.responseStatus(ResponseStatus.byResponseEvent(responseEvent))
.problems(new ArrayList<>())
.build();
}

private static String getStatusCode(ResponseFintEvent responseEvent) {
if (responseEvent.isFailed()) {
return "ERROR";
} else if (responseEvent.isRejected()) {
return "REJECTED";
} else if (responseEvent.isConflicted()) {
return "CONFLICT";
}

return "";
}

private static String getMessage(ResponseFintEvent responseEvent) {
Function<String, String> setMessage = (message) -> ObjectUtils.isEmpty(message) ? message : "";

if (responseEvent.isFailed()) {
return setMessage.apply(responseEvent.getErrorMessage());
} else if (responseEvent.isRejected()) {
return setMessage.apply(responseEvent.getRejectReason());
} else if (responseEvent.isConflicted()) {
return setMessage.apply(responseEvent.getConflictReason());
}

return "";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package no.fintlabs.adapter.models.event;

import lombok.Data;
import lombok.RequiredArgsConstructor;

@Data
@RequiredArgsConstructor
public class EventIdentifikator {

private final String idField;
private final String idValue;

}
11 changes: 11 additions & 0 deletions src/main/java/no/fintlabs/adapter/models/event/FintEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package no.fintlabs.adapter.models.event;

import no.fintlabs.adapter.operation.OperationType;

public interface FintEvent {

public String getCorrId();
public String getOrgId();
public OperationType getOperationType();

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package no.fintlabs.adapter.models;
package no.fintlabs.adapter.models.event;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import no.fintlabs.adapter.operation.OperationType;

/**
* Represents a request to the adapter
Expand All @@ -16,7 +17,7 @@ public class RequestFintEvent implements FintEvent {
/**
* GUID for correlation ID. The same ID should follow the request both upstream and downstream.
*/
String corrId;
private String corrId;

/**
* OrgId for the current customer.
Expand All @@ -39,7 +40,7 @@ public class RequestFintEvent implements FintEvent {
private String resourceName;

/**
* The type of operation to be performed (CREATE, UPDATE)
* The type of operation to be performed (CREATE, UPDATE, VALIDATE)
*/
private OperationType operationType;

Expand All @@ -57,4 +58,5 @@ public class RequestFintEvent implements FintEvent {
* The object to which the event applies
*/
private String value;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package no.fintlabs.adapter.models.event;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
public class ResourceEvictionPayload {
private final String domain;
private final String pkg;
private final String resource;
private final String org;
private final Long unixTimestamp;

@JsonCreator
public ResourceEvictionPayload(
@JsonProperty("domain") String domain,
@JsonProperty("pkg") String pkg,
@JsonProperty("resource") String resource,
@JsonProperty("org") String org,
@JsonProperty("unixTimestamp") Long unixTimestamp
) {
this.domain = domain;
this.pkg = pkg;
this.resource = resource;
this.org = org;
this.unixTimestamp = unixTimestamp;
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package no.fintlabs.adapter.models;
package no.fintlabs.adapter.models.event;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import no.fintlabs.adapter.models.AdapterContract;
import no.fintlabs.adapter.models.sync.SyncPageEntry;
import no.fintlabs.adapter.operation.OperationType;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ResponseFintEvent<T> implements FintEvent {
public class ResponseFintEvent implements FintEvent {
/**
* GUID for correlation ID. The same ID should follow the request both upstream and downstream.
*/
Expand All @@ -33,10 +36,10 @@ public class ResponseFintEvent<T> implements FintEvent {
/**
* The SyncPageEntry of the object that the event produced. The object should be a FINT resource.
*/
private SyncPageEntry<T> value;
private SyncPageEntry value;

/**
* The type of operation to be performed (CREATE, UPDATE)
* The type of operation to be performed (CREATE, UPDATE, VALIDATE)
*/
private OperationType operationType;

Expand All @@ -59,4 +62,15 @@ public class ResponseFintEvent<T> implements FintEvent {
* A message that explains the reason for the rejection of the event.
*/
private String rejectReason;

/**
* Indicates whether the event had a conflict.
*/
private boolean conflicted;

/**
* A message that explains the reason for the conflict of the event.
*/
private String conflictReason;

}
44 changes: 44 additions & 0 deletions src/main/java/no/fintlabs/adapter/models/event/ResponseStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package no.fintlabs.adapter.models.event;

/**
* The response status indicates the result of the event from the adapter.
* The statuses can be:
* <ul>
* <li>{@link #ACCEPTED}</li>
* <li>{@link #REJECTED}</li>
* <li>{@link #ERROR}</li>
* <li>{@link #CONFLICT}</li>
* </ul>
*/
public enum ResponseStatus {

/**
* The event request was accepted. For example the update of the resource was successful.
*/
ACCEPTED,
/**
* The event request was rejected. For example that the adapter does not allow the update of a resource.
*/
REJECTED,
/**
* An error happened during processing of the event, for example that the db that the adapter connects to is down.
*/
ERROR,
/**
* The requested action results in a conflict, for example that an event tries to update a value that another event has already updated.
*/
CONFLICT;

public static ResponseStatus byResponseEvent(ResponseFintEvent responseEvent) {
if (responseEvent.isFailed()) {
return ResponseStatus.ERROR;
} else if (responseEvent.isRejected()) {
return ResponseStatus.REJECTED;
} else if (responseEvent.isConflicted()) {
return ResponseStatus.CONFLICT;
}

return ResponseStatus.ACCEPTED;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package no.fintlabs.adapter.models.sync;

import java.util.List;

public class DeleteSyncPage extends SyncPage {
public DeleteSyncPage() {
super(SyncType.DELETE);
}
}
Loading
Loading