diff options
author | ayalaben <ayala.benzvi@amdocs.com> | 2018-04-10 13:43:01 +0300 |
---|---|---|
committer | Oren Kleks <orenkle@amdocs.com> | 2018-04-12 07:15:06 +0000 |
commit | 8dfa832a4bbe276fdf898330325321a776ac253e (patch) | |
tree | 2ed00333197348dfb0b933f2c6935ca1c9db9122 /openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src | |
parent | fe35212bee3b89dcee98a11dd364218c587aa41a (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/vendor-license-rest/vendor-license-rest-services/src')
-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.java | 22 |
1 files changed, 10 insertions, 12 deletions
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())); } |