aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java12
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/OnboardingSessionContextFilter.java21
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java3
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml2
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml10
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/filters/SessionContextFilter.java (renamed from openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/SessionContextFilter.java)16
-rw-r--r--openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/test/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsManagerImplTest.java3
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImplTest.java3
-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
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java21
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/dao/impl/zusammen/ItemZusammenDaoImplTest.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/dao/impl/zusammen/VersionZusammenDaoImplTest.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-versioning-lib/openecomp-sdc-versioning-core/src/test/java/org/openecomp/sdc/versioning/impl/ItemManagerImplTest.java3
19 files changed, 120 insertions, 35 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java
index b50913aa6f..bb2d9ea565 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java
@@ -21,6 +21,7 @@
package org.openecomp.sdcrests.health.rest.services;
import org.apache.cxf.jaxrs.impl.ResponseBuilderImpl;
+import org.openecomp.sdc.common.session.SessionContext;
import org.openecomp.sdc.common.session.SessionContextProviderFactory;
import org.openecomp.sdc.health.HealthCheckManager;
import org.openecomp.sdc.health.HealthCheckManagerFactory;
@@ -32,10 +33,10 @@ import org.openecomp.sdc.logging.api.LoggerFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
-import javax.inject.Named;
-import javax.ws.rs.core.Response;
import java.util.Arrays;
import java.util.Collection;
+import javax.inject.Named;
+import javax.ws.rs.core.Response;
@Named
@Service("healthCheck")
@@ -56,7 +57,12 @@ public class HealthCheckImpl implements org.openecomp.sdcrests.health.rest.Healt
@Override
public Response checkHealth() {
HealthCheckResult healthCheckResult = new HealthCheckResult();
- SessionContextProviderFactory.getInstance().createInterface().create("public");
+
+ SessionContext context =
+ SessionContextProviderFactory.getInstance().createInterface().get();
+
+ SessionContextProviderFactory.getInstance().createInterface().create("public",
+ context.getTenant());
try {
Collection<HealthInfo> healthInfos = healthCheckManager.checkHealth();
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/OnboardingSessionContextFilter.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/OnboardingSessionContextFilter.java
new file mode 100644
index 0000000000..7166f627e4
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/OnboardingSessionContextFilter.java
@@ -0,0 +1,21 @@
+package org.openecomp.server.filters;
+
+import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpServletRequest;
+
+import org.openecomp.sdcrests.filters.SessionContextFilter;
+
+public class OnboardingSessionContextFilter extends SessionContextFilter {
+
+ @Override
+ public String getUser(ServletRequest servletRequest) {
+ return ((HttpServletRequest) servletRequest).getHeader(USER_ID_HEADER_PARAM);
+ }
+
+ @Override
+ public String getTenant(ServletRequest servletRequest) {
+ return "dox";
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java
index 2ea0ee2f66..b1c818cabb 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java
@@ -21,6 +21,7 @@
package org.openecomp.server.listeners;
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
import org.springframework.web.context.ContextLoaderListener;
import javax.servlet.ServletContextEvent;
@@ -32,6 +33,8 @@ public class OnboardingAppStartupListener implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
+ SessionContextProviderFactory.getInstance().createInterface().create("onboarding",
+ "dox");
springListener = new ContextLoaderListener();
springListener.initWebApplicationContext(servletContextEvent.getServletContext());
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml
index de88197a8a..64be5ab20c 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml
@@ -83,7 +83,7 @@
</filter-mapping>
<filter>
<filter-name>SessionContextFilter</filter-name>
- <filter-class>org.openecomp.server.filters.SessionContextFilter</filter-class>
+ <filter-class>org.openecomp.server.filters.OnboardingSessionContextFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>SessionContextFilter</filter-name>
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml
index da8147f287..a82298b4c1 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml
@@ -45,6 +45,16 @@
<version>${swagger.version}</version>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-session-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>${javax.servlet.version}</version>
+ </dependency>
</dependencies>
</project> \ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/SessionContextFilter.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/filters/SessionContextFilter.java
index b317fa6bf5..f81cc4b586 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/SessionContextFilter.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/filters/SessionContextFilter.java
@@ -1,8 +1,9 @@
-package org.openecomp.server.filters;
+package org.openecomp.sdcrests.filters;
import org.openecomp.sdc.common.session.SessionContextProvider;
import org.openecomp.sdc.common.session.SessionContextProviderFactory;
+import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
@@ -10,11 +11,8 @@ import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
-import java.io.IOException;
-
-import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
-public class SessionContextFilter implements Filter {
+public abstract class SessionContextFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
@@ -28,8 +26,8 @@ public class SessionContextFilter implements Filter {
try {
if (servletRequest instanceof HttpServletRequest) {
- String userName = ((HttpServletRequest) servletRequest).getHeader(USER_ID_HEADER_PARAM);
- contextProvider.create(userName);
+
+ contextProvider.create(getUser(servletRequest),getTenant(servletRequest));
}
filterChain.doFilter(servletRequest, servletResponse);
@@ -42,4 +40,8 @@ public class SessionContextFilter implements Filter {
public void destroy() {
}
+
+ public abstract String getUser(ServletRequest servletRequest);
+
+ public abstract String getTenant(ServletRequest servletRequest);
}
diff --git a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/test/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/test/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsManagerImplTest.java
index 98154b3eaa..439b8b6105 100644
--- a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/test/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/test/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsManagerImplTest.java
@@ -35,6 +35,7 @@ public class ItemPermissionsManagerImplTest {
private static final String AFFECTED_USER1 = "affected_user1";
private static final String AFFECTED_USER2 = "affected_user2";
private static final String AFFECTED_USER3 = "affected_user3";
+ private static final String tenant = "dox";
@Mock
private PermissionsServices permissionsServicesMock;
@@ -53,7 +54,7 @@ public class ItemPermissionsManagerImplTest {
@BeforeMethod
public void setUp() throws Exception {
- SessionContextProviderFactory.getInstance().createInterface().create(USER);
+ SessionContextProviderFactory.getInstance().createInterface().create(USER, tenant);
MockitoAnnotations.initMocks(this);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImplTest.java
index 9e2cee6ace..b0d0b64ad8 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImplTest.java
@@ -62,6 +62,7 @@ public class NetworkManagerImplTest {
private static final Version VERSION = new Version("version_id");
private static final String NETWORK1_ID = "network1";
private static final String NETWORK2_ID = "network2";
+ private static final String tenant = "dox";
@Mock
private NetworkDao networkDaoMock;
@@ -86,7 +87,7 @@ public class NetworkManagerImplTest {
@BeforeMethod
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- SessionContextProviderFactory.getInstance().createInterface().create(USER_ID);
+ SessionContextProviderFactory.getInstance().createInterface().create(USER_ID, tenant);
}
@AfterMethod
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));