22
33import io .smallrye .mutiny .Uni ;
44import jakarta .enterprise .context .ApplicationScoped ;
5- import org .apache .logging .log4j .LogManager ;
6- import org .apache .logging .log4j .Logger ;
75import org .eclipse .microprofile .config .inject .ConfigProperty ;
86import org .lfenergy .compas .scl .data .dto .LocationMetaData ;
97import org .lfenergy .compas .scl .data .dto .ResourceMetaData ;
@@ -38,8 +36,8 @@ public Uni<LocationMetaData> createLocation(ILocationMetaItem location) {
3836 }
3937
4038 @ Override
41- public Uni <ResourceMetaData > archiveData (String locationName , String filename , UUID resourceId , File body , IAbstractArchivedResourceMetaItem archivedResource ) {
42- String absolutePath = generateSclDataLocation (resourceId , archivedResource , locationName ) + File .separator + "referenced_resources" ;
39+ public Uni <ResourceMetaData > archiveData (String locationKey , String filename , UUID resourceId , File body , IAbstractArchivedResourceMetaItem archivedResource ) {
40+ String absolutePath = generateSclDataLocation (resourceId , archivedResource , locationKey ) + File .separator + "referenced_resources" ;
4341 File locationDir = new File (absolutePath );
4442 locationDir .mkdirs ();
4543 File f = new File (absolutePath + File .separator + filename );
@@ -54,12 +52,12 @@ public Uni<ResourceMetaData> archiveData(String locationName, String filename, U
5452 return Uni .createFrom ().failure (new RuntimeException (e ));
5553 }
5654 List <ResourceTag > archivedResourceTag = archivedResource .getFields ().stream ().map (field -> new ResourceTag (field .getKey (), field .getValue ())).toList ();
57- return Uni .createFrom ().item (new ResourceMetaData (TypeEnum .RESOURCE , resourceId , locationName , archivedResourceTag ));
55+ return Uni .createFrom ().item (new ResourceMetaData (TypeEnum .RESOURCE , resourceId , locationKey , archivedResourceTag ));
5856 }
5957
6058 @ Override
61- public Uni <ResourceMetaData > archiveSclData (UUID resourceId , IAbstractArchivedResourceMetaItem archivedResource , String locationName , String data ) {
62- String absolutePath = generateSclDataLocation (resourceId , archivedResource , locationName );
59+ public Uni <ResourceMetaData > archiveSclData (UUID resourceId , IAbstractArchivedResourceMetaItem archivedResource , String locationKey , String data ) {
60+ String absolutePath = generateSclDataLocation (resourceId , archivedResource , locationKey );
6361 File locationDir = new File (absolutePath );
6462 locationDir .mkdirs ();
6563 File f = new File (locationDir + File .separator + archivedResource .getName () + "." + archivedResource .getType ().toLowerCase ());
@@ -69,10 +67,10 @@ public Uni<ResourceMetaData> archiveSclData(UUID resourceId, IAbstractArchivedRe
6967 throw new RuntimeException (e );
7068 }
7169 List <ResourceTag > archivedResourceTag = archivedResource .getFields ().stream ().map (field -> new ResourceTag (field .getKey (), field .getValue ())).toList ();
72- return Uni .createFrom ().item (new ResourceMetaData (TypeEnum .RESOURCE , resourceId , locationName , archivedResourceTag ));
70+ return Uni .createFrom ().item (new ResourceMetaData (TypeEnum .RESOURCE , resourceId , locationKey , archivedResourceTag ));
7371 }
7472
75- private String generateSclDataLocation (UUID resourceId , IAbstractArchivedResourceMetaItem archivedResource , String locationName ) {
76- return locationPath + File .separator + locationName + File .separator + resourceId + File .separator + archivedResource .getVersion ();
73+ private String generateSclDataLocation (UUID resourceId , IAbstractArchivedResourceMetaItem archivedResource , String locationKey ) {
74+ return locationPath + File .separator + locationKey + File .separator + resourceId + File .separator + archivedResource .getVersion ();
7775 }
7876}
0 commit comments