summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/services/ItemPermissionsImpl.java28
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java8
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java5
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java22
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java10
-rw-r--r--openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/ItemPermissionsManager.java25
-rw-r--r--openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/ItemPermissionsManagerFactory.java15
-rw-r--r--openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/PermissionsManager.java42
-rw-r--r--openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/PermissionsManagerFactory.java30
-rw-r--r--openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerFactoryImpl.java (renamed from openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsManagerFactoryImpl.java)12
-rw-r--r--openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerImpl.java (renamed from openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsManagerImpl.java)21
-rw-r--r--openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/resources/factoryConfiguration.json2
-rw-r--r--openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/test/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerImplTest.java (renamed from openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/test/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsManagerImplTest.java)13
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsServices.java17
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/ItemPermissionsDao.java17
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/UserPermissionsDao.java29
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/UserPermissionsDaoFactory.java27
-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.java43
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PrmissionsServicesFactoryImpl.java20
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/UserPermissionsDaoFactoryImpl.java30
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/UserPermissionsDaoImpl.java72
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/resources/factoryConfiguration.json1
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/PermissionsRulesImpl.java36
-rw-r--r--openecomp-be/tools/build/scripts/cassandra-commands.json2
-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
28 files changed, 503 insertions, 113 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/services/ItemPermissionsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/services/ItemPermissionsImpl.java
index 4fe93c20ac..213af650f7 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/services/ItemPermissionsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/services/ItemPermissionsImpl.java
@@ -1,9 +1,23 @@
-//package org.openecomp.sdcrests.itempermissions.rest.mapping.mapping.services;
+/*
+ * 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.sdcrests.itempermissions.rest.services;
-import org.openecomp.sdc.itempermissions.ItemPermissionsManager;
-import org.openecomp.sdc.itempermissions.ItemPermissionsManagerFactory;
+import org.openecomp.sdc.itempermissions.PermissionsManager;
+import org.openecomp.sdc.itempermissions.PermissionsManagerFactory;
import org.openecomp.sdcrests.itempermissions.rest.ItemPermissions;
import org.openecomp.sdcrests.itempermissions.rest.mapping.MapItemPermissionsToItemPermissionsDto;
import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsDto;
@@ -24,8 +38,8 @@ import javax.ws.rs.core.Response;
@Scope(value = "prototype")
public class ItemPermissionsImpl implements ItemPermissions {
- private ItemPermissionsManager itemPermissionsManager =
- ItemPermissionsManagerFactory.getInstance().createInterface();
+ private PermissionsManager permissionsManager =
+ PermissionsManagerFactory.getInstance().createInterface();
@Override
public Response list(String itemId, String user) {
@@ -33,7 +47,7 @@ public class ItemPermissionsImpl implements ItemPermissions {
GenericCollectionWrapper<ItemPermissionsDto> results = new GenericCollectionWrapper<>();
MapItemPermissionsToItemPermissionsDto mapper = new MapItemPermissionsToItemPermissionsDto();
- itemPermissionsManager.listItemPermissions(itemId)
+ permissionsManager.listItemPermissions(itemId)
.forEach(itemPermission -> results.add(mapper.applyMapping
(itemPermission, ItemPermissionsDto.class)));
@@ -44,7 +58,7 @@ public class ItemPermissionsImpl implements ItemPermissions {
public Response updatePermissions(ItemPermissionsRequestDto request, String itemId,
String permission, String user) {
- itemPermissionsManager.updateItemPermissions(itemId,permission,request.getAddedUsersIds(),
+ permissionsManager.updateItemPermissions(itemId,permission,request.getAddedUsersIds(),
request.getRemovedUsersIds());
return Response.ok().build();
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java
index f627dc590f..e2d987233e 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java
@@ -36,8 +36,8 @@ import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.conflicts.ConflictsManager;
import org.openecomp.sdc.conflicts.ConflictsManagerFactory;
-import org.openecomp.sdc.itempermissions.ItemPermissionsManager;
-import org.openecomp.sdc.itempermissions.ItemPermissionsManagerFactory;
+import org.openecomp.sdc.itempermissions.PermissionsManager;
+import org.openecomp.sdc.itempermissions.PermissionsManagerFactory;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.notification.dtos.Event;
@@ -76,8 +76,8 @@ public class VersionsImpl implements Versions {
private static final String COMMIT_ITEM_ACTION = "Commit_Item";
private static final Logger LOGGER = LoggerFactory.getLogger(VersionsImpl.class);
- private ItemPermissionsManager permissionsManager =
- ItemPermissionsManagerFactory.getInstance().createInterface();
+ private PermissionsManager permissionsManager =
+ PermissionsManagerFactory.getInstance().createInterface();
private AsdcItemManager asdcItemManager =
AsdcItemManagerFactory.getInstance().createInterface();
private VersioningManager versioningManager =
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java
index ea69249944..ebaba838eb 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java
@@ -38,12 +38,11 @@ public class GenericCollectionWrapper<T> implements Serializable {
* Instantiates a new Generic collection wrapper.
*
* @param list the list
- * @param listCount the list count
*/
- public GenericCollectionWrapper(List<T> list, int listCount) {
+ public GenericCollectionWrapper(List<T> list) {
if (!list.isEmpty()) {
this.results = list;
- this.listCount = listCount;
+ this.listCount = list.size();
}
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java
index 2f64a5018f..2761c85502 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java
@@ -28,8 +28,8 @@ import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.datatypes.model.ItemType;
import org.openecomp.sdc.healing.factory.HealingManagerFactory;
-import org.openecomp.sdc.itempermissions.ItemPermissionsManager;
-import org.openecomp.sdc.itempermissions.ItemPermissionsManagerFactory;
+import org.openecomp.sdc.itempermissions.PermissionsManager;
+import org.openecomp.sdc.itempermissions.PermissionsManagerFactory;
import org.openecomp.sdc.itempermissions.impl.types.PermissionTypes;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
@@ -67,11 +67,9 @@ import org.springframework.validation.annotation.Validated;
import javax.inject.Named;
import javax.ws.rs.core.Response;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
+import java.util.*;
import java.util.function.Predicate;
+import java.util.stream.Collectors;
import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER;
import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_ID;
@@ -91,7 +89,7 @@ public class VendorLicenseModelsImpl implements VendorLicenseModels {
private static final String SUBMIT_HEALED_VERSION_ERROR =
"VLM Id %s: Error while submitting version %s created based on Certified version %s for healing purpose.";
private static final Logger LOGGER = LoggerFactory.getLogger(VendorLicenseModelsImpl.class);
- private ItemPermissionsManager permissionsManager = ItemPermissionsManagerFactory.getInstance()
+ private PermissionsManager permissionsManager = PermissionsManagerFactory.getInstance()
.createInterface();
private NotificationPropagationManager notifier =
NotificationPropagationManagerFactory.getInstance().createInterface();
@@ -110,11 +108,11 @@ public class VendorLicenseModelsImpl implements VendorLicenseModels {
public Response listLicenseModels(String versionStatus,String itemStatus, String user) {
Predicate<Item> itemPredicate = createItemPredicate(versionStatus, itemStatus, user);
- GenericCollectionWrapper<ItemDto> results = new GenericCollectionWrapper<>();
MapItemToDto mapper = new MapItemToDto();
- asdcItemManager.list(itemPredicate).stream()
- .sorted((o1, o2) -> o2.getModificationTime().compareTo(o1.getModificationTime()))
- .forEach(vspItem -> results.add(mapper.applyMapping(vspItem, ItemDto.class)));
+ GenericCollectionWrapper<ItemDto> results = new GenericCollectionWrapper<>(asdcItemManager.list(itemPredicate)
+ .stream().sorted((o1, o2) -> o2.getModificationTime().compareTo(o1.getModificationTime()))
+ .map(item ->mapper.applyMapping(item, ItemDto.class)).collect(Collectors.toList()));
+
return Response.ok(results).build();
}
@@ -320,7 +318,7 @@ public class VendorLicenseModelsImpl implements VendorLicenseModels {
}
private boolean userHasPermission(String itemId, String userId) {
- String permission = permissionsManager.getUserItemPermiission(itemId, userId);
+ String permission = permissionsManager.getUserItemPermission(itemId, userId);
return (permission != null && permission
.matches(PermissionTypes.Contributor.name() + "|" + PermissionTypes.Owner.name()));
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java
index 8fdfd2fbd5..80532b5c29 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java
@@ -52,8 +52,8 @@ import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.datatypes.model.ItemType;
import org.openecomp.sdc.healing.factory.HealingManagerFactory;
-import org.openecomp.sdc.itempermissions.ItemPermissionsManager;
-import org.openecomp.sdc.itempermissions.ItemPermissionsManagerFactory;
+import org.openecomp.sdc.itempermissions.PermissionsManager;
+import org.openecomp.sdc.itempermissions.PermissionsManagerFactory;
import org.openecomp.sdc.itempermissions.impl.types.PermissionTypes;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
@@ -124,8 +124,8 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
private final AsdcItemManager itemManager = AsdcItemManagerFactory.getInstance()
.createInterface();
- private final ItemPermissionsManager permissionsManager =
- ItemPermissionsManagerFactory.getInstance().createInterface();
+ private final PermissionsManager permissionsManager =
+ PermissionsManagerFactory.getInstance().createInterface();
private final VersioningManager versioningManager =
VersioningManagerFactory.getInstance().createInterface();
private final VendorSoftwareProductManager vendorSoftwareProductManager =
@@ -606,7 +606,7 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
}
private boolean userHasPermission(String itemId, String userId) {
- String permission = permissionsManager.getUserItemPermiission(itemId, userId);
+ String permission = permissionsManager.getUserItemPermission(itemId, userId);
return permission != null && permission
.matches(PermissionTypes.Contributor.name() + "|" + PermissionTypes.Owner.name());
}
diff --git a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/ItemPermissionsManager.java b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/ItemPermissionsManager.java
deleted file mode 100644
index 1ca37325ca..0000000000
--- a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/ItemPermissionsManager.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.openecomp.sdc.itempermissions;
-
-import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
-
-import java.util.Collection;
-import java.util.Set;
-
-/**
- * Created by ayalaben on 6/18/2017.
- */
-public interface ItemPermissionsManager {
-
- Collection<ItemPermissionsEntity> listItemPermissions(String itemId);
-
- void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds,
- Set<String> removedUsersIds);
-
- boolean isAllowed(String itemId,String userId,String action);
-
- String getUserItemPermiission(String itemId, String userId);
-
- void deleteItemPermissions(String itemId);
-
-
-}
diff --git a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/ItemPermissionsManagerFactory.java b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/ItemPermissionsManagerFactory.java
deleted file mode 100644
index b983314b31..0000000000
--- a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/ItemPermissionsManagerFactory.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.openecomp.sdc.itempermissions;
-
-import org.openecomp.core.factory.api.AbstractComponentFactory;
-import org.openecomp.core.factory.api.AbstractFactory;
-
-/**
- * Created by ayalaben on 6/18/2017.
- */
-public abstract class ItemPermissionsManagerFactory extends
- AbstractComponentFactory<ItemPermissionsManager> {
-
- public static ItemPermissionsManagerFactory getInstance() {
- return AbstractFactory.getInstance(ItemPermissionsManagerFactory.class);
- }
-}
diff --git a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/PermissionsManager.java b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/PermissionsManager.java
new file mode 100644
index 0000000000..09f6048f82
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/PermissionsManager.java
@@ -0,0 +1,42 @@
+/*
+ * 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.sdc.itempermissions;
+
+import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
+
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ * Created by ayalaben on 6/18/2017.
+ */
+public interface PermissionsManager {
+
+ Collection<ItemPermissionsEntity> listItemPermissions(String itemId);
+
+ Set<String> listUserPermittedItems(String userId, String permission);
+
+ void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds,
+ Set<String> removedUsersIds);
+
+ boolean isAllowed(String itemId,String userId,String action);
+
+ String getUserItemPermission(String itemId, String userId);
+
+ void deleteItemPermissions(String itemId);
+
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/PermissionsManagerFactory.java b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/PermissionsManagerFactory.java
new file mode 100644
index 0000000000..0353e5ce03
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/PermissionsManagerFactory.java
@@ -0,0 +1,30 @@
+/*
+ * 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.sdc.itempermissions;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+/**
+ * Created by ayalaben on 6/18/2017.
+ */
+public abstract class PermissionsManagerFactory extends
+ AbstractComponentFactory<PermissionsManager> {
+
+ public static PermissionsManagerFactory getInstance() {
+ return AbstractFactory.getInstance(PermissionsManagerFactory.class);
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerFactoryImpl.java
index 6e41465a11..14539b0fa1 100644
--- a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerFactoryImpl.java
@@ -16,8 +16,8 @@
package org.openecomp.sdc.itempermissions.dao.impl;
-import org.openecomp.sdc.itempermissions.ItemPermissionsManager;
-import org.openecomp.sdc.itempermissions.ItemPermissionsManagerFactory;
+import org.openecomp.sdc.itempermissions.PermissionsManager;
+import org.openecomp.sdc.itempermissions.PermissionsManagerFactory;
import org.openecomp.sdc.itempermissions.PermissionsServicesFactory;
import org.openecomp.sdc.notification.factories.NotificationPropagationManagerFactory;
import org.openecomp.sdc.notification.factories.SubscriptionServiceFactory;
@@ -26,16 +26,16 @@ import org.openecomp.sdc.versioning.AsdcItemManagerFactory;
/**
* Created by ayalaben on 6/18/2017
*/
-public class ItemPermissionsManagerFactoryImpl extends ItemPermissionsManagerFactory {
+public class PermissionsManagerFactoryImpl extends PermissionsManagerFactory {
- private static final ItemPermissionsManager INSTANCE =
- new ItemPermissionsManagerImpl(PermissionsServicesFactory.getInstance().createInterface(),
+ private static final PermissionsManager INSTANCE =
+ new PermissionsManagerImpl(PermissionsServicesFactory.getInstance().createInterface(),
AsdcItemManagerFactory.getInstance().createInterface(),
NotificationPropagationManagerFactory.getInstance().createInterface(),
SubscriptionServiceFactory.getInstance().createInterface());
@Override
- public ItemPermissionsManager createInterface() {
+ public PermissionsManager createInterface() {
return INSTANCE;
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsManagerImpl.java b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerImpl.java
index a68c2d89f9..741053017c 100644
--- a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/ItemPermissionsManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/PermissionsManagerImpl.java
@@ -32,7 +32,7 @@ import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.common.session.SessionContextProviderFactory;
-import org.openecomp.sdc.itempermissions.ItemPermissionsManager;
+import org.openecomp.sdc.itempermissions.PermissionsManager;
import org.openecomp.sdc.itempermissions.PermissionsServices;
import org.openecomp.sdc.itempermissions.impl.types.PermissionTypes;
import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
@@ -47,9 +47,9 @@ import org.openecomp.sdc.versioning.types.Item;
/**
* Created by ayalaben on 6/18/2017.
*/
-public class ItemPermissionsManagerImpl implements ItemPermissionsManager {
+public class PermissionsManagerImpl implements PermissionsManager {
- private static final Logger LOGGER = LoggerFactory.getLogger(ItemPermissionsManagerImpl.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(PermissionsManagerImpl.class);
private static final String CHANGE_PERMISSIONS = "Change_Item_Permissions";
private PermissionsServices permissionsServices;
@@ -57,10 +57,10 @@ public class ItemPermissionsManagerImpl implements ItemPermissionsManager {
private NotificationPropagationManager notifier;
private SubscriptionService subscriptionService;
- public ItemPermissionsManagerImpl(PermissionsServices permissionsServices,
- AsdcItemManager asdcItemManager,
- NotificationPropagationManager notificationPropagationManager,
- SubscriptionService subscriptionService) {
+ public PermissionsManagerImpl(PermissionsServices permissionsServices,
+ AsdcItemManager asdcItemManager,
+ NotificationPropagationManager notificationPropagationManager,
+ SubscriptionService subscriptionService) {
this.permissionsServices = permissionsServices;
this.asdcItemManager = asdcItemManager;
this.notifier = notificationPropagationManager;
@@ -74,6 +74,11 @@ public class ItemPermissionsManagerImpl implements ItemPermissionsManager {
}
@Override
+ public Set<String> listUserPermittedItems(String userId, String permission) {
+ return permissionsServices.listUserPermittedItems(userId,permission);
+ }
+
+ @Override
public void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds,
Set<String> removedUsersIds) {
@@ -145,7 +150,7 @@ public class ItemPermissionsManagerImpl implements ItemPermissionsManager {
}
@Override
- public String getUserItemPermiission(String itemId, String userId) {
+ public String getUserItemPermission(String itemId, String userId) {
return permissionsServices.getUserItemPermiission(itemId, userId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/resources/factoryConfiguration.json b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/resources/factoryConfiguration.json
index a98f9c07f9..1ac763d3de 100644
--- a/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/resources/factoryConfiguration.json
+++ b/openecomp-be/backend/openecomp-sdc-item-permissions-manager/src/main/resources/factoryConfiguration.json
@@ -1,3 +1,3 @@
{
- "org.openecomp.sdc.itempermissions.ItemPermissionsManagerFactory": "org.openecomp.sdc.itempermissions.dao.impl.ItemPermissionsManagerFactoryImpl"
+ "org.openecomp.sdc.itempermissions.PermissionsManagerFactory": "org.openecomp.sdc.itempermissions.dao.impl.PermissionsManagerFactoryImpl"
} \ No newline at end of file
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/PermissionsManagerImplTest.java
index e215db2335..83902c5f53 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/PermissionsManagerImplTest.java
@@ -51,7 +51,7 @@ import org.testng.annotations.Test;
/**
* Created by ayalaben on 7/6/2017
*/
-public class ItemPermissionsManagerImplTest {
+public class PermissionsManagerImplTest {
private static final String ITEM1_ID = "1";
private static final String PERMISSION = "Contributor";
@@ -74,7 +74,7 @@ public class ItemPermissionsManagerImplTest {
private ArgumentCaptor<Event> eventArgumentCaptor;
@InjectMocks
- private ItemPermissionsManagerImpl permissionsManager;
+ private PermissionsManagerImpl permissionsManager;
@BeforeMethod
@@ -118,6 +118,15 @@ public class ItemPermissionsManagerImplTest {
}
}
+ @Test
+ public void testListUserPermittedItems(){
+ permissionsManager.listUserPermittedItems(AFFECTED_USER1,PERMISSION);
+
+ verify(permissionsServicesMock)
+ .listUserPermittedItems(AFFECTED_USER1, PERMISSION);
+
+ }
+
private void verifyCallsToNotificationsFramework(String affectedUser, boolean permissionGranted) {
verifyCallToSubscriptionService(affectedUser, permissionGranted);
verifyDirectNotificationCallParameters(affectedUser, permissionGranted);
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsServices.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsServices.java
index 8c0008454e..49d72bbcbf 100644
--- a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsServices.java
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsServices.java
@@ -1,3 +1,18 @@
+/*
+ * 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.sdc.itempermissions;
import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
@@ -12,6 +27,8 @@ public interface PermissionsServices {
Collection<ItemPermissionsEntity> listItemPermissions(String itemId);
+ Set<String> listUserPermittedItems(String userId, String permission);
+
void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds,
Set<String> removedUsersIds);
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/ItemPermissionsDao.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/ItemPermissionsDao.java
index ee5e1f3e3a..b8b7ddd7a0 100644
--- a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/ItemPermissionsDao.java
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/ItemPermissionsDao.java
@@ -1,3 +1,18 @@
+/*
+ * 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.sdc.itempermissions.dao;
import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
@@ -15,8 +30,6 @@ public interface ItemPermissionsDao {
void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds,
Set<String> removedUsersIds);
- void addUserPermission(String itemId, String userId, String permission);
-
String getUserItemPermission(String itemId, String userId);
void deleteItemPermissions(String itemId);
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/UserPermissionsDao.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/UserPermissionsDao.java
new file mode 100644
index 0000000000..990fde9f84
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/UserPermissionsDao.java
@@ -0,0 +1,29 @@
+/*
+ * 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.sdc.itempermissions.dao;
+
+import java.util.Set;
+
+public interface UserPermissionsDao {
+
+ Set<String> listUserPermittedItems(String userId, String permission);
+
+ void updatePermissions(String itemId, String permission, Set<String> addedUsersIds,
+ Set<String> removedUsersIds);
+
+}
+
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/UserPermissionsDaoFactory.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/UserPermissionsDaoFactory.java
new file mode 100644
index 0000000000..582fa23c0d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/UserPermissionsDaoFactory.java
@@ -0,0 +1,27 @@
+/*
+ * 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.sdc.itempermissions.dao;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class UserPermissionsDaoFactory extends AbstractComponentFactory<UserPermissionsDao> {
+
+ public static UserPermissionsDaoFactory getInstance() {
+ return AbstractFactory.getInstance(UserPermissionsDaoFactory.class);
+ }
+}
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 8c62aa02fe..87a9949468 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
@@ -1,3 +1,18 @@
+/*
+ * 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.sdc.itempermissions.dao.impl;
import com.datastax.driver.core.ResultSet;
@@ -28,16 +43,11 @@ public class ItemPermissionsDaoImpl implements ItemPermissionsDao {
@Override
public void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds,
Set<String> removedUsersIds) {
- addedUsersIds.forEach(userId -> accessor.addPermission(itemId,userId,permission));
+ addedUsersIds.forEach(userId -> accessor.addPermission(itemId,userId,permission));
removedUsersIds.forEach(userId -> accessor.deletePermission(itemId,userId));
}
@Override
- public void addUserPermission(String itemId, String userId, String permission){
- accessor.addPermission(itemId,userId,permission);
- }
-
- @Override
public String getUserItemPermission(String itemId, String userId) {
ResultSet result = accessor.getUserItemPermission(itemId,userId);
@@ -70,6 +80,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 08b51eee86..608102916e 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
@@ -1,9 +1,25 @@
+/*
+ * 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.sdc.itempermissions.dao.impl;
import org.openecomp.sdc.common.session.SessionContextProviderFactory;
import org.openecomp.sdc.itempermissions.PermissionsRules;
import org.openecomp.sdc.itempermissions.PermissionsServices;
import org.openecomp.sdc.itempermissions.dao.ItemPermissionsDao;
+import org.openecomp.sdc.itempermissions.dao.UserPermissionsDao;
import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
import java.util.Collection;
@@ -15,22 +31,30 @@ import java.util.Set;
*/
public class PermissionsServicesImpl implements PermissionsServices {
- private ItemPermissionsDao permissionsDao;
+ private ItemPermissionsDao itemPermissionsDao;
+
+ private UserPermissionsDao userPermissionsDao;
private PermissionsRules permissionsRules;
private static final String CHANGE_PERMISSIONS = "Change_Item_Permissions";
public PermissionsServicesImpl(PermissionsRules permissionsRules,
- ItemPermissionsDao permissionsDao) {
- this.permissionsDao = permissionsDao;
+ ItemPermissionsDao itemPermissionsDao,UserPermissionsDao userPermissionsDao) {
+ this.itemPermissionsDao = itemPermissionsDao;
this.permissionsRules = permissionsRules;
+ this.userPermissionsDao = userPermissionsDao;
}
@Override
public Collection<ItemPermissionsEntity> listItemPermissions(String itemId) {
- return permissionsDao.listItemPermissions(itemId);
+ return itemPermissionsDao.listItemPermissions(itemId);
+ }
+
+ @Override
+ public Set<String> listUserPermittedItems(String userId, String permission) {
+ return userPermissionsDao.listUserPermittedItems(userId,permission);
}
@Override
@@ -45,15 +69,18 @@ public class PermissionsServicesImpl implements PermissionsServices {
permissionsRules.updatePermission(itemId,currentUserId,permission,addedUsersIds,
removedUsersIds);
- permissionsDao.updateItemPermissions(itemId, permission,
+ itemPermissionsDao.updateItemPermissions(itemId, permission,
addedUsersIds, removedUsersIds);
+ userPermissionsDao.updatePermissions(itemId, permission,
+ addedUsersIds, removedUsersIds);
+
}
@Override
public boolean isAllowed(String itemId,String userId,String action) {
- String userPermission = permissionsDao.getUserItemPermission(itemId,userId);
+ String userPermission = itemPermissionsDao.getUserItemPermission(itemId,userId);
return permissionsRules.isAllowed(userPermission,action);
}
@@ -64,12 +91,12 @@ public class PermissionsServicesImpl implements PermissionsServices {
@Override
public String getUserItemPermiission(String itemId, String userId) {
- return permissionsDao.getUserItemPermission(itemId,userId);
+ return itemPermissionsDao.getUserItemPermission(itemId,userId);
}
@Override
public void deleteItemPermissions(String itemId) {
- permissionsDao.deleteItemPermissions(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 34532cb384..d009f62270 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
@@ -1,9 +1,25 @@
+/*
+ * 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.sdc.itempermissions.dao.impl;
import org.openecomp.sdc.itempermissions.PermissionsRulesFactory;
import org.openecomp.sdc.itempermissions.PermissionsServices;
import org.openecomp.sdc.itempermissions.PermissionsServicesFactory;
import org.openecomp.sdc.itempermissions.dao.ItemPermissionsDaoFactory;
+import org.openecomp.sdc.itempermissions.dao.UserPermissionsDaoFactory;
/**
* Created by ayalaben on 6/22/2017
@@ -11,8 +27,8 @@ import org.openecomp.sdc.itempermissions.dao.ItemPermissionsDaoFactory;
public class PrmissionsServicesFactoryImpl extends PermissionsServicesFactory {
private static final PermissionsServices INSTANCE =
- new org.openecomp.sdc.itempermissions.dao.impl.PermissionsServicesImpl(PermissionsRulesFactory.getInstance().createInterface(),
- ItemPermissionsDaoFactory.getInstance().createInterface());
+ new PermissionsServicesImpl(PermissionsRulesFactory.getInstance().createInterface(),
+ ItemPermissionsDaoFactory.getInstance().createInterface(), UserPermissionsDaoFactory.getInstance().createInterface());
@Override
public PermissionsServices createInterface() {
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
new file mode 100644
index 0000000000..86a64ddf1d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/UserPermissionsDaoFactoryImpl.java
@@ -0,0 +1,30 @@
+/*
+ * 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.sdc.itempermissions.dao.impl;
+
+import org.openecomp.sdc.itempermissions.dao.UserPermissionsDao;
+import org.openecomp.sdc.itempermissions.dao.UserPermissionsDaoFactory;
+
+public class UserPermissionsDaoFactoryImpl extends UserPermissionsDaoFactory {
+
+ private static UserPermissionsDao INSTANCE =new UserPermissionsDaoImpl();
+
+ @Override
+ public UserPermissionsDao 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/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
new file mode 100644
index 0000000000..dad8f25535
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/java/org/openecomp/sdc/itempermissions/dao/impl/UserPermissionsDaoImpl.java
@@ -0,0 +1,72 @@
+/*
+ * 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.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 org.openecomp.core.nosqldb.api.NoSqlDb;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+import org.openecomp.sdc.itempermissions.dao.UserPermissionsDao;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+public class UserPermissionsDaoImpl implements UserPermissionsDao {
+
+ private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static UserPermissionsAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(UserPermissionsAccessor.class);
+
+
+ @Override
+ public Set<String> listUserPermittedItems(String userId, String permission) {
+ ResultSet resultSet = accessor.getUserPermissionItems(userId,permission);
+ if(resultSet.isExhausted()){
+ return new HashSet<>();
+ } else {
+ return resultSet.one().getSet(0,String.class);
+ }
+ }
+
+ @Override
+ 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));
+ }
+
+ @Accessor
+ interface UserPermissionsAccessor {
+
+ @Query("select item_list from dox.user_permission_items WHERE user_id = ? AND permission = ?")
+ ResultSet getUserPermissionItems(String userId, String permission);
+
+ @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);
+
+ @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);
+
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/resources/factoryConfiguration.json
index d23948437f..95a8448719 100644
--- a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/resources/factoryConfiguration.json
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-core/src/main/resources/factoryConfiguration.json
@@ -1,4 +1,5 @@
{
"org.openecomp.sdc.itempermissions.dao.ItemPermissionsDaoFactory": "org.openecomp.sdc.itempermissions.dao.impl.ItemPermissionsDaoFactoryImpl",
+ "org.openecomp.sdc.itempermissions.dao.UserPermissionsDaoFactory": "org.openecomp.sdc.itempermissions.dao.impl.UserPermissionsDaoFactoryImpl",
"org.openecomp.sdc.itempermissions.PermissionsServicesFactory" : "org.openecomp.sdc.itempermissions.dao.impl.PrmissionsServicesFactoryImpl"
} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/PermissionsRulesImpl.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/PermissionsRulesImpl.java
index f80379aa91..feb3d59f7f 100644
--- a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/PermissionsRulesImpl.java
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/PermissionsRulesImpl.java
@@ -1,3 +1,18 @@
+/*
+ * 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.sdc.itempermissions.impl;
import org.openecomp.sdc.common.errors.CoreException;
@@ -7,6 +22,7 @@ import org.openecomp.sdc.itempermissions.errors.PermissionsErrorMessagesBuilder;
import org.openecomp.sdc.itempermissions.impl.types.PermissionActionTypes;
import org.openecomp.sdc.itempermissions.impl.types.PermissionTypes;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -112,22 +128,30 @@ public class PermissionsRulesImpl implements PermissionsRules {
}
if (permission.equals(PermissionTypes.Owner.name())) {
+ makeCurrentUserContributor(itemId,currentUserId);
+ }
+ }
+
+ private void makeCurrentUserContributor(String itemId, String currentUserId) {
- HashSet<String> currentOwner = new HashSet<>();
- currentOwner.add(currentUserId);
+ String currentPermission = PermissionsServicesFactory.getInstance().createInterface().
+ getUserItemPermiission(itemId,currentUserId);
+
+ if(currentPermission != null) {
PermissionsServicesFactory.getInstance().createInterface()
.updateItemPermissions(itemId, PermissionTypes.Contributor.name(),
- currentOwner, new HashSet<String>());
- }
+ Collections.singleton(currentUserId), new HashSet<>());
}
- protected void caseCreateItem(String userId, String itemId) {
+}
+
+ private void caseCreateItem(String userId, String itemId) {
HashSet<String> ownerId = new HashSet<>();
ownerId.add(userId);
PermissionsServicesFactory.getInstance().createInterface()
.updateItemPermissions(itemId, PermissionTypes.Owner.name(), ownerId,
- new HashSet<String>());
+ new HashSet<>());
}
}
diff --git a/openecomp-be/tools/build/scripts/cassandra-commands.json b/openecomp-be/tools/build/scripts/cassandra-commands.json
index 34916fe74d..0b0519a3df 100644
--- a/openecomp-be/tools/build/scripts/cassandra-commands.json
+++ b/openecomp-be/tools/build/scripts/cassandra-commands.json
@@ -22,6 +22,7 @@
"healing" : "CREATE TABLE IF NOT EXISTS healing (space text,item_id text,version_id text, healing_needed boolean,old_version text, PRIMARY KEY((space,item_id),version_id))",
"migration": "CREATE TABLE IF NOT EXISTS migration (id text, ismigrated boolean, primary key (id))",
"item_permissions" : "CREATE TABLE IF NOT EXISTS item_permissions (item_id text,user_id text, permission text, PRIMARY KEY(item_id,user_id)) WITH CLUSTERING ORDER BY (user_id DESC)",
+ "user_permission_items" : "CREATE TABLE IF NOT EXISTS user_permission_items (user_id text,permission text, item_list set<text>, PRIMARY KEY ((user_id), permission))",
"notification_subscribers": "CREATE TABLE IF NOT EXISTS NOTIFICATION_SUBSCRIBERS (entity_id text PRIMARY KEY, subscribers set<text>)",
"last_notification": "CREATE TABLE IF NOT EXISTS last_notification (owner_id text PRIMARY KEY, event_id timeuuid)",
"notifications": "CREATE TABLE IF NOT EXISTS notifications (owner_id text, event_id timeuuid, read boolean, originator_id text, event_type text, event_attributes text, PRIMARY KEY (owner_id, event_id)) WITH CLUSTERING ORDER BY (event_id DESC)",
@@ -46,6 +47,7 @@
"activity_log": "DROP TABLE IF EXISTS activity_log",
"migration": "DROP TABLE IF EXISTS migration",
"item_permissions": "DROP TABLE IF EXISTS item_permissions",
+ "user_permission_items" : "DROP TABLE IF EXISTS user_permission_items",
"notification_subscribers": "DROP TABLE IF EXISTS notification_subscribers",
"last_notification": "DROP TABLE IF EXISTS last_notification",
"notifications": "DROP TABLE IF EXISTS notifications",
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