aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl
diff options
context:
space:
mode:
authorayalaben <Ayala.Benzvi@Amdocs.Com>2018-02-11 11:11:00 +0200
committerayalaben <ayala.benzvi@amdocs.com>2018-02-11 15:27:45 +0200
commitda603323ec3cdf4257707ac1cb4d5d657783ae9f (patch)
treea8e65ce8629da0e56d5ac7fa7993b518d360a761 /openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl
parent27fed258bd045e4af8cdc1181ebf3cef8d0822cc (diff)
Delete Item Draft
Change-Id: I13767ab6a7be82ae89f80d50b5857aabe6e55906 Issue-ID: SDC-1014 Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl')
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/PermissionsRulesImpl.java186
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/types/PermissionActionTypes.java1
2 files changed, 97 insertions, 90 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 1f56c1038a..f80379aa91 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
@@ -19,109 +19,115 @@ import static org.openecomp.sdc.itempermissions.errors.PermissionsErrorMessages.
public class PermissionsRulesImpl implements PermissionsRules {
- @Override
- public boolean isAllowed(String permission, String action) {
+ @Override
+ public boolean isAllowed(String permission, String action) {
- if (permission == null) {
- return false;
- }
- try {
- PermissionTypes.valueOf(permission);
- } catch (IllegalArgumentException ex) {
- throw new CoreException(new PermissionsErrorMessagesBuilder(INVALID_PERMISSION_TYPE).build());
- }
+ if (permission == null) {
+ return false;
+ }
+ try {
+ PermissionTypes.valueOf(permission);
+ } catch (IllegalArgumentException ex) {
+ throw new CoreException(new PermissionsErrorMessagesBuilder(INVALID_PERMISSION_TYPE).build());
+ }
- try {
- switch (PermissionActionTypes.valueOf(action)) {
- case Create_Item:
- return true;
-
- case Edit_Item:
- if (permission.equals(PermissionTypes.Contributor.name()) || permission.equals
- (PermissionTypes.Owner.name())) {
- return true;
- }
- break;
- case Commit_Item:
- if (permission.equals(PermissionTypes.Contributor.name()) || permission.equals
- (PermissionTypes.Owner.name())) {
- return true;
+ try {
+ switch (PermissionActionTypes.valueOf(action)) {
+ case Create_Item:
+ return true;
+
+ case Edit_Item:
+ if (permission.equals(PermissionTypes.Contributor.name()) || permission.equals
+ (PermissionTypes.Owner.name())) {
+ return true;
+ }
+ break;
+ case Commit_Item:
+ if (permission.equals(PermissionTypes.Contributor.name()) || permission.equals
+ (PermissionTypes.Owner.name())) {
+ return true;
+ }
+ break;
+ case Delete_Item:
+ if (permission.equals(PermissionTypes.Contributor.name()) || permission.equals
+ (PermissionTypes.Owner.name())) {
+ return true;
+ }
+ break;
+
+ case Change_Item_Permissions:
+ if (permission.equals(PermissionTypes.Owner.name())) {
+ return true;
+ }
+ break;
+
+ case Submit_Item:
+ if (permission.equals(PermissionTypes.Contributor.name()) || permission.equals
+ (PermissionTypes.Owner.name())) {
+ return true;
+ }
+ break;
+
+ default:
+ return false;
+ }
+ } catch (IllegalArgumentException ex) {
+ throw new CoreException(new PermissionsErrorMessagesBuilder(INVALID_ACTION_TYPE).build());
}
- break;
-
- case Change_Item_Permissions:
- if (permission.equals(PermissionTypes.Owner.name())) {
- return true;
- }
- break;
-
- case Submit_Item:
- if (permission.equals(PermissionTypes.Contributor.name()) || permission.equals
- (PermissionTypes.Owner.name())) {
- return true;
- }
- break;
-
- default:
- return false;
- }
- } catch (IllegalArgumentException ex) {
- throw new CoreException(new PermissionsErrorMessagesBuilder(INVALID_ACTION_TYPE).build());
- }
- return false;
- }
+ return false;
+ }
- @Override
- public void executeAction(String itemId, String userId, String action) {
- try {
- switch (PermissionActionTypes.valueOf(action)) {
- case Create_Item:
- caseCreateItem(userId,itemId);
- break;
+ @Override
+ public void executeAction(String itemId, String userId, String action) {
+ try {
+ switch (PermissionActionTypes.valueOf(action)) {
+ case Create_Item:
+ caseCreateItem(userId, itemId);
+ break;
- case Change_Item_Permissions:
- break;
+ case Change_Item_Permissions:
+ break;
- case Edit_Item:
- break;
+ case Edit_Item:
+ break;
- case Submit_Item:
- break;
+ case Submit_Item:
+ break;
- default:
- }
- } catch (IllegalArgumentException ex) {
- throw new CoreException(new PermissionsErrorMessagesBuilder(INVALID_ACTION_TYPE).build());
- }
- }
-
- @Override
- public void updatePermission(String itemId,String currentUserId, String permission, Set<String>
- addedUsersIds,Set<String> removedUsersIds) {
- try {
- PermissionTypes.valueOf(permission);
- } catch (IllegalArgumentException ex) {
- throw new CoreException(new PermissionsErrorMessagesBuilder(INVALID_PERMISSION_TYPE).build());
+ default:
+ }
+ } catch (IllegalArgumentException ex) {
+ throw new CoreException(new PermissionsErrorMessagesBuilder(INVALID_ACTION_TYPE).build());
+ }
}
- if (permission.equals(PermissionTypes.Owner.name())) {
+ @Override
+ public void updatePermission(String itemId, String currentUserId, String permission, Set<String>
+ addedUsersIds, Set<String> removedUsersIds) {
+ try {
+ PermissionTypes.valueOf(permission);
+ } catch (IllegalArgumentException ex) {
+ throw new CoreException(new PermissionsErrorMessagesBuilder(INVALID_PERMISSION_TYPE).build());
+ }
+
+ if (permission.equals(PermissionTypes.Owner.name())) {
- HashSet<String> currentOwner = new HashSet<String>();
- currentOwner.add(currentUserId);
+ HashSet<String> currentOwner = new HashSet<>();
+ currentOwner.add(currentUserId);
+
+ PermissionsServicesFactory.getInstance().createInterface()
+ .updateItemPermissions(itemId, PermissionTypes.Contributor.name(),
+ currentOwner, new HashSet<String>());
+ }
+ }
- PermissionsServicesFactory.getInstance().createInterface()
- .updateItemPermissions(itemId,PermissionTypes.Contributor.name(),
- currentOwner,new HashSet<String>());
+ protected 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>());
}
- }
-
- protected void caseCreateItem(String userId,String itemId) {
- HashSet<String> ownerId = new HashSet<String>();
- ownerId.add(userId);
- PermissionsServicesFactory.getInstance().createInterface()
- .updateItemPermissions(itemId, PermissionTypes.Owner.name(), ownerId,
- new HashSet<String>());
- }
}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/types/PermissionActionTypes.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/types/PermissionActionTypes.java
index 3d1b8a82d7..3911f2ad7b 100644
--- a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/types/PermissionActionTypes.java
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-impl/src/main/java/org/openecomp/sdc/itempermissions/impl/types/PermissionActionTypes.java
@@ -9,6 +9,7 @@ public enum PermissionActionTypes {
Change_Item_Permissions,
Edit_Item,
Commit_Item,
+ Delete_Item,
Submit_Item;
}