aboutsummaryrefslogtreecommitdiffstats
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/src/main/java/org/openecomp/sdcrests/itempermissions/rest/ItemPermissions.java50
-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.java48
-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.java34
-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.java37
5 files changed, 82 insertions, 107 deletions
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
index c3ebc31b08..4343c1a000 100644
--- 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
@@ -7,9 +7,9 @@
* 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.
@@ -17,30 +17,32 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdcrests.itempermissions.rest;
+import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
+import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.tags.Tags;
-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.*;
+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;
+import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsDto;
+import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsRequestDto;
+import org.springframework.validation.annotation.Validated;
/**
* Created by ayalaben on 6/18/2017.
@@ -52,19 +54,15 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG
@Validated
public interface ItemPermissions {
- @GET
- @Path("/")
- @Operation(description = "List users permissions assigned on item",responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ItemPermissionsDto.class)))))
- Response list(@PathParam("itemId") String itemId,
- @HeaderParam(USER_ID_HEADER_PARAM) String user);
-
- @PUT
- @Path("/{permission}")
- @Operation(description = "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);
+ @GET
+ @Path("/")
+ @Operation(description = "List users permissions assigned on item", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ItemPermissionsDto.class)))))
+ Response list(@PathParam("itemId") String itemId, @HeaderParam(USER_ID_HEADER_PARAM) String user);
+ @PUT
+ @Path("/{permission}")
+ @Operation(description = "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
index c578cbe699..97011ef4c9 100644
--- 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
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdcrests.itempermissions.rest.mapping;
import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
@@ -27,14 +26,11 @@ import org.openecomp.sdcrests.mapping.MappingBase;
/**
* Created by ayalaben on 6/18/2017.
*/
+public class MapItemPermissionsToItemPermissionsDto extends MappingBase<ItemPermissionsEntity, ItemPermissionsDto> {
-public class MapItemPermissionsToItemPermissionsDto extends
- MappingBase<ItemPermissionsEntity, ItemPermissionsDto> {
-
-
- @Override
- public void doMapping(ItemPermissionsEntity source, ItemPermissionsDto target) {
- target.setUserId(source.getUserId());
- target.setPermission(source.getPermission());
- }
+ @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
index 213af650f7..ece235a29a 100644
--- 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
@@ -15,7 +15,8 @@
*/
package org.openecomp.sdcrests.itempermissions.rest.services;
-
+import javax.inject.Named;
+import javax.ws.rs.core.Response;
import org.openecomp.sdc.itempermissions.PermissionsManager;
import org.openecomp.sdc.itempermissions.PermissionsManagerFactory;
import org.openecomp.sdcrests.itempermissions.rest.ItemPermissions;
@@ -26,41 +27,28 @@ 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 PermissionsManager permissionsManager =
- PermissionsManagerFactory.getInstance().createInterface();
-
- @Override
- public Response list(String itemId, String user) {
-
- GenericCollectionWrapper<ItemPermissionsDto> results = new GenericCollectionWrapper<>();
- MapItemPermissionsToItemPermissionsDto mapper = new MapItemPermissionsToItemPermissionsDto();
-
- permissionsManager.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) {
-
- permissionsManager.updateItemPermissions(itemId,permission,request.getAddedUsersIds(),
- request.getRemovedUsersIds());
-
- return Response.ok().build();
- }
+ private PermissionsManager permissionsManager = PermissionsManagerFactory.getInstance().createInterface();
+
+ @Override
+ public Response list(String itemId, String user) {
+ GenericCollectionWrapper<ItemPermissionsDto> results = new GenericCollectionWrapper<>();
+ MapItemPermissionsToItemPermissionsDto mapper = new MapItemPermissionsToItemPermissionsDto();
+ permissionsManager.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) {
+ permissionsManager.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/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
index ef56619ff6..be3790b6e0 100644
--- 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
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdcrests.itempermissions.types;
/**
@@ -25,23 +24,22 @@ package org.openecomp.sdcrests.itempermissions.types;
*/
public class ItemPermissionsDto {
- private String userId;
- private String permission;
-
- public String getUserId() {
- return userId;
- }
+ private String userId;
+ private String permission;
- public void setUserId(String id) {
- this.userId = id;
- }
+ public String getUserId() {
+ return userId;
+ }
- public String getPermission() {
- return permission;
- }
+ public void setUserId(String id) {
+ this.userId = id;
+ }
- public void setPermission(String permission) {
- this.permission = permission;
- }
+ 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
index 873ff5d49e..1353b58d70 100644
--- 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
@@ -7,9 +7,9 @@
* 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.
@@ -17,38 +17,33 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdcrests.itempermissions.types;
-
-
import io.swagger.v3.oas.annotations.media.Schema;
-
import java.util.Set;
/**
* Created by ayalaben on 6/20/2017.
*/
-
@Schema(description = "ItemPermissionsRequest")
public class ItemPermissionsRequestDto {
- private Set<String> addedUsersIds;
- private Set<String> removedUsersIds;
+ private Set<String> addedUsersIds;
+ private Set<String> removedUsersIds;
- public Set<String> getAddedUsersIds() {
- return addedUsersIds;
- }
+ public Set<String> getAddedUsersIds() {
+ return addedUsersIds;
+ }
- public void setAddedUsersIds(Set<String> addedUsersIds) {
- this.addedUsersIds = addedUsersIds;
- }
+ public void setAddedUsersIds(Set<String> addedUsersIds) {
+ this.addedUsersIds = addedUsersIds;
+ }
- public Set<String> getRemovedUsersIds() {
- return removedUsersIds;
- }
+ public Set<String> getRemovedUsersIds() {
+ return removedUsersIds;
+ }
- public void setRemovedUsersIds(Set<String> removedUsersIds) {
- this.removedUsersIds = removedUsersIds;
- }
+ public void setRemovedUsersIds(Set<String> removedUsersIds) {
+ this.removedUsersIds = removedUsersIds;
+ }
}