summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src
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/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src
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/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src')
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/PermissionsRulesImpl.java36
1 files changed, 30 insertions, 6 deletions
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<>());
}
}