forked from teamdigitale/dati-semantic-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fcc1e82
commit 3e758d3
Showing
25 changed files
with
375 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/it/gov/innovazione/ndc/config/HarvestExecutionContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package it.gov.innovazione.ndc.config; | ||
|
||
import it.gov.innovazione.ndc.model.harvester.Repository; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.With; | ||
|
||
@With | ||
@Data | ||
@Builder | ||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class HarvestExecutionContext { | ||
private final Repository repository; | ||
private final String revision; | ||
private final String correlationId; | ||
private final String runId; | ||
private final String currentUserId; | ||
private final String rootPath; | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/it/gov/innovazione/ndc/config/HarvestExecutionContextUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package it.gov.innovazione.ndc.config; | ||
|
||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor(access = lombok.AccessLevel.PRIVATE) | ||
public class HarvestExecutionContextUtils { | ||
|
||
private static final ThreadLocal<HarvestExecutionContext> CONTEXT_HOLDER = new ThreadLocal<>(); | ||
|
||
public static HarvestExecutionContext getContext() { | ||
return CONTEXT_HOLDER.get(); | ||
} | ||
|
||
public static void setContext(HarvestExecutionContext context) { | ||
CONTEXT_HOLDER.set(context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/java/it/gov/innovazione/ndc/eventhandler/event/HarvestedFileTooBigEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package it.gov.innovazione.ndc.eventhandler.event; | ||
|
||
import it.gov.innovazione.ndc.model.harvester.Repository; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Builder | ||
@Data | ||
public class HarvestedFileTooBigEvent { | ||
private final String runId; | ||
private final Repository repository; | ||
private final String revision; | ||
private final ViolatingSemanticAsset violatingSemanticAsset; | ||
private final String relativePathInRepo; | ||
|
||
@Data | ||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE) | ||
public static class ViolatingSemanticAsset { | ||
private final String pathInRepo; | ||
private final List<FileDetail> fileDetails; | ||
|
||
public static ViolatingSemanticAsset fromPath( | ||
String pathInRepo, | ||
List<File> files, | ||
long maxFileSizeBytes) { | ||
return new ViolatingSemanticAsset( | ||
pathInRepo, | ||
files.stream() | ||
.map(file -> new FileDetail( | ||
file.getPath(), | ||
file.length(), | ||
file.length() > maxFileSizeBytes)) | ||
.collect(Collectors.toList())); | ||
} | ||
|
||
} | ||
|
||
|
||
@Data | ||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE) | ||
public static class FileDetail { | ||
private final String path; | ||
private final long size; | ||
private final boolean violatesMaxSize; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
src/main/java/it/gov/innovazione/ndc/harvester/SemanticAssetHarvester.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
package it.gov.innovazione.ndc.harvester; | ||
|
||
import it.gov.innovazione.ndc.model.harvester.Repository; | ||
|
||
import java.nio.file.Path; | ||
|
||
public interface SemanticAssetHarvester { | ||
SemanticAssetType getType(); | ||
|
||
void cleanUpBeforeHarvesting(String repoUrl); | ||
|
||
void harvest(String repoUrl, Path rootPath); | ||
void harvest(Repository repository, Path rootPath); | ||
} |
65 changes: 61 additions & 4 deletions
65
src/main/java/it/gov/innovazione/ndc/harvester/harvesters/BaseSemanticAssetHarvester.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.