Skip to content

Commit e6d35be

Browse files
committed
Refactor workspace migration to accept storage path
Updated ModelService and related calls to require an explicit metaModelStoragePath parameter for workspace migration, removing reliance on ApplicationSettings within the service. Adjusted tests, controller, and properties to support this change and improved configuration clarity.
1 parent 2b1b144 commit e6d35be

File tree

7 files changed

+13
-17
lines changed

7 files changed

+13
-17
lines changed

aspect-model-editor-runtime/src/main/resources/application-dev.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ micronaut.server.host=127.0.0.1
1717
micronaut.security.enabled=false
1818
# Logging Configuration
1919
logger.levels.root=INFO
20-
logger.levels.io.micronaut=INFO
21-
logger.levels.io.micronaut.security=INFO
2220
# Multipart Configuration
2321
micronaut.server.multipart.enabled=true
2422
micronaut.server.multipart.file-size-threshold=100MB

aspect-model-editor-runtime/src/main/resources/application-mac.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ micronaut.server.host=127.0.0.1
1717
micronaut.security.enabled=false
1818
# Logging Configuration
1919
logger.levels.root=INFO
20-
logger.levels.io.micronaut=INFO
21-
logger.levels.io.micronaut.security=INFO
2220
# Multipart Configuration
2321
micronaut.server.multipart.enabled=true
2422
micronaut.server.multipart.file-size-threshold=100MB

aspect-model-editor-runtime/src/main/resources/application.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ micronaut.server.configurations.all.allowed-methods=["*"]
2121
micronaut.server.configurations.all.allowed-headers=["*"]
2222
# Logging Configuration
2323
logger.levels.root=INFO
24-
logger.levels.io.micronaut=INFO
25-
logger.levels.io.micronaut.security=INFO
2624
# Multipart Configuration
2725
micronaut.server.multipart.enabled=true
2826
micronaut.server.multipart.file-size-threshold=100MB

aspect-model-editor-service/src/main/java/org/eclipse/esmf/ame/services/ModelService.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.util.Map;
2323
import java.util.function.Supplier;
2424

25-
import org.eclipse.esmf.ame.config.ApplicationSettings;
2625
import org.eclipse.esmf.ame.exceptions.CreateFileException;
2726
import org.eclipse.esmf.ame.exceptions.FileHandlingException;
2827
import org.eclipse.esmf.ame.exceptions.FileNotFoundException;
@@ -168,20 +167,22 @@ public Map<String, List<Version>> getAllNamespaces( final boolean onlyAspectMode
168167
}
169168
}
170169

171-
public MigrationResult migrateWorkspace( final boolean setNewVersion ) {
170+
public MigrationResult migrateWorkspace( final boolean setNewVersion, final Path metaModelStoragePath ) {
172171
final List<String> errors = new ArrayList<>();
173172

174173
try {
175174
getAllNamespaces( false ).forEach(
176-
( namespace, versions ) -> versions.forEach( version -> processVersion( namespace, version, setNewVersion, errors ) ) );
175+
( namespace, versions ) -> versions.forEach(
176+
version -> processVersion( namespace, version, setNewVersion, errors, metaModelStoragePath ) ) );
177177
return new MigrationResult( true, errors );
178178
} catch ( final Exception e ) {
179179
errors.add( e.getMessage() );
180180
return new MigrationResult( false, errors );
181181
}
182182
}
183183

184-
private void processVersion( final String namespace, final Version version, final boolean setNewVersion, final List<String> errors ) {
184+
private void processVersion( final String namespace, final Version version, final boolean setNewVersion, final List<String> errors,
185+
final Path metaModelStoragePath ) {
185186
version.getModels().forEach( model -> {
186187
try {
187188
final boolean isNotLatestKnownVersion = KnownVersion.fromVersionString( model.getVersion() )
@@ -195,7 +196,7 @@ private void processVersion( final String namespace, final Version version, fina
195196
final AspectModel aspectModel = aspectModelLoader.load( aspectModelPath.toFile() );
196197

197198
if ( setNewVersion ) {
198-
applyNamespaceVersionChange( aspectModel, errors );
199+
applyNamespaceVersionChange( aspectModel, errors, metaModelStoragePath );
199200
return;
200201
}
201202

@@ -206,7 +207,7 @@ private void processVersion( final String namespace, final Version version, fina
206207
} );
207208
}
208209

209-
private void applyNamespaceVersionChange( final AspectModel aspectModel, final List<String> errors ) {
210+
private void applyNamespaceVersionChange( final AspectModel aspectModel, final List<String> errors, final Path metaModelStoragePath ) {
210211
try {
211212
final AspectModelFile originalFile = aspectModel.files().getFirst();
212213
final AspectChangeManager changeManager = new AspectChangeManager( aspectModel );
@@ -231,7 +232,7 @@ private void applyNamespaceVersionChange( final AspectModel aspectModel, final L
231232

232233
ModelUtils.createFile( updatedFile.namespaceUrn(),
233234
updatedFile.filename().orElseThrow( () -> new FileHandlingException( "Filename missing" ) ),
234-
ApplicationSettings.getMetaModelStoragePath() );
235+
metaModelStoragePath );
235236

236237
AspectSerializer.INSTANCE.write( updatedFile );
237238
} catch ( final IOException e ) {

aspect-model-editor-service/src/test/java/org/eclipse/esmf/ame/services/ModelServiceTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public Path modelPath() {
179179

180180
@Test
181181
void testMigrateWorkspaceWithoutVersionUpgrade() throws IOException {
182-
final MigrationResult migrationResult = modelService.migrateWorkspace( false );
182+
final MigrationResult migrationResult = modelService.migrateWorkspace( false, MIGRATION_WORKSPACE_PATH );
183183

184184
assertTrue( migrationResult.isSuccess() );
185185

@@ -201,7 +201,7 @@ void testMigrateWorkspaceWithoutVersionUpgrade() throws IOException {
201201

202202
@Test
203203
void testMigrateWorkspaceWithVersionUpgrade() throws IOException {
204-
final MigrationResult migrationResult = modelService.migrateWorkspace( true );
204+
final MigrationResult migrationResult = modelService.migrateWorkspace( true, MIGRATION_WORKSPACE_PATH );
205205

206206
assertTrue( migrationResult.isSuccess() );
207207

aspect-model-editor-service/src/test/resources/application-test.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
# SPDX-License-Identifier: MPL-2.0
1212
#
1313
# Logging Configuration
14-
logger.levels.root=ERROR
14+
setting.meta-model-path=/tmp/test-meta-model-path
15+
logger.levels.root=info

aspect-model-editor-web/src/main/java/org/eclipse/esmf/ame/api/ModelController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,6 @@ public HttpResponse<Map<String, List<Version>>> getAllNamespaces(
166166
*/
167167
@Get( uri = "migrate-workspace" )
168168
public HttpResponse<MigrationResult> migrateWorkspace( @QueryValue( defaultValue = "false" ) final boolean setNewVersion ) {
169-
return HttpResponse.ok( modelService.migrateWorkspace( setNewVersion ) );
169+
return HttpResponse.ok( modelService.migrateWorkspace( setNewVersion, ApplicationSettings.getMetaModelStoragePath() ) );
170170
}
171171
}

0 commit comments

Comments
 (0)