aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-core-lib
diff options
context:
space:
mode:
authorsheetalm <sheetal.mudholkar@amdocs.com>2018-02-08 09:30:02 +0530
committerAvi Gaffa <avi.gaffa@amdocs.com>2018-02-08 12:38:37 +0000
commit2d2e0b503f915a81ae9a02dfa3afac3de369efde (patch)
treeb05555ebaca90f1d620f4562067bf486731ee48c /openecomp-be/lib/openecomp-core-lib
parent89f96b17aed5c432be3df6d75a49a1f9ebc9120b (diff)
Onboarding foundation changes
1. Adding OnboardingSessionContextFilter which sets tenant(kespace) for onboarding application 2. Different services can extend SessionContextFilter to set their own keyspace 3. These changes in onboarding are done to support services like ActivitySpec Change-Id: Ia62557354ab05235d027250af94a2835d741b7fa Issue-ID: SDC-1005 Signed-off-by: sheetalm <sheetal.mudholkar@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-core-lib')
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-api/src/main/java/org/openecomp/core/dao/types/UniqueValueEntity.java2
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/pom.xml5
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraSessionFactory.java4
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContextProvider.java2
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/impl/AsdcSessionContextProvider.java17
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenUtil.java22
6 files changed, 42 insertions, 10 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;
}