This is an automated email from the ASF dual-hosted git repository.
riemer pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to refs/heads/dev by this push:
new 2f87e2cccb chore: Remove migrations from v097 downwards (#4232)
2f87e2cccb is described below
commit 2f87e2cccbb6aa2ff8d2b9f22429b1b16bbdbd69
Author: Dominik Riemer <[email protected]>
AuthorDate: Fri Mar 6 09:40:14 2026 +0100
chore: Remove migrations from v097 downwards (#4232)
---
.../core/migrations/AvailableMigrations.java | 22 --
.../v070/CreateAssetLinkTypeMigration.java | 50 -----
.../v070/CreateFileAssetTypeMigration.java | 59 ------
.../v090/UpdateUsernameViewMigration.java | 62 ------
.../v093/StoreEmailTemplatesMigration.java | 58 ------
...MergeFilenamesAndRenameDuplicatesMigration.java | 232 ---------------------
.../v970/AddDataLakePipelineTemplateMigration.java | 50 -----
.../migrations/v970/AddLinkSettingsMigration.java | 52 -----
.../migrations/v970/AddRolesToUserDbMigration.java | 64 ------
.../v970/DataExplorerDataViewMigration.java | 125 -----------
.../v970/ModifyAssetLinkTypeMigration.java | 101 ---------
.../RemoveNodesFromOpcUaAdaptersMigration.java | 98 ---------
...eFilenamesAndRenameDuplicatesMigrationTest.java | 112 ----------
.../RemoveNodesFromOpcUaAdaptersMigrationTest.java | 85 --------
.../svcdiscovery/SpServiceDiscoveryCore.java | 1 -
15 files changed, 1171 deletions(-)
diff --git
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/AvailableMigrations.java
b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/AvailableMigrations.java
index b981830201..ecdbc1f292 100644
---
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/AvailableMigrations.java
+++
b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/AvailableMigrations.java
@@ -19,11 +19,6 @@
package org.apache.streampipes.service.core.migrations;
-import
org.apache.streampipes.service.core.migrations.v070.CreateAssetLinkTypeMigration;
-import
org.apache.streampipes.service.core.migrations.v070.CreateFileAssetTypeMigration;
-import
org.apache.streampipes.service.core.migrations.v090.UpdateUsernameViewMigration;
-import
org.apache.streampipes.service.core.migrations.v093.StoreEmailTemplatesMigration;
-import
org.apache.streampipes.service.core.migrations.v095.MergeFilenamesAndRenameDuplicatesMigration;
import
org.apache.streampipes.service.core.migrations.v0980.AddDataLakeMeasureViewMigration;
import
org.apache.streampipes.service.core.migrations.v0980.AddDefaultExportProviderMigration;
import
org.apache.streampipes.service.core.migrations.v0980.FixImportedPermissionsMigration;
@@ -42,12 +37,6 @@ import
org.apache.streampipes.service.core.migrations.v099.RemoveDuplicatedAsset
import
org.apache.streampipes.service.core.migrations.v099.RemoveObsoletePrivilegesMigration;
import
org.apache.streampipes.service.core.migrations.v099.UniqueDashboardIdMigration;
import
org.apache.streampipes.service.core.migrations.v099.connect.MigrateAdaptersToUseScript;
-import
org.apache.streampipes.service.core.migrations.v970.AddDataLakePipelineTemplateMigration;
-import
org.apache.streampipes.service.core.migrations.v970.AddLinkSettingsMigration;
-import
org.apache.streampipes.service.core.migrations.v970.AddRolesToUserDbMigration;
-import
org.apache.streampipes.service.core.migrations.v970.DataExplorerDataViewMigration;
-import
org.apache.streampipes.service.core.migrations.v970.ModifyAssetLinkTypeMigration;
-import
org.apache.streampipes.service.core.migrations.v970.RemoveNodesFromOpcUaAdaptersMigration;
import java.util.Arrays;
import java.util.List;
@@ -56,17 +45,6 @@ public class AvailableMigrations {
public List<Migration> getAvailableMigrations() {
return Arrays.asList(
- new CreateAssetLinkTypeMigration(),
- new CreateFileAssetTypeMigration(),
- new UpdateUsernameViewMigration(),
- new StoreEmailTemplatesMigration(),
- new MergeFilenamesAndRenameDuplicatesMigration(),
- new AddLinkSettingsMigration(),
- new DataExplorerDataViewMigration(),
- new ModifyAssetLinkTypeMigration(),
- new RemoveNodesFromOpcUaAdaptersMigration(),
- new AddRolesToUserDbMigration(),
- new AddDataLakePipelineTemplateMigration(),
new ModifyAssetLinksMigration(),
new ModifyAssetLinkTypesMigration(),
new AddDataLakeMeasureViewMigration(),
diff --git
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v070/CreateAssetLinkTypeMigration.java
b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v070/CreateAssetLinkTypeMigration.java
deleted file mode 100644
index 42db290315..0000000000
---
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v070/CreateAssetLinkTypeMigration.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-package org.apache.streampipes.service.core.migrations.v070;
-
-import org.apache.streampipes.commons.constants.GenericDocTypes;
-import org.apache.streampipes.manager.setup.tasks.CreateAssetLinkTypeTask;
-import org.apache.streampipes.service.core.migrations.Migration;
-import org.apache.streampipes.storage.management.StorageDispatcher;
-
-import java.io.IOException;
-
-public class CreateAssetLinkTypeMigration implements Migration {
-
- @Override
- public boolean shouldExecute() {
- try {
- return
StorageDispatcher.INSTANCE.getNoSqlStore().getGenericStorage().findAll(GenericDocTypes.DOC_ASSET_LINK_TYPE)
- .size() == 0;
- } catch (IOException e) {
- return true;
- }
- }
-
- @Override
- public void executeMigration() {
- new CreateAssetLinkTypeTask().execute();
- }
-
- @Override
- public String getDescription() {
- return "Populating database with default asset links";
- }
-}
diff --git
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v070/CreateFileAssetTypeMigration.java
b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v070/CreateFileAssetTypeMigration.java
deleted file mode 100644
index 7cef8f0960..0000000000
---
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v070/CreateFileAssetTypeMigration.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.service.core.migrations.v070;
-
-import org.apache.streampipes.commons.constants.GenericDocTypes;
-import org.apache.streampipes.commons.random.UUIDGenerator;
-import org.apache.streampipes.model.assets.AssetLinkType;
-import org.apache.streampipes.service.core.migrations.Migration;
-import org.apache.streampipes.storage.management.StorageDispatcher;
-
-import java.io.IOException;
-import java.util.List;
-
-public class CreateFileAssetTypeMigration implements Migration {
-
- @Override
- public boolean shouldExecute() {
- try {
- return StorageDispatcher
- .INSTANCE
- .getNoSqlStore()
- .getGenericStorage()
- .findAll(GenericDocTypes.DOC_ASSET_LINK_TYPE)
- .stream()
- .noneMatch(al -> al.get("linkType").equals("file"));
- } catch (IOException e) {
- return true;
- }
- }
-
- @Override
- public void executeMigration() throws IOException {
- var fileAsset = new AssetLinkType("file", "File", "var(--color-file)",
"draft", "file", List.of(), false);
- fileAsset.setId(UUIDGenerator.generateUuid());
-
StorageDispatcher.INSTANCE.getNoSqlStore().getGenericStorage().create(fileAsset,
AssetLinkType.class);
-
- }
-
- @Override
- public String getDescription() {
- return "Create asset type 'File'";
- }
-}
diff --git
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v090/UpdateUsernameViewMigration.java
b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v090/UpdateUsernameViewMigration.java
deleted file mode 100644
index cb2368c1ec..0000000000
---
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v090/UpdateUsernameViewMigration.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.service.core.migrations.v090;
-
-import org.apache.streampipes.manager.setup.design.UserDesignDocument;
-import org.apache.streampipes.service.core.migrations.Migration;
-import org.apache.streampipes.storage.couchdb.utils.Utils;
-
-import org.lightcouch.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class UpdateUsernameViewMigration implements Migration {
-
- private static final Logger LOG =
LoggerFactory.getLogger(UpdateUsernameViewMigration.class);
- private static final String DOC_NAME = "_design/users";
-
- @Override
- public boolean shouldExecute() {
- var designDoc = Utils.getCouchDbUserClient().design().getFromDb(DOC_NAME);
- var viewKey = UserDesignDocument.USERNAME_KEY;
- var viewMapFunction = UserDesignDocument.USERNAME_MAP_FUNCTION;
- var views = designDoc.getViews();
-
- if (views.containsKey(viewKey)) {
- return !(views.get(viewKey).getMap().equals(viewMapFunction));
- } else {
- return true;
- }
- }
-
- @Override
- public void executeMigration() {
- var userDocument = new UserDesignDocument().make();
- Response resp =
Utils.getCouchDbUserClient().design().synchronizeWithDb(userDocument);
-
- if (resp.getError() != null) {
- LOG.warn("Could not update user design document with reason {}",
resp.getReason());
- }
- }
-
- @Override
- public String getDescription() {
- return "Lowercase all keys in user database design document";
- }
-}
diff --git
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v093/StoreEmailTemplatesMigration.java
b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v093/StoreEmailTemplatesMigration.java
deleted file mode 100644
index dfeca224ba..0000000000
---
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v093/StoreEmailTemplatesMigration.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.service.core.migrations.v093;
-
-import
org.apache.streampipes.model.configuration.DefaultEmailTemplateConfiguration;
-import org.apache.streampipes.service.core.migrations.Migration;
-import org.apache.streampipes.storage.api.system.ISpCoreConfigurationStorage;
-import org.apache.streampipes.storage.management.StorageDispatcher;
-
-import java.io.IOException;
-
-public class StoreEmailTemplatesMigration implements Migration {
-
- private final ISpCoreConfigurationStorage storage;
-
- public StoreEmailTemplatesMigration() {
- this.storage =
StorageDispatcher.INSTANCE.getNoSqlStore().getSpCoreConfigurationStorage();
- }
-
- @Override
- public boolean shouldExecute() {
- var config = storage.get();
- if (config == null) {
- return false;
- } else {
- return config.getEmailTemplateConfig() == null;
- }
- }
-
- @Override
- public void executeMigration() throws IOException {
- var config = storage.get();
- config.setEmailTemplateConfig(new
DefaultEmailTemplateConfiguration().getDefaultTemplates());
-
- storage.updateElement(config);
- }
-
- @Override
- public String getDescription() {
- return "Moving email templates to configuration storage";
- }
-}
diff --git
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v095/MergeFilenamesAndRenameDuplicatesMigration.java
b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v095/MergeFilenamesAndRenameDuplicatesMigration.java
deleted file mode 100644
index 3fefb94b27..0000000000
---
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v095/MergeFilenamesAndRenameDuplicatesMigration.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.service.core.migrations.v095;
-
-import org.apache.streampipes.manager.file.FileHandler;
-import org.apache.streampipes.model.file.FileMetadata;
-import org.apache.streampipes.serializers.json.JacksonSerializer;
-import org.apache.streampipes.service.core.migrations.Migration;
-import org.apache.streampipes.storage.api.system.IFileMetadataStorage;
-import org.apache.streampipes.storage.couchdb.utils.Utils;
-import org.apache.streampipes.storage.management.StorageDispatcher;
-
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.lightcouch.CouchDbClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Scanner;
-
-public class MergeFilenamesAndRenameDuplicatesMigration implements Migration {
-
- protected static final String ORIGINAL_FILENAME = "originalFilename";
- protected static final String INTERNAL_FILENAME = "internalFilename";
- protected static final String ID = "_id";
- protected static final String FILETYPE = "filetype";
-
- private CouchDbClient couchDbClient;
-
- private final ObjectMapper mapper = JacksonSerializer.getObjectMapper(Map.of(
- DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true
- ));
-
- private final IFileMetadataStorage fileMetadataStorage =
- StorageDispatcher.INSTANCE.getNoSqlStore().getFileMetadataStorage();
-
- private final FileHandler fileHandler = new FileHandler();
-
- Logger logger =
LoggerFactory.getLogger(MergeFilenamesAndRenameDuplicatesMigration.class);
-
- protected Map<String, List<FileMetadata>> fileMetadataGroupedByOriginalName
= new HashMap<>();
-
- private boolean isTesting = false;
-
- public MergeFilenamesAndRenameDuplicatesMigration(boolean testing) {
- isTesting = testing;
- }
-
- public MergeFilenamesAndRenameDuplicatesMigration() {
- couchDbClient = Utils.getCouchDbFileMetadataClient();
- }
-
- // Starting from v0.95, StreamPipes will use a single file name as the
unique identifier of files instead of an
- // internal filename and an original filename. This migration merges them
and renames all the files that have
- // duplicate names to ensure uniqueness
- @Override
- public boolean shouldExecute() {
- return true;
- }
-
- @Override
- public void executeMigration() {
- var couchDbRawFileMetadata =
getCouchDbRawFileMetadata(getAllFileIds(fileMetadataStorage));
- getFileMetadataToUpdate(couchDbRawFileMetadata);
- fileMetadataGroupedByOriginalName.forEach(
- (originalFilename, fileMetadataList) -> update(originalFilename,
fileMetadataList));
- }
-
- /**
- * Gets all fileMetadata that need to be updated grouped by originalFilename
- * key is (possibly) duplicated originalFilename and value is that file's
FileMetadata list (if duplicated)
- */
- protected void getFileMetadataToUpdate(List<Map<String, Object>>
couchDbRawFileMetadata) {
- couchDbRawFileMetadata.forEach(
- this::checkDuplicateOriginalFilename);
- }
-
- /**
- * Fetches all fileIds stored in CouchDB
- */
- private List<String> getAllFileIds(IFileMetadataStorage fileMetadataStorage)
{
- return fileMetadataStorage.findAll().stream().map(FileMetadata::getFileId)
- .toList();
- }
-
- /**
- * Takes the list of fileIds and searches for their raw metadata in CouchDB
and returns them
- */
- private List<Map<String, Object>> getCouchDbRawFileMetadata(List<String>
fileIds) {
- return fileIds.stream()
- .map(fileId -> convertInputStreamToMap(couchDbClient.find(fileId)))
- .toList();
- }
-
- /**
- * Converts InputStream (as stored in CouchDB) to Map, if there's an error,
constructs a new Map
- */
- private Map<String, Object> convertInputStreamToMap(InputStream inputStream)
{
- try {
- return mapper.readValue(inputStream, Map.class);
- } catch (Exception e) {
- Scanner scanner = new Scanner(inputStream).useDelimiter("\\A");
- String inputStreamString = scanner.hasNext() ? scanner.next() : "";
- logger.error(
- "Failed to construct a Map from InputStream stored in CouchDB, the
data for this file is likely corrupted, "
- + "skipping it for migration.\nThe original debug message is: "
+ e.getMessage()
- + "\nThe original InputStream is: " + inputStreamString);
- return new HashMap<>();
- }
- }
-
- /**
- * Takes raw data stored in CouchDB and constructs
fileMetadataGroupedByOriginalName,
- * key is (possibly) duplicated originalFilename and value is that file's
FileMetadata list (if duplicated)
- */
- private void checkDuplicateOriginalFilename(Map<String, Object>
rawFileMetadata) {
- // If this file was already migrated or there was an error when converting
InputStream to Map, skip it
- if (rawFileMetadata.containsKey(ORIGINAL_FILENAME)) {
- var originalFilename =
rawFileMetadata.get(ORIGINAL_FILENAME).toString().toLowerCase();
- if (!fileMetadataGroupedByOriginalName.containsKey(originalFilename)) {
- fileMetadataGroupedByOriginalName.put(originalFilename, new
ArrayList<>());
- }
- FileMetadata fileMetadata;
- if (isTesting) {
- fileMetadata = new FileMetadata();
- fileMetadata.setFileId(rawFileMetadata.get(ID).toString());
- fileMetadata.setFiletype(rawFileMetadata.get(FILETYPE).toString());
- } else {
- fileMetadata =
fileMetadataStorage.getElementById(rawFileMetadata.get(ID).toString());
- }
-
fileMetadataGroupedByOriginalName.get(originalFilename).add(fileMetadata);
- }
- }
-
- /**
- * For each of the file, calls updateFileMetadata() and updateLocalFile()
- */
- protected void update(String originalFilename, List<FileMetadata>
fileMetadataList) {
- var fileMetadata = fileMetadataList.get(0);
- // just name the 1st one to its originalFilename
- if (!isTesting) {
- var internalFilename = getInternalFilenameFromFileMetadata(fileMetadata);
- updateLocalFile(internalFilename, originalFilename);
- }
- updateFileMetadata(fileMetadata, originalFilename, isTesting);
- for (int i = 1; i < fileMetadataList.size(); ++i) {
- fileMetadata = fileMetadataList.get(i);
- var newFilename = createNewFileName(i, removeFileType(originalFilename),
fileMetadata.getFiletype());
- if (!isTesting) {
- var internalFilename =
getInternalFilenameFromFileMetadata(fileMetadata);
- updateLocalFile(internalFilename, newFilename);
- }
- updateFileMetadata(fileMetadata, newFilename, isTesting);
- }
- }
-
- /**
- * Updates FileMetadata: sets new merged filename to the given filename
- */
- private void updateFileMetadata(FileMetadata fileMetadata, String filename,
boolean isTesting) {
- fileMetadata.setFilename(filename);
- if (!isTesting) {
- fileMetadataStorage.updateElement(fileMetadata);
- }
- }
-
- /**
- * Updates the file stored locally: renames the file (i.e. before it's using
internalFilename, now copy the
- * InputStream stored and replace internalFilename with the given filename)
- */
- private void updateLocalFile(String internalFilename, String filename) {
- fileHandler.renameFile(internalFilename, filename);
- }
-
- /**
- * Gets the old internalFilename after merging
- */
- private String getInternalFilenameFromFileMetadata(FileMetadata
fileMetadata) {
- return
convertInputStreamToMap(couchDbClient.find(fileMetadata.getFileId())).get(INTERNAL_FILENAME).toString();
- }
-
- /**
- * Creates the new file name for a file with a duplicate name.
- */
- private String createNewFileName(
- int index,
- String fileName,
- String fileType
- ) {
- return String.format(
- "%s(%d).%s",
- fileName,
- index + 1,
- fileType
- );
- }
-
- /**
- * Returns file name without file type suffix.
- */
- private String removeFileType(String fileName) {
- var indexBeforeFileType = fileName.lastIndexOf('.');
- return fileName.substring(0, indexBeforeFileType);
- }
-
- @Override
- public String getDescription() {
- return "Merge internalFilename and originalFilename. Additionally, rename"
- + "duplicate files to ensure uniqueness.";
- }
-}
diff --git
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v970/AddDataLakePipelineTemplateMigration.java
b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v970/AddDataLakePipelineTemplateMigration.java
deleted file mode 100644
index 717d4c09c8..0000000000
---
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v970/AddDataLakePipelineTemplateMigration.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.service.core.migrations.v970;
-
-import
org.apache.streampipes.manager.template.instances.PersistDataLakePipelineTemplate;
-import org.apache.streampipes.service.core.migrations.Migration;
-import
org.apache.streampipes.storage.api.pipeline.ICompactPipelineTemplateStorage;
-import org.apache.streampipes.storage.management.StorageDispatcher;
-
-import java.io.IOException;
-
-public class AddDataLakePipelineTemplateMigration implements Migration {
-
- private final ICompactPipelineTemplateStorage storage;
-
- public AddDataLakePipelineTemplateMigration() {
- this.storage =
StorageDispatcher.INSTANCE.getNoSqlStore().getPipelineTemplateStorage();
- }
-
- @Override
- public boolean shouldExecute() {
- return
storage.getElementById(PersistDataLakePipelineTemplate.DATA_LAKE_TEMPLATE_ID)
== null;
- }
-
- @Override
- public void executeMigration() throws IOException {
- storage.persist(new PersistDataLakePipelineTemplate().getTemplate());
- }
-
- @Override
- public String getDescription() {
- return "Adding data lake pipeline template to template storage";
- }
-}
diff --git
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v970/AddLinkSettingsMigration.java
b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v970/AddLinkSettingsMigration.java
deleted file mode 100644
index a1a6c2d7eb..0000000000
---
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v970/AddLinkSettingsMigration.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.service.core.migrations.v970;
-
-import org.apache.streampipes.model.configuration.DefaultLinkSettings;
-import org.apache.streampipes.service.core.migrations.Migration;
-import org.apache.streampipes.storage.api.system.ISpCoreConfigurationStorage;
-import org.apache.streampipes.storage.management.StorageDispatcher;
-
-import java.io.IOException;
-
-public class AddLinkSettingsMigration implements Migration {
-
- private final ISpCoreConfigurationStorage coreConfigStore = StorageDispatcher
- .INSTANCE
- .getNoSqlStore()
- .getSpCoreConfigurationStorage();
-
- @Override
- public boolean shouldExecute() {
- return coreConfigStore.get().getGeneralConfig().getLinkSettings() == null;
- }
-
- @Override
- public void executeMigration() throws IOException {
- var linkSettings = new DefaultLinkSettings().make();
- var coreConfig = coreConfigStore.get();
- coreConfig.getGeneralConfig().setLinkSettings(linkSettings);
- coreConfigStore.updateElement(coreConfig);
- }
-
- @Override
- public String getDescription() {
- return "Adding link settings to general config";
- }
-}
diff --git
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v970/AddRolesToUserDbMigration.java
b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v970/AddRolesToUserDbMigration.java
deleted file mode 100644
index 1465779ef4..0000000000
---
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v970/AddRolesToUserDbMigration.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.service.core.migrations.v970;
-
-import org.apache.streampipes.manager.setup.design.UserDesignDocument;
-import org.apache.streampipes.service.core.migrations.Migration;
-import org.apache.streampipes.storage.couchdb.utils.Utils;
-
-import org.lightcouch.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-
-public class AddRolesToUserDbMigration implements Migration {
-
- private static final String DOC_NAME = "_design/users";
- private static final Logger LOG =
LoggerFactory.getLogger(AddRolesToUserDbMigration.class);
-
- @Override
- public boolean shouldExecute() {
- var designDoc = Utils.getCouchDbUserClient().design().getFromDb(DOC_NAME);
- var viewKey = UserDesignDocument.ROLE_KEY;
- var viewMapFunction = UserDesignDocument.ROLE_MAP_FUNCTION;
- var views = designDoc.getViews();
-
- if (views.containsKey(viewKey)) {
- return !(views.get(viewKey).getMap().equals(viewMapFunction));
- } else {
- return true;
- }
- }
-
- @Override
- public void executeMigration() throws IOException {
- var userDocument = new UserDesignDocument().make();
- Response resp =
Utils.getCouchDbUserClient().design().synchronizeWithDb(userDocument);
-
- if (resp.getError() != null) {
- LOG.warn("Could not update user design document with reason {}",
resp.getReason());
- }
- }
-
- @Override
- public String getDescription() {
- return "Add default roles and privileges";
- }
-}
diff --git
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v970/DataExplorerDataViewMigration.java
b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v970/DataExplorerDataViewMigration.java
deleted file mode 100644
index 1e107b9103..0000000000
---
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v970/DataExplorerDataViewMigration.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.service.core.migrations.v970;
-
-import org.apache.streampipes.model.client.user.PermissionBuilder;
-import org.apache.streampipes.model.dashboard.DashboardModel;
-import org.apache.streampipes.model.datalake.DataExplorerWidgetModel;
-import org.apache.streampipes.resource.management.PermissionResourceManager;
-import org.apache.streampipes.service.core.migrations.Migration;
-import
org.apache.streampipes.storage.api.explorer.IDataExplorerDashboardStorage;
-import org.apache.streampipes.storage.api.explorer.IDataExplorerWidgetStorage;
-import org.apache.streampipes.storage.management.StorageDispatcher;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Migrates data explorer dashboards and data views
- * Add permission object for each data view
- * Add time settings to data views
- * Add live settings to dashboards
- */
-public class DataExplorerDataViewMigration implements Migration {
-
- private static final Logger LOG =
LoggerFactory.getLogger(DataExplorerDataViewMigration.class);
-
- private final IDataExplorerWidgetStorage dataViewStorage;
- private final IDataExplorerDashboardStorage dataExplorerDashboardStorage;
- private final PermissionResourceManager permissionResourceManager;
-
- public DataExplorerDataViewMigration() {
- var storage = StorageDispatcher.INSTANCE.getNoSqlStore();
- this.dataViewStorage = storage.getDataExplorerWidgetStorage();
- this.dataExplorerDashboardStorage =
storage.getDataExplorerDashboardStorage();
- this.permissionResourceManager = new PermissionResourceManager();
- }
-
- @Override
- public boolean shouldExecute() {
- return !findDashboardsToMigrate().isEmpty();
- }
-
- @Override
- public void executeMigration() throws IOException {
- var allDashboards = findDashboardsToMigrate();
- var defaultLiveSettings = makeDefaultLiveSettings();
-
- LOG.info("Migrating {} data explorer dashboards", allDashboards.size());
-
- allDashboards
- .forEach(dashboard -> {
- var timeSettings = dashboard.getDashboardTimeSettings();
- dashboard.getDashboardGeneralSettings().put("globalTimeEnabled",
true);
- dashboard.setDashboardLiveSettings(defaultLiveSettings);
- dashboard.getWidgets().forEach(widget -> {
- var dataView = dataViewStorage.getElementById(widget.getId());
- if (dataView != null) {
- dataView.setTimeSettings(timeSettings);
- dataViewStorage.updateElement(dataView);
- addPermissionsObject(dashboard, dataView);
- }
- });
- dataExplorerDashboardStorage.updateElement(dashboard);
- });
- }
-
- @Override
- public String getDescription() {
- return "Migrating data explorer data views";
- }
-
- private List<DashboardModel> findDashboardsToMigrate() {
- return dataExplorerDashboardStorage
- .findAll()
- .stream()
- .filter(dashboard ->
!dashboard.getDashboardGeneralSettings().containsKey("globalTimeEnabled"))
- .toList();
- }
-
- private Map<String, Object> makeDefaultLiveSettings() {
- var map = new HashMap<String, Object>();
- map.put("refreshModeActive", false);
- map.put("refreshIntervalInSeconds", 10);
- map.put("label", "Off");
-
- return map;
- }
-
- private void addPermissionsObject(DashboardModel dashboard,
- DataExplorerWidgetModel dataView) {
- var dashboardPermissions =
permissionResourceManager.findForObjectId(dashboard.getElementId());
- if (!dashboardPermissions.isEmpty()) {
- var dashboardPermission = dashboardPermissions.get(0);
- if (permissionResourceManager.find(dataView.getElementId()) == null) {
- var dataViewPermission = PermissionBuilder
- .create(dataView.getElementId(), DataExplorerWidgetModel.class,
dashboardPermission.getOwnerSid())
- .publicElement(dashboardPermission.isPublicElement())
- .build();
-
dataViewPermission.setGrantedAuthorities(dashboardPermission.getGrantedAuthorities());
- permissionResourceManager.create(dataViewPermission);
- }
- }
- }
-}
diff --git
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v970/ModifyAssetLinkTypeMigration.java
b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v970/ModifyAssetLinkTypeMigration.java
deleted file mode 100644
index 3f7f9e6d14..0000000000
---
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v970/ModifyAssetLinkTypeMigration.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.service.core.migrations.v970;
-
-import org.apache.streampipes.commons.constants.GenericDocTypes;
-import org.apache.streampipes.model.assets.AssetLinkType;
-import org.apache.streampipes.serializers.json.JacksonSerializer;
-import org.apache.streampipes.service.core.migrations.Migration;
-import org.apache.streampipes.storage.api.system.IGenericStorage;
-import org.apache.streampipes.storage.management.StorageDispatcher;
-
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.type.CollectionType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-public class ModifyAssetLinkTypeMigration implements Migration {
-
- private static final Logger LOG =
LoggerFactory.getLogger(ModifyAssetLinkTypeMigration.class);
-
- private final IGenericStorage genericStorage =
StorageDispatcher.INSTANCE.getNoSqlStore().getGenericStorage();
- private final ObjectMapper objectMapper =
JacksonSerializer.getObjectMapper(Map.of(
- DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true
- ));
-
- public ModifyAssetLinkTypeMigration() {
-
- }
-
- @Override
- public boolean shouldExecute() {
- return true;
- }
-
- @Override
- public void executeMigration() throws IOException {
- getAssetLinkTypes().stream()
- .filter(assetLinkType -> switch (assetLinkType.getLinkType()) {
- case "data-view", "adapter", "pipeline" -> true;
- default -> false;
- })
- .forEach(assetLinkType -> {
- assetLinkType.setNavPaths(switch (assetLinkType.getLinkType()) {
- case "data-view" -> List.of("dataexplorer", "dashboard");
- case "adapter" -> List.of("connect", "details");
- case "pipeline" -> List.of("pipelines", "details");
- default -> throw new IllegalStateException("Unexpected value: " +
assetLinkType.getLinkType());
- });
- updateLinkType(assetLinkType);
- });
- }
-
- @Override
- public String getDescription() {
- return "Modifying navigation targets of asset link types";
- }
-
- private void updateLinkType(AssetLinkType assetLinkType) {
- try {
- this.genericStorage.update(assetLinkType.getId(),
objectMapper.writeValueAsString(assetLinkType));
- } catch (IOException e) {
- LOG.warn("Could not update asset link type {}", assetLinkType, e);
- }
- }
-
- private List<AssetLinkType> getAssetLinkTypes() {
- try {
- return
deserialize(genericStorage.findAll(GenericDocTypes.DOC_ASSET_LINK_TYPE));
- } catch (IOException e) {
- return List.of();
- }
- }
-
- private List<AssetLinkType> deserialize(List<Map<String, Object>> list) {
- CollectionType listType = objectMapper.getTypeFactory()
- .constructCollectionType(List.class, AssetLinkType.class);
-
- return objectMapper.convertValue(list, listType);
- }
-}
diff --git
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v970/RemoveNodesFromOpcUaAdaptersMigration.java
b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v970/RemoveNodesFromOpcUaAdaptersMigration.java
deleted file mode 100644
index 820cf46203..0000000000
---
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v970/RemoveNodesFromOpcUaAdaptersMigration.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.service.core.migrations.v970;
-
-import org.apache.streampipes.model.connect.adapter.AdapterDescription;
-import
org.apache.streampipes.model.staticproperty.RuntimeResolvableTreeInputStaticProperty;
-import org.apache.streampipes.service.core.migrations.Migration;
-import org.apache.streampipes.storage.api.connect.IAdapterStorage;
-import org.apache.streampipes.storage.management.StorageDispatcher;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-
-public class RemoveNodesFromOpcUaAdaptersMigration implements Migration {
-
- private static final Logger LOG =
LoggerFactory.getLogger(RemoveNodesFromOpcUaAdaptersMigration.class);
-
- private final IAdapterStorage adapterStorage;
-
- public RemoveNodesFromOpcUaAdaptersMigration() {
- adapterStorage = StorageDispatcher.INSTANCE.getNoSqlStore()
- .getAdapterInstanceStorage();
- }
-
- public RemoveNodesFromOpcUaAdaptersMigration(IAdapterStorage adapterStorage)
{
- this.adapterStorage = adapterStorage;
- }
-
- @Override
- public boolean shouldExecute() {
- return true;
- }
-
- @Override
- public String getDescription() {
- return "Remove latestFetchedNodes and nodes from OPC UA adapter instances
and updates the adapters in CouchDB.";
- }
-
- @Override
- public void executeMigration() throws IOException {
- var adapters = adapterStorage.findAll();
-
- var opcUaAdapters = filterForOpcUaAdapters(adapters);
-
- opcUaAdapters.forEach(adapter -> {
- removeTreeNodesFromConfigurationAndUpdateAdapter(adapter);
- LOG.info("The nodes and latest fetched nodes of the adapter {} have been
removed.", adapter.getElementId());
- });
-
- }
-
- private void
removeTreeNodesFromConfigurationAndUpdateAdapter(AdapterDescription adapter) {
- removeTreeNodesFromConfiguration(adapter);
- adapterStorage.updateElement(adapter);
- }
-
- /**
- * This method sets the nodes and latest fetched nodes of the adapter
configuration to an empty list.
- */
- private static void removeTreeNodesFromConfiguration(AdapterDescription
adapter) {
- adapter.getConfig()
- .stream()
- .filter(RuntimeResolvableTreeInputStaticProperty.class::isInstance)
- .map(RuntimeResolvableTreeInputStaticProperty.class::cast)
- .forEach(treeInputProperty -> {
- treeInputProperty.setNodes(Collections.emptyList());
- treeInputProperty.setLatestFetchedNodes(Collections.emptyList());
- });
- }
-
- private static List<AdapterDescription>
filterForOpcUaAdapters(List<AdapterDescription> adapters) {
- return adapters.stream()
- .filter(adapter -> adapter.getAppId()
-
.equals("org.apache.streampipes.connect.iiot.adapters.opcua"))
- .toList();
- }
-
-}
diff --git
a/streampipes-service-core/src/test/java/org/apache/streampipes/service/core/migrations/v095/MergeFilenamesAndRenameDuplicatesMigrationTest.java
b/streampipes-service-core/src/test/java/org/apache/streampipes/service/core/migrations/v095/MergeFilenamesAndRenameDuplicatesMigrationTest.java
deleted file mode 100644
index aa77248038..0000000000
---
a/streampipes-service-core/src/test/java/org/apache/streampipes/service/core/migrations/v095/MergeFilenamesAndRenameDuplicatesMigrationTest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.service.core.migrations.v095;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static
org.apache.streampipes.service.core.migrations.v095.MergeFilenamesAndRenameDuplicatesMigration.FILETYPE;
-import static
org.apache.streampipes.service.core.migrations.v095.MergeFilenamesAndRenameDuplicatesMigration.ID;
-import static
org.apache.streampipes.service.core.migrations.v095.MergeFilenamesAndRenameDuplicatesMigration.INTERNAL_FILENAME;
-import static
org.apache.streampipes.service.core.migrations.v095.MergeFilenamesAndRenameDuplicatesMigration.ORIGINAL_FILENAME;
-
-public class MergeFilenamesAndRenameDuplicatesMigrationTest {
-
- private static final Map RAW_FILEMETADATA_1 = new HashMap<String, Object>() {
- {
- put(ID, "id1");
- put(ORIGINAL_FILENAME, "file.txt");
- put(INTERNAL_FILENAME, "doesn't matter");
- put(FILETYPE, "txt");
- }
- };
-
- private static final Map RAW_FILEMETADATA_2 = new HashMap<String, Object>() {
- {
- put(ID, "id2");
- put(ORIGINAL_FILENAME, "FILE.txt");
- put(INTERNAL_FILENAME, "doesn't matter");
- put(FILETYPE, "TXT");
- }
- };
-
- private static final Map RAW_FILEMETADATA_3 = new HashMap<String, Object>() {
- {
- put(ID, "id2");
- put(ORIGINAL_FILENAME, "fIlE.TxT");
- put(INTERNAL_FILENAME, "doesn't matter");
- put(FILETYPE, "TxT");
- }
- };
-
- private static final Map RAW_FILEMETADATA_4 = new HashMap<String, Object>() {
- {
- put(ID, "id3");
- put(ORIGINAL_FILENAME, "file.csv");
- put(INTERNAL_FILENAME, "doesn't matter");
- put(FILETYPE, "csv");
- }
- };
-
- private List<Map<String, Object>> couchDbRawFileMetadata;
-
- private MergeFilenamesAndRenameDuplicatesMigration migration;
-
- @BeforeEach
- public void setUp() {
- migration = new MergeFilenamesAndRenameDuplicatesMigration(true);
- couchDbRawFileMetadata = new ArrayList<>() {
- {
- add(RAW_FILEMETADATA_1);
- add(RAW_FILEMETADATA_2);
- add(RAW_FILEMETADATA_3);
- add(RAW_FILEMETADATA_4);
- }
- };
- }
-
- @Test
- public void testMigration() {
- // Test that the migration successfully groups FileMetadata by
originalFilename
- migration.getFileMetadataToUpdate(couchDbRawFileMetadata);
- Assertions.assertEquals(2,
migration.fileMetadataGroupedByOriginalName.size());
- Assertions.assertEquals(3,
-
migration.fileMetadataGroupedByOriginalName.get("file.txt").size());
- Assertions.assertEquals(1,
-
migration.fileMetadataGroupedByOriginalName.get("file.csv").size());
-
- // Test that the migration successfully renames duplicate files
- migration.fileMetadataGroupedByOriginalName.forEach(
- (originalFilename, fileMetadataList) ->
migration.update(originalFilename, fileMetadataList));
- Assertions.assertEquals("file.txt",
-
migration.fileMetadataGroupedByOriginalName.get("file.txt").get(0).getFilename());
- Assertions.assertEquals("file(2).TXT",
-
migration.fileMetadataGroupedByOriginalName.get("file.txt").get(1).getFilename());
- Assertions.assertEquals("file(3).TxT",
-
migration.fileMetadataGroupedByOriginalName.get("file.txt").get(2).getFilename());
- Assertions.assertEquals("file.csv",
-
migration.fileMetadataGroupedByOriginalName.get("file.csv").get(0).getFilename());
- }
-}
\ No newline at end of file
diff --git
a/streampipes-service-core/src/test/java/org/apache/streampipes/service/core/migrations/v970/RemoveNodesFromOpcUaAdaptersMigrationTest.java
b/streampipes-service-core/src/test/java/org/apache/streampipes/service/core/migrations/v970/RemoveNodesFromOpcUaAdaptersMigrationTest.java
deleted file mode 100644
index 7925b57bab..0000000000
---
a/streampipes-service-core/src/test/java/org/apache/streampipes/service/core/migrations/v970/RemoveNodesFromOpcUaAdaptersMigrationTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.streampipes.service.core.migrations.v970;
-
-import org.apache.streampipes.model.connect.adapter.AdapterDescription;
-import
org.apache.streampipes.model.staticproperty.RuntimeResolvableTreeInputStaticProperty;
-import org.apache.streampipes.model.staticproperty.TreeInputNode;
-import org.apache.streampipes.storage.api.connect.IAdapterStorage;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.mockito.ArgumentCaptor;
-
-import java.io.IOException;
-import java.util.List;
-
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-
-class RemoveNodesFromOpcUaAdaptersMigrationTest {
-
- private RemoveNodesFromOpcUaAdaptersMigration migration;
- private IAdapterStorage adapterStorage;
-
- @BeforeEach
- void setUp() {
- adapterStorage = mock(IAdapterStorage.class);
- migration = new RemoveNodesFromOpcUaAdaptersMigration(adapterStorage);
- }
-
- @Test
- void executeMigration_RemoveConfigsFromOpcUaAdapter() throws IOException {
- var opcUaAdapter = prepareOpcUaAdapterWithNodesAndLatestFetchedNodes();
- when(adapterStorage.findAll()).thenReturn(List.of(opcUaAdapter));
-
- migration.executeMigration();
-
- // Ensure that the nodes and latestFetchedNodes are removed from the
adapter description
- var captor = ArgumentCaptor.forClass(AdapterDescription.class);
- verify(adapterStorage).updateElement(captor.capture());
- var updatedAdapter = captor.getValue();
- var treeProperty = getFirstTreeInputProperty(updatedAdapter);
- assertTrue(treeProperty.getNodes().isEmpty());
- assertTrue(treeProperty.getLatestFetchedNodes()
- .isEmpty());
- }
-
- private RuntimeResolvableTreeInputStaticProperty
getFirstTreeInputProperty(AdapterDescription adapterDescription) {
- return adapterDescription.getConfig()
- .stream()
- .filter(config -> config instanceof
RuntimeResolvableTreeInputStaticProperty)
- .map(config ->
(RuntimeResolvableTreeInputStaticProperty) config)
- .findFirst()
- .orElse(null);
- }
-
- private AdapterDescription
prepareOpcUaAdapterWithNodesAndLatestFetchedNodes() {
- var opcUaAdapter = new AdapterDescription();
-
opcUaAdapter.setAppId("org.apache.streampipes.connect.iiot.adapters.opcua");
- var property = new RuntimeResolvableTreeInputStaticProperty();
- property.setNodes(List.of(new TreeInputNode()));
- property.setLatestFetchedNodes(List.of(new TreeInputNode()));
- opcUaAdapter.setConfig(List.of(property));
- return opcUaAdapter;
- }
-}
\ No newline at end of file
diff --git
a/streampipes-service-discovery/src/main/java/org/apache/streampipes/svcdiscovery/SpServiceDiscoveryCore.java
b/streampipes-service-discovery/src/main/java/org/apache/streampipes/svcdiscovery/SpServiceDiscoveryCore.java
index 4378eef1d4..aa769ae84c 100644
---
a/streampipes-service-discovery/src/main/java/org/apache/streampipes/svcdiscovery/SpServiceDiscoveryCore.java
+++
b/streampipes-service-discovery/src/main/java/org/apache/streampipes/svcdiscovery/SpServiceDiscoveryCore.java
@@ -120,7 +120,6 @@ public class SpServiceDiscoveryCore implements
ISpServiceDiscovery {
if (retryCount < MAX_RETRIES) {
try {
retryCount++;
- LOG.info("Could not find any extensions services, retrying ({}/{})",
retryCount, MAX_RETRIES);
TimeUnit.MILLISECONDS.sleep(1000);
return findServices(retryCount);
} catch (InterruptedException e) {