summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src')
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/dao/impl/HealingDaoImpl.java50
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerFactoryImpl.java9
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java354
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/utils/HealingConfiguration.java6
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/utils/HealingUtil.java6
5 files changed, 183 insertions, 242 deletions
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/dao/impl/HealingDaoImpl.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/dao/impl/HealingDaoImpl.java
index d813c41448..0e60932392 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/dao/impl/HealingDaoImpl.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/dao/impl/HealingDaoImpl.java
@@ -7,9 +7,9 @@
* Licensed 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.
@@ -17,50 +17,42 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.healing.dao.impl;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.mapping.annotations.Accessor;
import com.datastax.driver.mapping.annotations.Query;
+import java.util.Optional;
import org.openecomp.core.nosqldb.api.NoSqlDb;
import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
import org.openecomp.sdc.healing.dao.HealingDao;
-import java.util.Optional;
-
/**
* Created by ayalaben on 10/17/2017
*/
public class HealingDaoImpl implements HealingDao {
- private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static HealingAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(HealingAccessor.class);
-
- @Override
- public Optional<Boolean> getItemHealingFlag(String space, String itemId, String versionId) {
- ResultSet result = accessor.getItemHealingFlag(space, itemId, versionId);
- return result.getAvailableWithoutFetching() < 1
- ? Optional.empty()
- : Optional.of(result.one().getBool("healing_needed"));
- }
-
- @Override
- public void setItemHealingFlag(boolean healingNeededFlag, String space, String itemId,
- String versionId) {
- accessor.setItemHealingFlag(healingNeededFlag, space, itemId, versionId);
- }
+ private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static HealingAccessor accessor = noSqlDb.getMappingManager().createAccessor(HealingAccessor.class);
+ @Override
+ public Optional<Boolean> getItemHealingFlag(String space, String itemId, String versionId) {
+ ResultSet result = accessor.getItemHealingFlag(space, itemId, versionId);
+ return result.getAvailableWithoutFetching() < 1 ? Optional.empty() : Optional.of(result.one().getBool("healing_needed"));
+ }
- @Accessor
- interface HealingAccessor {
+ @Override
+ public void setItemHealingFlag(boolean healingNeededFlag, String space, String itemId, String versionId) {
+ accessor.setItemHealingFlag(healingNeededFlag, space, itemId, versionId);
+ }
- @Query("SELECT healing_needed FROM healing WHERE space=? AND item_id=? AND version_id=?")
- ResultSet getItemHealingFlag(String space, String itemId, String versionId);
+ @Accessor
+ interface HealingAccessor {
- @Query("UPDATE healing SET healing_needed=? WHERE space=? AND item_id=? AND version_id=?")
- void setItemHealingFlag(boolean flag, String space, String itemId, String versionId);
+ @Query("SELECT healing_needed FROM healing WHERE space=? AND item_id=? AND version_id=?")
+ ResultSet getItemHealingFlag(String space, String itemId, String versionId);
- }
+ @Query("UPDATE healing SET healing_needed=? WHERE space=? AND item_id=? AND version_id=?")
+ void setItemHealingFlag(boolean flag, String space, String itemId, String versionId);
+ }
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerFactoryImpl.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerFactoryImpl.java
index 5a283f954b..9fff4f4698 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerFactoryImpl.java
@@ -7,9 +7,9 @@
* Licensed 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.healing.impl;
import org.openecomp.sdc.healing.api.HealingManager;
@@ -29,9 +28,9 @@ import org.openecomp.sdc.versioning.VersioningManagerFactory;
* Created by Talio on 11/29/2016.
*/
public class HealingManagerFactoryImpl extends HealingManagerFactory {
+
@Override
public HealingManager createInterface() {
- return new HealingManagerImpl(
- VersioningManagerFactory.getInstance().createInterface(), new HealingDaoImpl());
+ return new HealingManagerImpl(VersioningManagerFactory.getInstance().createInterface(), new HealingDaoImpl());
}
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
index fa9c6d1cdf..4478c00a63 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
@@ -17,10 +17,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.healing.impl;
-
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.json.JsonUtil;
@@ -39,235 +46,178 @@ import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.dao.types.VersionStatus;
import org.openecomp.sdc.versioning.types.VersionCreationMethod;
-import java.util.*;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
public class HealingManagerImpl implements HealingManager {
- private static final String HEALERS_BY_ENTITY_TYPE_FILE = "entityHealingConfiguration.json";
- private static final String HEALING_USER_SUFFIX = "_healer";
- private static final String PUBLIC_USER = "public";
-
- private HealingDao healingDao;
- private VersioningManager versioningManager;
+ private static final String HEALERS_BY_ENTITY_TYPE_FILE = "entityHealingConfiguration.json";
+ private static final String HEALING_USER_SUFFIX = "_healer";
+ private static final String PUBLIC_USER = "public";
+ private HealingDao healingDao;
+ private VersioningManager versioningManager;
- public HealingManagerImpl(VersioningManager versioningManager, HealingDao healingDao) {
- this.versioningManager = versioningManager;
- this.healingDao = healingDao;
- }
-
- @Override
- public Optional<Version> healItemVersion(final String itemId, final Version version,
- final ItemType itemType, final boolean force) {
- String user = getUser();
- populateVersionInfo(itemId, version);
-
- if (!isHealingNeeded(itemId, version, force, user)) {
- return Optional.empty();
+ public HealingManagerImpl(VersioningManager versioningManager, HealingDao healingDao) {
+ this.versioningManager = versioningManager;
+ this.healingDao = healingDao;
}
- Map<String, Collection<String>> healersByType = getItemHealers(itemType);
- List<String> failureMessages = new LinkedList<>();
- List<Healer> structureHealersToRun =
- getHealersToRun(healersByType.get(HealerType.structure.name()), itemId, version,
- failureMessages);
- List<Healer> dataHealersToRun =
- getHealersToRun(healersByType.get(HealerType.data.name()), itemId, version,
- failureMessages);
-
- if (structureHealersToRun.isEmpty() && dataHealersToRun.isEmpty()) {
- markAsHealed(itemId, version.getId(), user);
- markAsHealed(itemId, version.getId(), PUBLIC_USER);
- return Optional.empty();
+ @Override
+ public Optional<Version> healItemVersion(final String itemId, final Version version, final ItemType itemType, final boolean force) {
+ String user = getUser();
+ populateVersionInfo(itemId, version);
+ if (!isHealingNeeded(itemId, version, force, user)) {
+ return Optional.empty();
+ }
+ Map<String, Collection<String>> healersByType = getItemHealers(itemType);
+ List<String> failureMessages = new LinkedList<>();
+ List<Healer> structureHealersToRun = getHealersToRun(healersByType.get(HealerType.structure.name()), itemId, version, failureMessages);
+ List<Healer> dataHealersToRun = getHealersToRun(healersByType.get(HealerType.data.name()), itemId, version, failureMessages);
+ if (structureHealersToRun.isEmpty() && dataHealersToRun.isEmpty()) {
+ markAsHealed(itemId, version.getId(), user);
+ markAsHealed(itemId, version.getId(), PUBLIC_USER);
+ return Optional.empty();
+ }
+ Optional<Version> healVersion = getHealVersion(itemId, version);
+ if (!healVersion.isPresent()) {
+ // do NOT turn off flag here (in thought of saving version calculate performance next
+
+ // time) because maybe next time the next version will be available (due to deletion of
+
+ // the taken one)
+ return Optional.empty();
+ }
+ failureMessages.addAll(doHeal(itemId, healVersion.get(), version, structureHealersToRun, dataHealersToRun, user, force));
+ handleFailures(failureMessages);
+ return healVersion;
}
- Optional<Version> healVersion = getHealVersion(itemId, version);
- if (!healVersion.isPresent()) {
- // do NOT turn off flag here (in thought of saving version calculate performance next
- // time) because maybe next time the next version will be available (due to deletion of
- // the taken one)
- return Optional.empty();
+ private void populateVersionInfo(String itemId, Version version) {
+ if (version.getStatus() != null) {
+ return;
+ }
+ Version retrievedVersion = versioningManager.get(itemId, version);
+ version.setStatus(retrievedVersion.getStatus());
+ version.setBaseId(retrievedVersion.getBaseId());
}
- failureMessages.addAll(
- doHeal(itemId, healVersion.get(), version, structureHealersToRun, dataHealersToRun, user,
- force));
- handleFailures(failureMessages);
-
- return healVersion;
- }
-
- private void populateVersionInfo(String itemId, Version version) {
- if (version.getStatus() != null) {
- return;
+ private boolean isHealingNeeded(String itemId, Version version, boolean force, String user) {
+ return force || isHealingFlagOn(itemId, version.getId(), user).orElse(isHealingFlagOn(itemId, version.getId(), PUBLIC_USER).orElse(
+ version.getStatus() == VersionStatus.Draft && version.getBaseId() != null && isHealingFlagOn(itemId, version.getBaseId(), user)
+ .orElse(isHealingFlagOn(itemId, version.getBaseId(), PUBLIC_USER).orElse(false))));
}
- Version retrievedVersion = versioningManager.get(itemId, version);
- version.setStatus(retrievedVersion.getStatus());
- version.setBaseId(retrievedVersion.getBaseId());
- }
-
- private boolean isHealingNeeded(String itemId, Version version, boolean force, String user) {
- return force || isHealingFlagOn(itemId, version.getId(), user)
- .orElse(isHealingFlagOn(itemId, version.getId(), PUBLIC_USER)
- .orElse(version.getStatus() == VersionStatus.Draft && version.getBaseId() != null &&
- isHealingFlagOn(itemId, version.getBaseId(), user)
- .orElse(isHealingFlagOn(itemId, version.getBaseId(), PUBLIC_USER)
- .orElse(false))));
- }
-
- private Optional<Version> getHealVersion(String itemId, Version version) {
- return version.getStatus() == VersionStatus.Certified
- ? createNewVersion(itemId, version.getId())
- : Optional.of(version);
- }
-
- private Optional<Version> createNewVersion(String itemId, String versionId) {
- Version newVersion = new Version();
- newVersion.setBaseId(versionId);
- newVersion.setDescription("Version is created by healing process");
- try {
- return Optional.of(versioningManager.create(itemId, newVersion, VersionCreationMethod.major));
- } catch (Exception e) {
- return Optional.empty();
+ private Optional<Version> getHealVersion(String itemId, Version version) {
+ return version.getStatus() == VersionStatus.Certified ? createNewVersion(itemId, version.getId()) : Optional.of(version);
}
- }
- private List<String> doHeal(String itemId, Version version, Version origVersion,
- List<Healer> structureHealersToRun,
- List<Healer> dataHealersToRun, String user,
- boolean force) {
- boolean publicFlagOn = isHealingFlagOn(itemId, origVersion.getId(), PUBLIC_USER)
- .orElse(origVersion.getBaseId() != null &&
- isHealingFlagOn(itemId, origVersion.getBaseId(), PUBLIC_USER).orElse(false));
+ private Optional<Version> createNewVersion(String itemId, String versionId) {
+ Version newVersion = new Version();
+ newVersion.setBaseId(versionId);
+ newVersion.setDescription("Version is created by healing process");
+ try {
+ return Optional.of(versioningManager.create(itemId, newVersion, VersionCreationMethod.major));
+ } catch (Exception e) {
+ return Optional.empty();
+ }
+ }
- List<String> failureMessages =
- force || origVersion.getStatus() == VersionStatus.Certified || publicFlagOn
- ? healPublic(itemId, version, origVersion, structureHealersToRun, dataHealersToRun,
- user)
- : new LinkedList<>();
+ private List<String> doHeal(String itemId, Version version, Version origVersion, List<Healer> structureHealersToRun,
+ List<Healer> dataHealersToRun, String user, boolean force) {
+ boolean publicFlagOn = isHealingFlagOn(itemId, origVersion.getId(), PUBLIC_USER)
+ .orElse(origVersion.getBaseId() != null && isHealingFlagOn(itemId, origVersion.getBaseId(), PUBLIC_USER).orElse(false));
+ List<String> failureMessages =
+ force || origVersion.getStatus() == VersionStatus.Certified || publicFlagOn ? healPublic(itemId, version, origVersion,
+ structureHealersToRun, dataHealersToRun, user) : new LinkedList<>();
+ failureMessages.addAll(healPrivate(itemId, version, origVersion, structureHealersToRun, dataHealersToRun, user));
+ return failureMessages;
+ }
- failureMessages.addAll(
- healPrivate(itemId, version, origVersion, structureHealersToRun, dataHealersToRun, user));
+ private List<String> healPrivate(String itemId, Version version, Version origVersion, List<Healer> structureHealersToRun,
+ List<Healer> dataHealersToRun, String user) {
+ List<String> failureMessages;
+ if (origVersion.getStatus() == VersionStatus.Certified) {
+ failureMessages = executeHealers(itemId, version,
+ Stream.concat(structureHealersToRun.stream(), dataHealersToRun.stream()).collect(Collectors.toList()));
+ } else {
+ if (structureHealersToRun.isEmpty()) {
+ failureMessages = executeHealers(itemId, version, dataHealersToRun);
+ } else {
+ versioningManager.forceSync(itemId, version);
+ failureMessages = new LinkedList<>();
+ }
+ }
+ markAsHealed(itemId, origVersion.getId(), user);
+ return failureMessages;
+ }
- return failureMessages;
- }
+ private List<String> healPublic(String itemId, Version version, Version origVersion, List<Healer> structureHealersToRun,
+ List<Healer> dataHealersToRun, String user) {
+ List<String> failureMessages = origVersion.getStatus() == VersionStatus.Certified ? new LinkedList<>()
+ : healPublic(itemId, version, Stream.concat(structureHealersToRun.stream(), dataHealersToRun.stream()).collect(Collectors.toList()),
+ user);
+ markAsHealed(itemId, origVersion.getId(), PUBLIC_USER);
+ return failureMessages;
+ }
- private List<String> healPrivate(String itemId, Version version, Version origVersion,
- List<Healer> structureHealersToRun,
- List<Healer> dataHealersToRun, String user) {
- List<String> failureMessages;
- if (origVersion.getStatus() == VersionStatus.Certified) {
- failureMessages = executeHealers(itemId, version,
- Stream.concat(structureHealersToRun.stream(), dataHealersToRun.stream())
- .collect(Collectors.toList()));
- } else {
- if (structureHealersToRun.isEmpty()) {
- failureMessages = executeHealers(itemId, version, dataHealersToRun);
- } else {
+ private List<String> healPublic(String itemId, Version version, List<Healer> healers, String user) {
+ String tenant = SessionContextProviderFactory.getInstance().createInterface().get().getTenant();
+ SessionContextProviderFactory.getInstance().createInterface().create(user + HEALING_USER_SUFFIX, tenant);
versioningManager.forceSync(itemId, version);
- failureMessages = new LinkedList<>();
- }
+ List<String> failureMessages = executeHealers(itemId, version, healers);
+ Version publicVersion = versioningManager.get(itemId, version);
+ if (Objects.nonNull(publicVersion.getState()) && publicVersion.getState().isDirty()) {
+ versioningManager.publish(itemId, version, "Healing vsp");
+ }
+ SessionContextProviderFactory.getInstance().createInterface().create(user, tenant);
+ return failureMessages;
}
- markAsHealed(itemId, origVersion.getId(), user);
- return failureMessages;
- }
-
- private List<String> healPublic(String itemId, Version version, Version origVersion,
- List<Healer> structureHealersToRun,
- List<Healer> dataHealersToRun, String user) {
- List<String> failureMessages = origVersion.getStatus() == VersionStatus.Certified
- ? new LinkedList<>()
- : healPublic(itemId, version,
- Stream.concat(structureHealersToRun.stream(), dataHealersToRun.stream())
- .collect(Collectors.toList()), user);
-
- markAsHealed(itemId, origVersion.getId(), PUBLIC_USER);
- return failureMessages;
- }
-
- private List<String> healPublic(String itemId, Version version, List<Healer> healers,
- String user) {
- String tenant = SessionContextProviderFactory.getInstance().createInterface().get().getTenant();
- SessionContextProviderFactory.getInstance().createInterface()
- .create(user + HEALING_USER_SUFFIX, tenant);
-
- versioningManager.forceSync(itemId, version);
- List<String> failureMessages = executeHealers(itemId, version, healers);
- Version publicVersion = versioningManager.get(itemId, version);
-
- if (Objects.nonNull(publicVersion.getState()) && publicVersion.getState().isDirty()) {
- versioningManager.publish(itemId, version, "Healing vsp");
+ private List<String> executeHealers(String itemId, Version version, List<Healer> healers) {
+ List<String> failureMessages = new LinkedList<>();
+ for (Healer healer : healers) {
+ try {
+ healer.heal(itemId, version);
+ } catch (Exception e) {
+ failureMessages.add(String.format("Failure in healer %s: %s", healer.getClass().getName(), e.getMessage()));
+ }
+ }
+ return failureMessages;
}
- SessionContextProviderFactory.getInstance().createInterface().create(user, tenant);
- return failureMessages;
- }
-
- private List<String> executeHealers(String itemId, Version version, List<Healer> healers) {
- List<String> failureMessages = new LinkedList<>();
- for (Healer healer : healers) {
- try {
- healer.heal(itemId, version);
- } catch (Exception e) {
- failureMessages.add(
- String.format("Failure in healer %s: %s", healer.getClass().getName(), e.getMessage()));
- }
+ private Optional<Boolean> isHealingFlagOn(String itemId, String version, String user) {
+ return healingDao.getItemHealingFlag(user, itemId, version);
}
- return failureMessages;
- }
-
- private Optional<Boolean> isHealingFlagOn(String itemId, String version, String user) {
- return healingDao.getItemHealingFlag(user, itemId, version);
- }
-
- private void markAsHealed(String itemId, String versionId, String user) {
- healingDao.setItemHealingFlag(false, user, itemId, versionId);
- }
+ private void markAsHealed(String itemId, String versionId, String user) {
+ healingDao.setItemHealingFlag(false, user, itemId, versionId);
+ }
- private void handleFailures(List<String> failureMessages) {
- if (!failureMessages.isEmpty()) {
- throw new CoreException(new ErrorCode.ErrorCodeBuilder()
- .withCategory(ErrorCategory.APPLICATION)
- .withMessage(CommonMethods.listToSeparatedString(failureMessages, '\n')).build());
+ private void handleFailures(List<String> failureMessages) {
+ if (!failureMessages.isEmpty()) {
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
+ .withMessage(CommonMethods.listToSeparatedString(failureMessages, '\n')).build());
+ }
}
- }
- private List<Healer> getHealersToRun(Collection<String> healersClassNames, String itemId,
- Version version, List<String> failureMessages) {
- return healersClassNames == null
- ? Collections.emptyList()
- : healersClassNames.stream()
- .map(healerClassName -> getHealerInstance(healerClassName, failureMessages))
- .filter(Optional::isPresent)
- .map(Optional::get)
- .filter(healer -> healer.isHealingNeeded(itemId, version))
- .collect(Collectors.toList());
- }
+ private List<Healer> getHealersToRun(Collection<String> healersClassNames, String itemId, Version version, List<String> failureMessages) {
+ return healersClassNames == null ? Collections.emptyList()
+ : healersClassNames.stream().map(healerClassName -> getHealerInstance(healerClassName, failureMessages)).filter(Optional::isPresent)
+ .map(Optional::get).filter(healer -> healer.isHealingNeeded(itemId, version)).collect(Collectors.toList());
+ }
- private Optional<Healer> getHealerInstance(String healerClassName, List<String> failureMessages) {
- try {
- return Optional.of((Healer) Class.forName(healerClassName).getConstructor().newInstance());
- } catch (Exception e) {
- failureMessages
- .add(String.format(Messages.CANT_LOAD_HEALING_CLASS.getErrorMessage(), healerClassName));
- return Optional.empty();
+ private Optional<Healer> getHealerInstance(String healerClassName, List<String> failureMessages) {
+ try {
+ return Optional.of((Healer) Class.forName(healerClassName).getConstructor().newInstance());
+ } catch (Exception e) {
+ failureMessages.add(String.format(Messages.CANT_LOAD_HEALING_CLASS.getErrorMessage(), healerClassName));
+ return Optional.empty();
+ }
}
- }
- private Map<String, Collection<String>> getItemHealers(ItemType itemType) {
- Map healingConfig = FileUtils
- .readViaInputStream(HEALERS_BY_ENTITY_TYPE_FILE,
- stream -> JsonUtil.json2Object(stream, Map.class));
- return (Map<String, Collection<String>>) healingConfig
- .getOrDefault(itemType.name(), Collections.emptyMap());
- }
+ private Map<String, Collection<String>> getItemHealers(ItemType itemType) {
+ Map healingConfig = FileUtils.readViaInputStream(HEALERS_BY_ENTITY_TYPE_FILE, stream -> JsonUtil.json2Object(stream, Map.class));
+ return (Map<String, Collection<String>>) healingConfig.getOrDefault(itemType.name(), Collections.emptyMap());
+ }
- private String getUser() {
- return SessionContextProviderFactory.getInstance().createInterface().get().getUser()
- .getUserId();
- }
+ private String getUser() {
+ return SessionContextProviderFactory.getInstance().createInterface().get().getUser().getUserId();
+ }
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/utils/HealingConfiguration.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/utils/HealingConfiguration.java
index 7767277444..2cfa874d28 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/utils/HealingConfiguration.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/utils/HealingConfiguration.java
@@ -7,9 +7,9 @@
* Licensed 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.
@@ -17,11 +17,11 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.healing.utils;
/**
* Created by Talio on 11/29/2016.
*/
public class HealingConfiguration {
+
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/utils/HealingUtil.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/utils/HealingUtil.java
index e955c83b79..3a815e9867 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/utils/HealingUtil.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/utils/HealingUtil.java
@@ -7,9 +7,9 @@
* Licensed 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.
@@ -17,11 +17,11 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.healing.utils;
/**
* Created by Talio on 11/29/2016.
*/
public class HealingUtil {
+
}