diff options
Diffstat (limited to 'openecomp-be/lib')
11 files changed, 63 insertions, 22 deletions
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/src/main/java/org/openecomp/core/dao/types/UniqueValueEntity.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/src/main/java/org/openecomp/core/dao/types/UniqueValueEntity.java index 5c3d300044..c53280ed7a 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/src/main/java/org/openecomp/core/dao/types/UniqueValueEntity.java +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/src/main/java/org/openecomp/core/dao/types/UniqueValueEntity.java @@ -23,7 +23,7 @@ package org.openecomp.core.dao.types; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; -@Table(keyspace = "dox", name = "unique_value") +@Table(name = "unique_value") public class UniqueValueEntity { @PartitionKey diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/pom.xml b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/pom.xml index 8ec98379c6..99696392d3 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/pom.xml +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/pom.xml @@ -60,5 +60,10 @@ <scope>test</scope> <version>${junit.version}</version> </dependency> + <dependency> + <groupId>org.openecomp.sdc.core</groupId> + <artifactId>openecomp-session-lib</artifactId> + <version>1.2.0-SNAPSHOT</version> + </dependency> </dependencies> </project> diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraSessionFactory.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraSessionFactory.java index 8d7b5c9f3a..f06817965b 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraSessionFactory.java +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraSessionFactory.java @@ -26,6 +26,7 @@ import com.datastax.driver.core.policies.LoadBalancingPolicy; import com.datastax.driver.core.policies.TokenAwarePolicy; import org.openecomp.core.nosqldb.util.CassandraUtils; import org.openecomp.sdc.common.errors.SdcConfigurationException; +import org.openecomp.sdc.common.session.SessionContextProviderFactory; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; @@ -82,7 +83,8 @@ public class CassandraSessionFactory { Cluster cluster = builder.build(); - String keyStore = CassandraUtils.getKeySpace(); + String keyStore = SessionContextProviderFactory.getInstance().createInterface().get() + .getTenant(); return cluster.connect(keyStore); } diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContextProvider.java b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContextProvider.java index 8efbbd10eb..5c4da8d855 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContextProvider.java +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContextProvider.java @@ -2,7 +2,7 @@ package org.openecomp.sdc.common.session; public interface SessionContextProvider { - void create(String user); + void create(String user, String tenant); SessionContext get(); diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/impl/AsdcSessionContextProvider.java b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/impl/AsdcSessionContextProvider.java index 53a40a163f..7c4b0ecc0c 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/impl/AsdcSessionContextProvider.java +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/impl/AsdcSessionContextProvider.java @@ -1,5 +1,7 @@ package org.openecomp.sdc.common.session.impl; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.ErrorCode; import org.openecomp.sdc.common.session.SessionContext; import org.openecomp.sdc.common.session.SessionContextProvider; import org.openecomp.sdc.common.session.User; @@ -7,24 +9,33 @@ import org.openecomp.sdc.common.session.User; public class AsdcSessionContextProvider implements SessionContextProvider { private static final ThreadLocal<String> threadUserId = new ThreadLocal<>(); + private static final ThreadLocal<String> threadTenant = new ThreadLocal<>(); @Override - public void create(String userId) { + public void create(String userId, String tenant) { threadUserId.set(userId); + threadTenant.set(tenant); } @Override public SessionContext get() { if (threadUserId.get() == null) { - throw new RuntimeException("UserId was not set for this thread"); + throw new CoreException(new ErrorCode.ErrorCodeBuilder().withMessage("UserId was not set " + + "for this thread").build()); } - return new AsdcSessionContext(new User(threadUserId.get()), "dox"); + if (threadTenant.get() == null) { + throw new CoreException(new ErrorCode.ErrorCodeBuilder().withMessage("Tenant was not set " + + "for this thread").build()); + } + + return new AsdcSessionContext(new User(threadUserId.get()), threadTenant.get()); } @Override public void close() { threadUserId.remove(); + threadTenant.remove(); } private static class AsdcSessionContext implements SessionContext { diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenUtil.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenUtil.java index 623f958ceb..494428f7a0 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenUtil.java +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenUtil.java @@ -12,21 +12,35 @@ import org.openecomp.types.ElementPropertyName; public class ZusammenUtil { + private ZusammenUtil() { + throw new IllegalStateException("Utility class"); + } + public static SessionContext createSessionContext() { org.openecomp.sdc.common.session.SessionContext asdcSessionContext = SessionContextProviderFactory.getInstance().createInterface().get(); + return createSessionContext(asdcSessionContext.getUser().getUserId(), asdcSessionContext + .getTenant()); + } + + private static SessionContext createSessionContext(String user, String tenant) { SessionContext sessionContext = new SessionContext(); - sessionContext.setUser(new UserInfo(asdcSessionContext.getUser().getUserId())); - sessionContext.setTenant(asdcSessionContext.getTenant()); + sessionContext.setUser(new UserInfo(user)); + sessionContext.setTenant(tenant); return sessionContext; } public static ZusammenElement buildStructuralElement(ElementType elementType, Action action) { + return buildStructuralElement(elementType.name(), action); + } + + + public static ZusammenElement buildStructuralElement(String elementType, Action action) { ZusammenElement element = buildElement(null, action); Info info = new Info(); - info.setName(elementType.name()); - info.addProperty(ElementPropertyName.elementType.name(), elementType.name()); + info.setName(elementType); + info.addProperty(ElementPropertyName.elementType.name(), elementType); element.setInfo(info); return element; } 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 9db9ea44b8..07122f093e 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 @@ -23,7 +23,10 @@ package org.openecomp.sdc.healing.impl; import org.openecomp.core.utilities.CommonMethods; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.ErrorCode; import org.openecomp.sdc.common.errors.Messages; +import org.openecomp.sdc.common.session.SessionContext; import org.openecomp.sdc.common.session.SessionContextProviderFactory; import org.openecomp.sdc.datatypes.model.ItemType; import org.openecomp.sdc.healing.api.HealingManager; @@ -98,8 +101,9 @@ public class HealingManagerImpl implements HealingManager { : Optional.empty(); if (privateFailureMessages.isPresent() || publicFailureMessages.isPresent()) { - throw new RuntimeException( - publicFailureMessages.orElse("") + " " + privateFailureMessages.orElse("")); + throw new CoreException(new ErrorCode.ErrorCodeBuilder().withMessage( + publicFailureMessages.orElse("") + " " + privateFailureMessages.orElse("")) + .build()); } } @@ -126,8 +130,10 @@ public class HealingManagerImpl implements HealingManager { private Optional<String> healPublic(String itemId, Version version, Map<String, Map<String, String>> itemHealers, String user) { - SessionContextProviderFactory.getInstance().createInterface() - .create(user + HEALING_USER_SUFFIX); + SessionContext context = + SessionContextProviderFactory.getInstance().createInterface().get(); + SessionContextProviderFactory.getInstance().createInterface().create(user + + HEALING_USER_SUFFIX,context.getTenant()); versioningManager.sync(itemId, version); @@ -138,7 +144,7 @@ public class HealingManagerImpl implements HealingManager { versioningManager.publish(itemId, version, "Healing vsp"); } - SessionContextProviderFactory.getInstance().createInterface().create(user); + SessionContextProviderFactory.getInstance().createInterface().create(user, context.getTenant()); return healingFailureMessages; } @@ -161,7 +167,8 @@ public class HealingManagerImpl implements HealingManager { Object result = executeHealer(itemId, version, healerClassName, healingFailureMessages); if (!healingFailureMessages.isEmpty()) { - throw new RuntimeException(CommonMethods.listToSeparatedString(healingFailureMessages, '\n')); + throw new CoreException(new ErrorCode.ErrorCodeBuilder().withMessage(CommonMethods + .listToSeparatedString(healingFailureMessages, '\n')).build()); } return result; } @@ -223,8 +230,6 @@ public class HealingManagerImpl implements HealingManager { } private Map<String, Map<String, String>> getItemHealers(ItemType itemType) { - // TODO: 11/29/2017 create objects to hold this configuration + - // load once from the json file and use the relevant healers (by itemType, healerType) as needed. Map healingConfig = FileUtils .readViaInputStream(HEALERS_BY_ENTITY_TYPE_FILE, stream -> JsonUtil.json2Object(stream, Map.class)); diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java index 74bdeef16e..c24934508e 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java @@ -65,10 +65,11 @@ public class ServiceModelDaoFactoryTest { private static final Version version = Version.valueOf("1.0"); private static final String baseServiceTemplateName = "baseYaml.yaml"; private static String artifact001; + private static final String tenant = "dox"; @BeforeMethod public void setUp(){ - SessionContextProviderFactory.getInstance().createInterface().create("test"); + SessionContextProviderFactory.getInstance().createInterface().create("test", tenant); } @AfterMethod diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/dao/impl/zusammen/ItemZusammenDaoImplTest.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/dao/impl/zusammen/ItemZusammenDaoImplTest.java index b2a27de2c1..bfa660a5a1 100644 --- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/dao/impl/zusammen/ItemZusammenDaoImplTest.java +++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/dao/impl/zusammen/ItemZusammenDaoImplTest.java @@ -36,6 +36,7 @@ public class ItemZusammenDaoImplTest { private static final String ITEM_VERSIONS_STATUSES = "item_versions_statuses"; private static final String APP_PROP_1 = "app_prop1"; private static final String APP_PROP_2 = "app_prop2"; + private static final String tenant = "dox"; @Mock private ZusammenAdaptor zusammenAdaptorMock; @@ -45,7 +46,7 @@ public class ItemZusammenDaoImplTest { @BeforeMethod public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - SessionContextProviderFactory.getInstance().createInterface().create(USER); + SessionContextProviderFactory.getInstance().createInterface().create(USER, tenant); } @Test diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/dao/impl/zusammen/VersionZusammenDaoImplTest.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/dao/impl/zusammen/VersionZusammenDaoImplTest.java index 76e1fe56b6..603e2b0297 100644 --- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/dao/impl/zusammen/VersionZusammenDaoImplTest.java +++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/dao/impl/zusammen/VersionZusammenDaoImplTest.java @@ -37,6 +37,7 @@ import static org.openecomp.sdc.versioning.dao.impl.zusammen.TestUtil.createZusa public class VersionZusammenDaoImplTest { private static final String USER = "user1"; + private static final String tenant = "dox"; @Mock private ZusammenAdaptor zusammenAdaptorMock; @InjectMocks @@ -45,7 +46,7 @@ public class VersionZusammenDaoImplTest { @BeforeMethod public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - SessionContextProviderFactory.getInstance().createInterface().create(USER); + SessionContextProviderFactory.getInstance().createInterface().create(USER, tenant); } @Test diff --git a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/impl/ItemManagerImplTest.java b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/impl/ItemManagerImplTest.java index 6ac2ab30d5..95c38e46e4 100644 --- a/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/impl/ItemManagerImplTest.java +++ b/openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/impl/ItemManagerImplTest.java @@ -32,6 +32,7 @@ public class ItemManagerImplTest { private static final String ITEM_NAME = "item 1 name"; private static final String ITEM_TYPE_A = "A"; private static final String ITEM_TYPE_B = "B"; + private static final String tenant = "dox"; @Mock private ItemDao itemDao; @Mock @@ -81,7 +82,7 @@ public class ItemManagerImplTest { @Test public void testCreate() throws Exception { - SessionContextProviderFactory.getInstance().createInterface().create(USER); + SessionContextProviderFactory.getInstance().createInterface().create(USER, tenant); Item returnedItem = createItem(ITEM_ID, ITEM_NAME, ITEM_TYPE_A); doReturn(returnedItem).when(itemDao).create(any(Item.class)); |