aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api')
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/pom.xml32
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsRules.java17
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsRulesFactory.java16
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsServices.java26
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsServicesFactory.java16
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/ItemPermissionsDao.java21
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/ItemPermissionsDaoFactory.java15
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/errors/PermissionsErrorMessages.java23
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/errors/PermissionsErrorMessagesBuilder.java29
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/notifications/NotificationConstants.java14
-rw-r--r--openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/type/ItemPermissionsEntity.java50
11 files changed, 259 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/pom.xml b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/pom.xml
new file mode 100644
index 0000000000..f69f3041a7
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/pom.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
+ <modelVersion>4.0.0</modelVersion>
+
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-item-permissions-lib</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>openecomp-item-permissions-api</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-nosqldb-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-facade-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+
+ </dependencies>
+
+</project> \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsRules.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsRules.java
new file mode 100644
index 0000000000..b5a119e8ed
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsRules.java
@@ -0,0 +1,17 @@
+package org.openecomp.sdc.itempermissions;
+
+import java.util.Set;
+
+/**
+ * Created by ayalaben on 6/22/2017.
+ */
+public interface PermissionsRules {
+
+ boolean isAllowed(String userId,String action);
+
+ void executeAction(String itemId, String userId, String action);
+
+ void updatePermission(String itemId,String currentUserId, String permission,Set<String>
+ addedUsersIds, Set<String> removedUsersIds);
+
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsRulesFactory.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsRulesFactory.java
new file mode 100644
index 0000000000..c3e0672939
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsRulesFactory.java
@@ -0,0 +1,16 @@
+package org.openecomp.sdc.itempermissions;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+/**
+ * Created by ayalaben on 6/26/2017
+ */
+public abstract class PermissionsRulesFactory extends
+ AbstractComponentFactory<PermissionsRules> {
+
+ public static PermissionsRulesFactory getInstance() {
+ return AbstractFactory.getInstance(PermissionsRulesFactory.class);
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsServices.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsServices.java
new file mode 100644
index 0000000000..09c8102ef0
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsServices.java
@@ -0,0 +1,26 @@
+package org.openecomp.sdc.itempermissions;
+
+import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
+
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ * Created by ayalaben on 6/22/2017
+ */
+public interface PermissionsServices {
+
+ Collection<ItemPermissionsEntity> listItemPermissions(String itemId);
+
+ void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds,
+ Set<String> removedUsersIds);
+
+ boolean isAllowed(String itemId,String userId,String action);
+
+ void execute(String itemId,String userId,String action);
+
+ String getUserItemPermiission(String itemId, String userId);
+
+
+
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsServicesFactory.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsServicesFactory.java
new file mode 100644
index 0000000000..97769bcc82
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/PermissionsServicesFactory.java
@@ -0,0 +1,16 @@
+package org.openecomp.sdc.itempermissions;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+/**
+ * Created by ayalaben on 6/22/2017.
+ */
+public abstract class PermissionsServicesFactory extends
+ AbstractComponentFactory<PermissionsServices> {
+
+ public static PermissionsServicesFactory getInstance() {
+ return AbstractFactory.getInstance(PermissionsServicesFactory.class);
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/ItemPermissionsDao.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/ItemPermissionsDao.java
new file mode 100644
index 0000000000..a0f51f90bb
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/ItemPermissionsDao.java
@@ -0,0 +1,21 @@
+package org.openecomp.sdc.itempermissions.dao;
+
+import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
+
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ * Created by ayalaben on 6/18/2017.
+ */
+public interface ItemPermissionsDao {
+
+ Collection<ItemPermissionsEntity> listItemPermissions(String itemId);
+
+ void updateItemPermissions(String itemId, String permission, Set<String> addedUsersIds,
+ Set<String> removedUsersIds);
+
+ void addUserPermission(String itemId, String userId, String permission);
+
+ String getUserItemPermiission(String itemId, String userId);
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/ItemPermissionsDaoFactory.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/ItemPermissionsDaoFactory.java
new file mode 100644
index 0000000000..95d541e028
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/dao/ItemPermissionsDaoFactory.java
@@ -0,0 +1,15 @@
+package org.openecomp.sdc.itempermissions.dao;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+/**
+ * Created by ayalaben on 6/18/2017.
+ */
+public abstract class ItemPermissionsDaoFactory extends AbstractComponentFactory<ItemPermissionsDao> {
+
+ public static ItemPermissionsDaoFactory getInstance() {
+ return AbstractFactory.getInstance(ItemPermissionsDaoFactory.class);
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/errors/PermissionsErrorMessages.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/errors/PermissionsErrorMessages.java
new file mode 100644
index 0000000000..a3fb9a14a8
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/errors/PermissionsErrorMessages.java
@@ -0,0 +1,23 @@
+package org.openecomp.sdc.itempermissions.errors;
+
+/**
+ * Created by ayalaben on 6/28/2017
+ */
+public enum PermissionsErrorMessages {
+
+ NO_PERMISSION_FOR_USER("The user is not permitted to edit this item"),
+ USER_NOT_OWNER_SUBMIT("The user must be the owner to submit the item"),
+ INVALID_PERMISSION_TYPE("Invalid permission type"),
+ INVALID_ACTION_TYPE("Invalid action type");
+
+ private String errorMessage;
+
+ PermissionsErrorMessages(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/errors/PermissionsErrorMessagesBuilder.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/errors/PermissionsErrorMessagesBuilder.java
new file mode 100644
index 0000000000..f0c13d9cda
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/errors/PermissionsErrorMessagesBuilder.java
@@ -0,0 +1,29 @@
+package org.openecomp.sdc.itempermissions.errors;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+/**
+ * Created by ayalaben on 6/28/2017
+ */
+public class PermissionsErrorMessagesBuilder {
+ public static final String PERMISSIONS_ERROR= "PERMISSIONS_ERROR";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ /**
+ * Instantiates a new Submit uncompleted license model error builder.
+ *
+ * @param error
+ */
+ public PermissionsErrorMessagesBuilder(PermissionsErrorMessages error) {
+ builder.withId(PERMISSIONS_ERROR);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(error.getErrorMessage());
+ }
+
+ public ErrorCode build() {
+ return builder.build();
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/notifications/NotificationConstants.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/notifications/NotificationConstants.java
new file mode 100644
index 0000000000..d4235cd6c6
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/notifications/NotificationConstants.java
@@ -0,0 +1,14 @@
+package org.openecomp.sdc.itempermissions.notifications;
+
+/**
+ * @author avrahamg
+ * @since July 10, 2017
+ */
+public class NotificationConstants {
+ public static final String PERMISSION_CHANGED= "PermissionChanged";
+ public static final String PERMISSION_ITEM = "permission";
+ public static final String ITEM_ID_PROP = "itemId";
+ public static final String ITEM_NAME_PROP = "itemName";
+ public static final String PERMISSION_GRANTED = "granted";
+ public static final String PERMISSION_USER = "userId";
+}
diff --git a/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/type/ItemPermissionsEntity.java b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/type/ItemPermissionsEntity.java
new file mode 100644
index 0000000000..22ff43778c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-item-permissions-lib/openecomp-item-permissions-api/src/main/java/org/openecomp/sdc/itempermissions/type/ItemPermissionsEntity.java
@@ -0,0 +1,50 @@
+package org.openecomp.sdc.itempermissions.type;
+
+import com.datastax.driver.mapping.annotations.ClusteringColumn;
+import com.datastax.driver.mapping.annotations.Column;
+import com.datastax.driver.mapping.annotations.PartitionKey;
+import com.datastax.driver.mapping.annotations.Table;
+
+/**
+ * Created by ayalaben on 6/18/2017.
+ */
+
+@Table(keyspace = "dox", name = "item_permissions")
+public class ItemPermissionsEntity {
+
+ @PartitionKey
+ @Column(name = "item_id")
+ private String itemId;
+
+ @ClusteringColumn
+ @Column(name = "user_id")
+ private String userId;
+
+ @Column(name = "permission")
+ private String permission;
+
+
+ public String getItemId() {
+ return itemId;
+ }
+
+ public void setItemId(String itemId) {
+ this.itemId = itemId;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public String getPermission() {
+ return permission;
+ }
+
+ public void setPermission(String permission) {
+ this.permission = permission;
+ }
+}