From 8dfa832a4bbe276fdf898330325321a776ac253e Mon Sep 17 00:00:00 2001 From: ayalaben Date: Tue, 10 Apr 2018 13:43:01 +0300 Subject: User Permission items Change-Id: Ice1d126dd29e9f49ca90ada7b1671c72545c9ee8 Issue-ID: SDC-1202 Signed-off-by: ayalaben --- .../itempermissions/impl/PermissionsRulesImpl.java | 36 ++++++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl') 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 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()); - } + Collections.singleton(currentUserId), new HashSet<>()); } - protected void caseCreateItem(String userId, String itemId) { +} + + private void caseCreateItem(String userId, String itemId) { HashSet ownerId = new HashSet<>(); ownerId.add(userId); PermissionsServicesFactory.getInstance().createInterface() .updateItemPermissions(itemId, PermissionTypes.Owner.name(), ownerId, - new HashSet()); + new HashSet<>()); } } -- cgit 1.2.3-korg