aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-03-22 15:33:06 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-03-24 06:59:47 +0000
commitd378c37fbd1ecec7b43394926f1ca32a695e07de (patch)
tree5c8a085f8732f980d871d966ac49361644efa698 /openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao
parenta6ae7294ecd336d7e88f915710b08e2658eaee00 (diff)
Reformat openecomp-be
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3449 Change-Id: I13e02322f8e00820cc5a1d85752caaeda9bf10d1
Diffstat (limited to 'openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao')
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsDaoFactoryImpl.java1
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsDaoImpl.java23
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsServicesImpl.java40
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PrmissionsServicesFactoryImpl.java15
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/UserPermissionsDaoFactoryImpl.java1
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/UserPermissionsDaoImpl.java19
6 files changed, 26 insertions, 73 deletions
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsDaoFactoryImpl.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsDaoFactoryImpl.java
index 6fd83c2233..89db18b30b 100644
--- a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsDaoFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsDaoFactoryImpl.java
@@ -22,7 +22,6 @@ package org.openecomp.sdc.itempermissions.dao.impl;
import org.openecomp.sdc.itempermissions.dao.ItemPermissionsDao;
import org.openecomp.sdc.itempermissions.dao.ItemPermissionsDaoFactory;
-
/**
* Created by ayalaben on 6/18/2017.
*/
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsDaoImpl.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsDaoImpl.java
index c9c4198081..34c4f39395 100644
--- a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsDaoImpl.java
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsDaoImpl.java
@@ -13,18 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.itempermissions.dao.impl;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.mapping.Result;
import com.datastax.driver.mapping.annotations.Accessor;
import com.datastax.driver.mapping.annotations.Query;
-
import java.util.Collection;
import java.util.Optional;
import java.util.Set;
-
import org.openecomp.core.nosqldb.api.NoSqlDb;
import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
import org.openecomp.sdc.itempermissions.dao.ItemPermissionsDao;
@@ -36,8 +33,7 @@ import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
public class ItemPermissionsDaoImpl implements ItemPermissionsDao {
private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static ItemPermissionsAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(ItemPermissionsAccessor.class);
+ private static ItemPermissionsAccessor accessor = noSqlDb.getMappingManager().createAccessor(ItemPermissionsAccessor.class);
@Override
public Collection<ItemPermissionsEntity> listItemPermissions(String itemId) {
@@ -45,22 +41,17 @@ public class ItemPermissionsDaoImpl implements ItemPermissionsDao {
}
@Override
- public void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds,
- Set<String> removedUsersIds) {
+ public void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds, Set<String> removedUsersIds) {
addedUsersIds.forEach(userId -> accessor.addPermission(itemId, userId, permission));
- removedUsersIds.stream()
- .filter(userId -> getUserItemPermission(itemId, userId)
- .map(userPermissionOnItem -> userPermissionOnItem.equals(permission))
- .orElse(false))
- .forEach(userId -> accessor.deletePermission(itemId, userId));
+ removedUsersIds.stream().filter(
+ userId -> getUserItemPermission(itemId, userId).map(userPermissionOnItem -> userPermissionOnItem.equals(permission)).orElse(false))
+ .forEach(userId -> accessor.deletePermission(itemId, userId));
}
@Override
public Optional<String> getUserItemPermission(String itemId, String userId) {
ResultSet result = accessor.getUserItemPermission(itemId, userId);
- return result.getAvailableWithoutFetching() < 1
- ? Optional.empty()
- : Optional.of(result.one().getString(0));
+ return result.getAvailableWithoutFetching() < 1 ? Optional.empty() : Optional.of(result.one().getString(0));
}
@Override
@@ -68,7 +59,6 @@ public class ItemPermissionsDaoImpl implements ItemPermissionsDao {
accessor.deleteItemPermissions(itemId);
}
-
@Accessor
interface ItemPermissionsAccessor {
@@ -86,6 +76,5 @@ public class ItemPermissionsDaoImpl implements ItemPermissionsDao {
@Query("delete from dox.item_permissions where item_id=?")
void deleteItemPermissions(String itemId);
-
}
}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsServicesImpl.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsServicesImpl.java
index d0e41d8c91..7e9d289731 100644
--- a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsServicesImpl.java
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsServicesImpl.java
@@ -13,13 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.itempermissions.dao.impl;
import java.util.Collection;
import java.util.Optional;
import java.util.Set;
-
import org.openecomp.sdc.common.session.SessionContextProviderFactory;
import org.openecomp.sdc.itempermissions.PermissionsRules;
import org.openecomp.sdc.itempermissions.PermissionsServices;
@@ -27,29 +25,22 @@ import org.openecomp.sdc.itempermissions.dao.ItemPermissionsDao;
import org.openecomp.sdc.itempermissions.dao.UserPermissionsDao;
import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
-
/**
* Created by ayalaben on 6/22/2017.
*/
public class PermissionsServicesImpl implements PermissionsServices {
+ private static final String CHANGE_PERMISSIONS = "Change_Item_Permissions";
private ItemPermissionsDao itemPermissionsDao;
-
private UserPermissionsDao userPermissionsDao;
-
private PermissionsRules permissionsRules;
- private static final String CHANGE_PERMISSIONS = "Change_Item_Permissions";
-
- public PermissionsServicesImpl(PermissionsRules permissionsRules,
- ItemPermissionsDao itemPermissionsDao,
- UserPermissionsDao userPermissionsDao) {
+ public PermissionsServicesImpl(PermissionsRules permissionsRules, ItemPermissionsDao itemPermissionsDao, UserPermissionsDao userPermissionsDao) {
this.itemPermissionsDao = itemPermissionsDao;
this.permissionsRules = permissionsRules;
this.userPermissionsDao = userPermissionsDao;
}
-
@Override
public Collection<ItemPermissionsEntity> listItemPermissions(String itemId) {
return itemPermissionsDao.listItemPermissions(itemId);
@@ -61,30 +52,18 @@ public class PermissionsServicesImpl implements PermissionsServices {
}
@Override
- public void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds,
- Set<String> removedUsersIds) {
-
- String currentUserId = SessionContextProviderFactory.getInstance()
- .createInterface().get().getUser().getUserId();
-
+ public void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds, Set<String> removedUsersIds) {
+ String currentUserId = SessionContextProviderFactory.getInstance().createInterface().get().getUser().getUserId();
permissionsRules.executeAction(itemId, currentUserId, CHANGE_PERMISSIONS);
-
- permissionsRules.updatePermission(itemId, currentUserId, permission, addedUsersIds,
- removedUsersIds);
-
- itemPermissionsDao.updateItemPermissions(itemId, permission,
- addedUsersIds, removedUsersIds);
-
- userPermissionsDao.updatePermissions(itemId, permission,
- addedUsersIds, removedUsersIds);
-
+ permissionsRules.updatePermission(itemId, currentUserId, permission, addedUsersIds, removedUsersIds);
+ itemPermissionsDao.updateItemPermissions(itemId, permission, addedUsersIds, removedUsersIds);
+ userPermissionsDao.updatePermissions(itemId, permission, addedUsersIds, removedUsersIds);
}
@Override
public boolean isAllowed(String itemId, String userId, String action) {
- return itemPermissionsDao.getUserItemPermission(itemId, userId)
- .map(permission -> permissionsRules.isAllowed(permission, action))
- .orElse(false);
+ return itemPermissionsDao.getUserItemPermission(itemId, userId).map(permission -> permissionsRules.isAllowed(permission, action))
+ .orElse(false);
}
@Override
@@ -101,5 +80,4 @@ public class PermissionsServicesImpl implements PermissionsServices {
public void deleteItemPermissions(String itemId) {
itemPermissionsDao.deleteItemPermissions(itemId);
}
-
}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PrmissionsServicesFactoryImpl.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PrmissionsServicesFactoryImpl.java
index d009f62270..b86d10ceb1 100644
--- a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PrmissionsServicesFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PrmissionsServicesFactoryImpl.java
@@ -24,14 +24,13 @@ import org.openecomp.sdc.itempermissions.dao.UserPermissionsDaoFactory;
/**
* Created by ayalaben on 6/22/2017
*/
-public class PrmissionsServicesFactoryImpl extends PermissionsServicesFactory {
+public class PrmissionsServicesFactoryImpl extends PermissionsServicesFactory {
- private static final PermissionsServices INSTANCE =
- new PermissionsServicesImpl(PermissionsRulesFactory.getInstance().createInterface(),
- ItemPermissionsDaoFactory.getInstance().createInterface(), UserPermissionsDaoFactory.getInstance().createInterface());
+ private static final PermissionsServices INSTANCE = new PermissionsServicesImpl(PermissionsRulesFactory.getInstance().createInterface(),
+ ItemPermissionsDaoFactory.getInstance().createInterface(), UserPermissionsDaoFactory.getInstance().createInterface());
- @Override
- public PermissionsServices createInterface() {
- return INSTANCE;
- }
+ @Override
+ public PermissionsServices createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/UserPermissionsDaoFactoryImpl.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/UserPermissionsDaoFactoryImpl.java
index 4c23743ea5..d60013db77 100644
--- a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/UserPermissionsDaoFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/UserPermissionsDaoFactoryImpl.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.itempermissions.dao.impl;
import org.openecomp.sdc.itempermissions.dao.UserPermissionsDao;
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/UserPermissionsDaoImpl.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/UserPermissionsDaoImpl.java
index 8609f2f4a8..25645ab483 100644
--- a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/UserPermissionsDaoImpl.java
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/UserPermissionsDaoImpl.java
@@ -13,17 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.itempermissions.dao.impl;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.mapping.annotations.Accessor;
import com.datastax.driver.mapping.annotations.Query;
-
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
-
import org.openecomp.core.nosqldb.api.NoSqlDb;
import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
import org.openecomp.sdc.itempermissions.dao.UserPermissionsDao;
@@ -31,9 +28,7 @@ import org.openecomp.sdc.itempermissions.dao.UserPermissionsDao;
public class UserPermissionsDaoImpl implements UserPermissionsDao {
private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static UserPermissionsAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(UserPermissionsAccessor.class);
-
+ private static UserPermissionsAccessor accessor = noSqlDb.getMappingManager().createAccessor(UserPermissionsAccessor.class);
@Override
public Set<String> listUserPermittedItems(String userId, String permission) {
@@ -46,14 +41,10 @@ public class UserPermissionsDaoImpl implements UserPermissionsDao {
}
@Override
- public void updatePermissions(String itemId, String permission, Set<String> addedUsersIds,
- Set<String> removedUsersIds) {
+ public void updatePermissions(String itemId, String permission, Set<String> addedUsersIds, Set<String> removedUsersIds) {
Set<String> itemSet = Collections.singleton(itemId);
-
- addedUsersIds.forEach(userId ->
- accessor.addItem(itemSet, userId, permission));
- removedUsersIds.forEach(userId ->
- accessor.removeItem(itemSet, userId, permission));
+ addedUsersIds.forEach(userId -> accessor.addItem(itemSet, userId, permission));
+ removedUsersIds.forEach(userId -> accessor.removeItem(itemSet, userId, permission));
}
@Accessor
@@ -67,7 +58,5 @@ public class UserPermissionsDaoImpl implements UserPermissionsDao {
@Query("update dox.user_permission_items set item_list=item_list-? WHERE user_id = ? AND permission = ?")
void removeItem(Set<String> items, String userId, String permission);
-
}
-
}