aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src
diff options
context:
space:
mode:
authortalig <talig@amdocs.com>2017-12-20 14:30:43 +0200
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>2017-12-21 11:12:33 +0000
commit8e9c0653dd6c6862123c9609ae34e1206d86456e (patch)
tree5eeef00ec0677133baa439ca8d7ffd7aca4804b6 /openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src
parent785ebcc95de3e064e843bec04ba7a209d854fc7c (diff)
Add collaboration feature
Issue-ID: SDC-767 Change-Id: I14fb4c1f54086ed03a56a7ff7fab9ecd40381795 Signed-off-by: talig <talig@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src')
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContext.java8
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContextProvider.java10
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContextProviderFactory.java32
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/User.java13
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/impl/AsdcSessionContextProvider.java50
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/impl/SessionContextProviderFactoryImpl.java33
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/resources/factoryConfiguration.json3
7 files changed, 149 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContext.java b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContext.java
new file mode 100644
index 0000000000..a1b410c90c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContext.java
@@ -0,0 +1,8 @@
+package org.openecomp.sdc.common.session;
+
+public interface SessionContext {
+
+ User getUser();
+
+ String getTenant();
+}
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
new file mode 100644
index 0000000000..8efbbd10eb
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContextProvider.java
@@ -0,0 +1,10 @@
+package org.openecomp.sdc.common.session;
+
+public interface SessionContextProvider {
+
+ void create(String user);
+
+ SessionContext get();
+
+ void close();
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContextProviderFactory.java b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContextProviderFactory.java
new file mode 100644
index 0000000000..cfa6a346c9
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/SessionContextProviderFactory.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.common.session;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class SessionContextProviderFactory
+ extends AbstractComponentFactory<SessionContextProvider> {
+
+ public static SessionContextProviderFactory getInstance() {
+ return AbstractFactory.getInstance(SessionContextProviderFactory.class);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/User.java b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/User.java
new file mode 100644
index 0000000000..5319a0bf56
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/User.java
@@ -0,0 +1,13 @@
+package org.openecomp.sdc.common.session;
+
+public class User {
+ private final String userId;
+
+ public User(String userId) {
+ this.userId = userId;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+}
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
new file mode 100644
index 0000000000..53a40a163f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/impl/AsdcSessionContextProvider.java
@@ -0,0 +1,50 @@
+package org.openecomp.sdc.common.session.impl;
+
+import org.openecomp.sdc.common.session.SessionContext;
+import org.openecomp.sdc.common.session.SessionContextProvider;
+import org.openecomp.sdc.common.session.User;
+
+public class AsdcSessionContextProvider implements SessionContextProvider {
+
+ private static final ThreadLocal<String> threadUserId = new ThreadLocal<>();
+
+ @Override
+ public void create(String userId) {
+ threadUserId.set(userId);
+ }
+
+ @Override
+ public SessionContext get() {
+ if (threadUserId.get() == null) {
+ throw new RuntimeException("UserId was not set for this thread");
+ }
+
+ return new AsdcSessionContext(new User(threadUserId.get()), "dox");
+ }
+
+ @Override
+ public void close() {
+ threadUserId.remove();
+ }
+
+ private static class AsdcSessionContext implements SessionContext {
+
+ private final User user;
+ private final String tenant;
+
+ private AsdcSessionContext(User user, String tenant) {
+ this.user = user;
+ this.tenant = tenant;
+ }
+
+ @Override
+ public User getUser() {
+ return user;
+ }
+
+ @Override
+ public String getTenant() {
+ return tenant;
+ }
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/impl/SessionContextProviderFactoryImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/impl/SessionContextProviderFactoryImpl.java
new file mode 100644
index 0000000000..635aa5b6ed
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/java/org/openecomp/sdc/common/session/impl/SessionContextProviderFactoryImpl.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.common.session.impl;
+
+import org.openecomp.sdc.common.session.SessionContextProvider;
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
+
+public class SessionContextProviderFactoryImpl extends SessionContextProviderFactory {
+ private static final SessionContextProvider INSTANCE = new AsdcSessionContextProvider();
+
+ @Override
+ public SessionContextProvider createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/resources/factoryConfiguration.json
new file mode 100644
index 0000000000..cd1637a80e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-session-lib/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,3 @@
+{
+ "org.openecomp.sdc.common.session.SessionContextProviderFactory": "org.openecomp.sdc.common.session.impl.SessionContextProviderFactoryImpl"
+} \ No newline at end of file