summaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/pom.xml68
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/ItemPermissions.java53
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/mapping/MapItemPermissionsToItemPermissionsDto.java20
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/services/ItemPermissionsImpl.java52
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/pom.xml24
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsDto.java27
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsRequestDto.java32
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/pom.xml24
8 files changed, 300 insertions, 0 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/pom.xml
new file mode 100644
index 0000000000..cec27da833
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/pom.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>item-permissions-rest</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>item-permissions-rest-services</artifactId>
+
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>item-permissions-rest-types</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-common-rest</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-item-permissions-manager</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
+
+
+ <!--<dependency>-->
+ <!--<groupId>javax.ws.rs</groupId>-->
+ <!--<artifactId>javax.ws.rs-api</artifactId>-->
+ <!--<version>${ws.rs.version}</version>-->
+ <!--</dependency>-->
+
+ <!--<dependency>-->
+ <!--<groupId>org.apache.cxf</groupId>-->
+ <!--<artifactId>cxf-rt-frontend-jaxrs</artifactId>-->
+ <!--<version>${cxf.version}</version>-->
+ <!--</dependency>-->
+
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-models</artifactId>
+ <version>RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${spring.framework.version}</version>
+ </dependency>
+ </dependencies>
+
+
+</project> \ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/ItemPermissions.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/ItemPermissions.java
new file mode 100644
index 0000000000..e73595c67b
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/ItemPermissions.java
@@ -0,0 +1,53 @@
+package org.openecomp.sdcrests.itempermissions.rest;
+
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsDto;
+import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsRequestDto;
+import org.springframework.validation.annotation.Validated;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
+import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
+
+/**
+ * Created by ayalaben on 6/18/2017.
+ */
+@Path("/v1.0/items/{itemId}/permissions")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+@Api(value = "Item Permissions")
+@Validated
+public interface ItemPermissions {
+
+ @GET
+ @Path("/")
+ @ApiOperation(value = "List users permissions assigned on item",
+ response = ItemPermissionsDto.class,
+ responseContainer = "List")
+
+ Response list(@PathParam("itemId") String itemId,
+ @HeaderParam(USER_ID_HEADER_PARAM) String user);
+
+ @PUT
+ @Path("/{permission}")
+ @ApiOperation(value = "Update useres permission on item")
+ Response updatePermissions(@Valid ItemPermissionsRequestDto request,
+ @PathParam("itemId") String itemId,
+ @PathParam("permission") String permission,
+ @NotNull(message = USER_MISSING_ERROR_MSG)
+ @HeaderParam(USER_ID_HEADER_PARAM) String user);
+
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/mapping/MapItemPermissionsToItemPermissionsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/mapping/MapItemPermissionsToItemPermissionsDto.java
new file mode 100644
index 0000000000..88c3d4d74e
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/mapping/MapItemPermissionsToItemPermissionsDto.java
@@ -0,0 +1,20 @@
+package org.openecomp.sdcrests.itempermissions.rest.mapping;
+
+import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
+import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsDto;
+import org.openecomp.sdcrests.mapping.MappingBase;
+
+/**
+ * Created by ayalaben on 6/18/2017.
+ */
+
+public class MapItemPermissionsToItemPermissionsDto extends
+ MappingBase<ItemPermissionsEntity, ItemPermissionsDto> {
+
+
+ @Override
+ public void doMapping(ItemPermissionsEntity source, ItemPermissionsDto target) {
+ target.setUserId(source.getUserId());
+ target.setPermission(source.getPermission());
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/services/ItemPermissionsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/services/ItemPermissionsImpl.java
new file mode 100644
index 0000000000..4fe93c20ac
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/services/ItemPermissionsImpl.java
@@ -0,0 +1,52 @@
+//package org.openecomp.sdcrests.itempermissions.rest.mapping.mapping.services;
+package org.openecomp.sdcrests.itempermissions.rest.services;
+
+
+import org.openecomp.sdc.itempermissions.ItemPermissionsManager;
+import org.openecomp.sdc.itempermissions.ItemPermissionsManagerFactory;
+import org.openecomp.sdcrests.itempermissions.rest.ItemPermissions;
+import org.openecomp.sdcrests.itempermissions.rest.mapping.MapItemPermissionsToItemPermissionsDto;
+import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsDto;
+import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsRequestDto;
+import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Named;
+import javax.ws.rs.core.Response;
+
+/**
+ * Created by ayalaben on 6/18/2017.
+ */
+
+@Named
+@Service("itemPermissions")
+@Scope(value = "prototype")
+public class ItemPermissionsImpl implements ItemPermissions {
+
+ private ItemPermissionsManager itemPermissionsManager =
+ ItemPermissionsManagerFactory.getInstance().createInterface();
+
+ @Override
+ public Response list(String itemId, String user) {
+
+ GenericCollectionWrapper<ItemPermissionsDto> results = new GenericCollectionWrapper<>();
+ MapItemPermissionsToItemPermissionsDto mapper = new MapItemPermissionsToItemPermissionsDto();
+
+ itemPermissionsManager.listItemPermissions(itemId)
+ .forEach(itemPermission -> results.add(mapper.applyMapping
+ (itemPermission, ItemPermissionsDto.class)));
+
+ return Response.ok(results).build();
+ }
+
+ @Override
+ public Response updatePermissions(ItemPermissionsRequestDto request, String itemId,
+ String permission, String user) {
+
+ itemPermissionsManager.updateItemPermissions(itemId,permission,request.getAddedUsersIds(),
+ request.getRemovedUsersIds());
+
+ return Response.ok().build();
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/pom.xml
new file mode 100644
index 0000000000..49f1f2b6d3
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/pom.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <dependencies>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-annotations</artifactId>
+ <version>1.5.3</version>
+ </dependency>
+
+ </dependencies>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>item-permissions-rest</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>item-permissions-rest-types</artifactId>
+
+
+</project> \ No newline at end of file
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsDto.java
new file mode 100644
index 0000000000..d7f0b9f259
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsDto.java
@@ -0,0 +1,27 @@
+package org.openecomp.sdcrests.itempermissions.types;
+
+/**
+ * Created by ayalaben on 6/18/2017.
+ */
+public class ItemPermissionsDto {
+
+ private String userId;
+ private String permission;
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String id) {
+ this.userId = id;
+ }
+
+ public String getPermission() {
+ return permission;
+ }
+
+ public void setPermission(String permission) {
+ this.permission = permission;
+ }
+
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsRequestDto.java
new file mode 100644
index 0000000000..82a960c7fd
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsRequestDto.java
@@ -0,0 +1,32 @@
+package org.openecomp.sdcrests.itempermissions.types;
+
+import io.swagger.annotations.ApiModel;
+
+import java.util.Set;
+
+/**
+ * Created by ayalaben on 6/20/2017.
+ */
+
+@ApiModel(value = "ItemPermissionsRequest")
+public class ItemPermissionsRequestDto {
+
+ private Set<String> addedUsersIds;
+ private Set<String> removedUsersIds;
+
+ public Set<String> getAddedUsersIds() {
+ return addedUsersIds;
+ }
+
+ public void setAddedUsersIds(Set<String> addedUsersIds) {
+ this.addedUsersIds = addedUsersIds;
+ }
+
+ public Set<String> getRemovedUsersIds() {
+ return removedUsersIds;
+ }
+
+ public void setRemovedUsersIds(Set<String> removedUsersIds) {
+ this.removedUsersIds = removedUsersIds;
+ }
+}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/pom.xml
new file mode 100644
index 0000000000..f89fb0760a
--- /dev/null
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/pom.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-rest-webapp</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>item-permissions-rest</artifactId>
+
+ <packaging>pom</packaging>
+
+
+ <modules>
+ <module>item-permissions-rest-types</module>
+ <module>item-permissions-rest-services</module>
+ </modules>
+
+</project> \ No newline at end of file