aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/tools/zusammen-tools/src
diff options
context:
space:
mode:
authorayalaben <ayala.benzvi@amdocs.com>2018-04-10 13:43:01 +0300
committerOren Kleks <orenkle@amdocs.com>2018-04-12 07:15:06 +0000
commit8dfa832a4bbe276fdf898330325321a776ac253e (patch)
tree2ed00333197348dfb0b933f2c6935ca1c9db9122 /openecomp-be/tools/zusammen-tools/src
parentfe35212bee3b89dcee98a11dd364218c587aa41a (diff)
User Permission items
Change-Id: Ice1d126dd29e9f49ca90ada7b1671c72545c9ee8 Issue-ID: SDC-1202 Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
Diffstat (limited to 'openecomp-be/tools/zusammen-tools/src')
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/commands/PopulateUserPermissions.java43
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/main/ZusammenMainTool.java5
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/PermissionHandler.java18
3 files changed, 66 insertions, 0 deletions
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/commands/PopulateUserPermissions.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/commands/PopulateUserPermissions.java
new file mode 100644
index 0000000000..bf85bd19b5
--- /dev/null
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/commands/PopulateUserPermissions.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.core.tools.commands;
+
+import org.openecomp.core.tools.store.PermissionHandler;
+import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
+
+import java.util.*;
+
+
+public class PopulateUserPermissions {
+
+ private static PermissionHandler permissionHandler = new PermissionHandler();
+
+ private PopulateUserPermissions(){ }
+
+ public static void execute(){
+
+ List<ItemPermissionsEntity> permissions = permissionHandler.getAll();
+
+ permissions.forEach(itemPermissionsEntity ->
+ permissionHandler.addItem
+ (Collections.singleton(itemPermissionsEntity.getItemId()),
+ itemPermissionsEntity.getUserId(),itemPermissionsEntity.getPermission()));
+
+ System.exit(0);
+
+ }
+}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/main/ZusammenMainTool.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/main/ZusammenMainTool.java
index 42a63e8938..1080a23dfa 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/main/ZusammenMainTool.java
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/main/ZusammenMainTool.java
@@ -2,6 +2,7 @@ package org.openecomp.core.tools.main;
import org.openecomp.core.tools.commands.AddContributorCommand;
import org.openecomp.core.tools.commands.HealAll;
+import org.openecomp.core.tools.commands.PopulateUserPermissions;
import org.openecomp.core.tools.commands.SetHealingFlag;
import org.openecomp.core.tools.exportinfo.ExportDataCommand;
import org.openecomp.core.tools.importinfo.ImportDataCommand;
@@ -59,6 +60,9 @@ public class ZusammenMainTool {
case HEAL_ALL:
HealAll.healAll(ToolsUtil.getParam("t", args));
break;
+ case POPULATE_USER_PERMISSIONS:
+ PopulateUserPermissions.execute();
+ break;
case ADD_CONTRIBUTOR:
AddContributorCommand.add(ToolsUtil.getParam("p", args), ToolsUtil.getParam("u", args));
@@ -93,6 +97,7 @@ public class ZusammenMainTool {
EXPORT,
IMPORT,
HEAL_ALL,
+ POPULATE_USER_PERMISSIONS,
ADD_CONTRIBUTOR
}
}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/PermissionHandler.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/PermissionHandler.java
index 9b7b0f62e6..ecde9e900a 100644
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/PermissionHandler.java
+++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/PermissionHandler.java
@@ -2,13 +2,17 @@ package org.openecomp.core.tools.store;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
+import com.datastax.driver.mapping.Result;
import com.datastax.driver.mapping.annotations.Accessor;
import com.datastax.driver.mapping.annotations.Query;
import org.openecomp.core.nosqldb.api.NoSqlDb;
import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
+import java.util.List;
import java.util.Objects;
import java.util.Optional;
+import java.util.Set;
public class PermissionHandler {
@@ -32,6 +36,14 @@ public class PermissionHandler {
accessor.setItemUserPermission(itemId, user, permission);
}
+ public void addItem(Set<String> items, String userId, String permission){
+ accessor.addItem(items,userId,permission);
+ }
+
+ public List<ItemPermissionsEntity> getAll(){
+ return accessor.getAll().all();
+ }
+
@Accessor
interface PermissionAccessor {
@@ -43,6 +55,12 @@ public class PermissionHandler {
@Query("SELECT permission FROM dox.item_permissions WHERE item_id=? AND user_id=?")
ResultSet getItemUserPermission(String itemId, String userId);
+
+ @Query("SELECT * from dox.item_permissions")
+ Result<ItemPermissionsEntity> getAll();
+
+ @Query("update dox.user_permission_items set item_list=item_list+? WHERE user_id = ? AND permission = ?")
+ void addItem(Set<String> items, String userId, String permission);
}
} \ No newline at end of file