summaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp
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/api/openecomp-sdc-rest-webapp
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/api/openecomp-sdc-rest-webapp')
-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
5 files changed, 42 insertions, 31 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());
}