From aa247bc1f25c64feed65af2b024f2a9ac3ee90a0 Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Fri, 21 Jun 2019 15:10:18 +0530 Subject: [PATCH] Improve publisher review management --- .../management/ApplicationManagementTest.java | 410 ++++++++++-------- .../admin/ReviewManagementAdminAPI.java | 313 +++++++++++++ .../admin/ReviewManagementAdminAPIImpl.java | 79 +++- .../src/main/webapp/WEB-INF/cxf-servlet.xml | 2 + .../api/services/ReviewManagementAPI.java | 214 +++------ .../admin/ReviewManagementAdminAPI.java | 174 -------- .../impl/ReviewManagementAPIImpl.java | 48 -- .../src/main/webapp/WEB-INF/cxf-servlet.xml | 2 - .../main/resources/conf/application-mgt.xml | 1 + 9 files changed, 679 insertions(+), 564 deletions(-) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/admin/ReviewManagementAdminAPI.java rename components/application-mgt/{org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store => org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher}/api/services/impl/admin/ReviewManagementAdminAPIImpl.java (54%) delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/admin/ReviewManagementAdminAPI.java diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/java/org.wso2.carbon.device.application.mgt.core/management/ApplicationManagementTest.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/java/org.wso2.carbon.device.application.mgt.core/management/ApplicationManagementTest.java index 3942735da28..fce6bc41a98 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/java/org.wso2.carbon.device.application.mgt.core/management/ApplicationManagementTest.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/java/org.wso2.carbon.device.application.mgt.core/management/ApplicationManagementTest.java @@ -22,6 +22,10 @@ import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagem import org.wso2.carbon.device.application.mgt.core.dto.ApplicationsDTO; import org.wso2.carbon.device.application.mgt.core.impl.ApplicationManagerImpl; import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; +import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; +import org.wso2.carbon.device.mgt.core.dto.DeviceType; +import org.wso2.carbon.device.mgt.core.dto.DeviceTypeVersion; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl; import java.io.File; import java.io.FileInputStream; @@ -35,190 +39,224 @@ public class ApplicationManagementTest extends BaseTestCase { private static final Log log = LogFactory.getLog(ApplicationManagementTest.class); -// @Test -// public void testAddApplication() throws Exception { -// -// ApplicationDAO applicationDAO = ApplicationManagementDAOFactory.getApplicationDAO(); -// ConnectionManagerUtil.beginDBTransaction(); -// applicationDAO.createApplication(ApplicationsDTO.getApp1(), -1234); -// ConnectionManagerUtil.commitDBTransaction(); -// ConnectionManagerUtil.closeDBConnection(); -// } -// -// @Test(dependsOnMethods = ("addAplicationCategories")) -// public void createApplication() throws Exception { -// -// log.debug("Creating the first application ....!"); -// -// ApplicationWrapper applicationWrapper = new ApplicationWrapper(); -// -// List categories = new ArrayList<>(); -// categories.add("Test Category"); -// applicationWrapper.setAppCategories(categories); -// -// applicationWrapper.setDescription("Test Description"); -// applicationWrapper.setDeviceType("android"); -// applicationWrapper.setName("Test Application"); -// applicationWrapper.setSubType("Test Sub type"); -// -// List tags = new ArrayList<>(); -// tags.add("abc"); -// tags.add("pqr"); -// tags.add("xyz"); -// applicationWrapper.setTags(tags); -// applicationWrapper.setPaymentCurrency("USD"); -// -// List applicationReleaseWrappers = new ArrayList<>(); -// ApplicationReleaseWrapper releaseWrapper = new ApplicationReleaseWrapper(); -// releaseWrapper.setDescription("First release"); -// releaseWrapper.setIsSharedWithAllTenants(false); -// releaseWrapper.setMetaData("Just meta data"); -// releaseWrapper.setReleaseType("free"); -// releaseWrapper.setPrice(5.7); -// releaseWrapper.setSupportedOsVersions("4.0-7.0"); -// applicationReleaseWrappers.add(releaseWrapper); -// -// applicationWrapper.setApplicationReleaseWrappers(applicationReleaseWrappers); -// -// ApplicationArtifact applicationArtifact = new ApplicationArtifact(); -// applicationArtifact.setBannerName("My First Banner"); -// File banner = new File("src/test/resources/samples/app1/banner1.jpg"); -// InputStream bannerStream = new FileInputStream(banner); -// applicationArtifact.setBannerStream(bannerStream); -// applicationArtifact.setIconName("My First Icon"); -// applicationArtifact.setIconStream(new FileInputStream(new File("src/test/resources/samples/app1/icon.png"))); -// applicationArtifact.setInstallerName("Test Android App"); -// applicationArtifact.setInstallerStream(new FileInputStream(new File("src/test/resources/samples/app1/sample.apk"))); -// -// Map screenshots = new HashMap<>(); -// screenshots.put("shot1", new FileInputStream(new File("src/test/resources/samples/app1/shot1.png"))); -// screenshots.put("shot2", new FileInputStream(new File("src/test/resources/samples/app1/shot2.png"))); -// screenshots.put("shot3", new FileInputStream(new File("src/test/resources/samples/app1/shot3.png"))); -// -// applicationArtifact.setScreenshots(screenshots); -// -// ApplicationManager manager = new ApplicationManagerImpl(); -// manager.createApplication(applicationWrapper, applicationArtifact); -// } -// -// @Test -// public void updateApplication(int applicationId, ApplicationUpdateWrapper applicationUpdateWrapper) throws ApplicationManagementException { -// -// } -// -// @Test -// public void deleteApplication(int applicationId) throws ApplicationManagementException { -// -// } -// -// @Test -// public void retireApplication(int applicationId) throws ApplicationManagementException { -// -// } -// -// @Test -// public void deleteApplicationRelease(String releaseUuid) throws ApplicationManagementException { -// -// } -// -// @Test -// public ApplicationList getApplications(Filter filter) throws ApplicationManagementException { -// return null; -// } -// -// @Test -// public Application getApplicationById(int id, String state) throws ApplicationManagementException { -// return null; -// } -// -// @Test -// public ApplicationRelease getApplicationReleaseByUUID(String uuid) throws ApplicationManagementException { -// return null; -// } -// -// @Test -// public ApplicationDTO getApplicationByUuid(String uuid, String state) throws ApplicationManagementException { -// return null; -// } -// -// @Test -// public ApplicationDTO getApplicationByRelease(String appReleaseUUID) throws ApplicationManagementException { -// return null; -// } -// -// @Test -// public List getLifecycleStateChangeFlow(String releaseUuid) throws ApplicationManagementException { -// return null; -// } -// -// @Test -// public void changeLifecycleState(String releaseUuid, String stateName) throws ApplicationManagementException { -// -// } -// -// @Test -// public void updateApplicationImageArtifact(String uuid, ApplicationArtifact applicationArtifact) throws ApplicationManagementException { -// -// } -// -// @Test -// public void updateApplicationArtifact(String deviceType, String appType, String uuid, ApplicationArtifact applicationArtifact) throws ApplicationManagementException { -// -// } -// -// @Test -// public ApplicationRelease createRelease(int applicationId, ApplicationReleaseWrapper applicationReleaseWrapper, ApplicationArtifact applicationArtifact) throws ApplicationManagementException { -// return null; -// } -// -// @Test -// public boolean updateRelease(String deviceType, String applicationType, String releaseUuid, ApplicationReleaseWrapper applicationReleaseWrapper, ApplicationArtifact applicationArtifact) throws ApplicationManagementException { -// return false; -// } -// -// @Test -// public void validateAppCreatingRequest(ApplicationWrapper applicationWrapper) throws RequestValidatingException { -// -// } -// -// @Test -// public void validateReleaseCreatingRequest(ApplicationReleaseWrapper applicationReleaseWrapper, String applicationType) throws RequestValidatingException { -// -// } -// -// @Test -// public void validateImageArtifacts(Attachment iconFile, Attachment bannerFile, List attachmentList) throws RequestValidatingException { -// -// } -// -// @Test -// public void validateBinaryArtifact(Attachment binaryFile, String applicationType) throws RequestValidatingException { -// -// } -// -// @Test -// public void addAplicationCategories() throws ApplicationManagementException { -// -// List categories = new ArrayList<>(); -// categories.add("Test Category"); -// categories.add("Test Category2"); -// ApplicationManager manager = new ApplicationManagerImpl(); -// manager.addApplicationCategories(categories); -// -// } -// -// @Test -// public List getRegisteredTags() throws ApplicationManagementException { -// return null; -// } -// -// @Test -// public List getRegisteredCategories() throws ApplicationManagementException { -// return null; -// } -// -// @Test -// public void deleteTagMapping(int appId, String tagName) throws ApplicationManagementException { -// -// } + @Test + public void testAddApplication() throws Exception { + + ApplicationDAO applicationDAO = ApplicationManagementDAOFactory.getApplicationDAO(); + ConnectionManagerUtil.beginDBTransaction(); + applicationDAO.createApplication(ApplicationsDTO.getApp1(), -1234); + ConnectionManagerUtil.commitDBTransaction(); + ConnectionManagerUtil.closeDBConnection(); + } + + @Test(dependsOnMethods = ("addApplicationCategories")) + public void createApplication() throws Exception { + + log.debug("Creating the first application ....!"); + + ApplicationWrapper applicationWrapper = new ApplicationWrapper(); + + List categories = new ArrayList<>(); + categories.add("Test Category"); + applicationWrapper.setAppCategories(categories); + + applicationWrapper.setDescription("Test Description"); + applicationWrapper.setDeviceType("android"); + applicationWrapper.setName("Test Application"); + applicationWrapper.setSubType("Test Sub type"); + + List tags = new ArrayList<>(); + tags.add("abc"); + tags.add("pqr"); + tags.add("xyz"); + applicationWrapper.setTags(tags); + applicationWrapper.setPaymentCurrency("USD"); + + List applicationReleaseWrappers = new ArrayList<>(); + ApplicationReleaseWrapper releaseWrapper = new ApplicationReleaseWrapper(); + releaseWrapper.setDescription("First release"); + releaseWrapper.setIsSharedWithAllTenants(false); + releaseWrapper.setMetaData("Just meta data"); + releaseWrapper.setReleaseType("free"); + releaseWrapper.setPrice(5.7); + releaseWrapper.setSupportedOsVersions("4.0-7.0"); + applicationReleaseWrappers.add(releaseWrapper); + + applicationWrapper.setApplicationReleaseWrappers(applicationReleaseWrappers); + + ApplicationArtifact applicationArtifact = new ApplicationArtifact(); + applicationArtifact.setBannerName("My First Banner"); + File banner = new File("src/test/resources/samples/app1/banner1.jpg"); + InputStream bannerStream = new FileInputStream(banner); + applicationArtifact.setBannerStream(bannerStream); + applicationArtifact.setIconName("My First Icon"); + applicationArtifact.setIconStream(new FileInputStream(new File("src/test/resources/samples/app1/icon.png"))); + applicationArtifact.setInstallerName("Test Android App"); + applicationArtifact.setInstallerStream(new FileInputStream(new File("src/test/resources/samples/app1/sample.apk"))); + + Map screenshots = new HashMap<>(); + screenshots.put("shot1", new FileInputStream(new File("src/test/resources/samples/app1/shot1.png"))); + screenshots.put("shot2", new FileInputStream(new File("src/test/resources/samples/app1/shot2.png"))); + screenshots.put("shot3", new FileInputStream(new File("src/test/resources/samples/app1/shot3.png"))); + + applicationArtifact.setScreenshots(screenshots); + + ApplicationManager manager = new ApplicationManagerImpl(); + manager.createApplication(applicationWrapper, applicationArtifact); + } + + @Test + public void updateApplication(int applicationId, ApplicationUpdateWrapper applicationUpdateWrapper) throws ApplicationManagementException { + + } + + @Test + public void deleteApplication(int applicationId) throws ApplicationManagementException { + + } + + @Test + public void retireApplication(int applicationId) throws ApplicationManagementException { + + } + + @Test + public void deleteApplicationRelease(String releaseUuid) throws ApplicationManagementException { + + } + + @Test + public ApplicationList getApplications(Filter filter) throws ApplicationManagementException { + return null; + } + + @Test + public Application getApplicationById(int id, String state) throws ApplicationManagementException { + return null; + } + + @Test + public ApplicationRelease getApplicationReleaseByUUID(String uuid) throws ApplicationManagementException { + return null; + } + + @Test + public ApplicationDTO getApplicationByUuid(String uuid, String state) throws ApplicationManagementException { + return null; + } + + @Test + public ApplicationDTO getApplicationByRelease(String appReleaseUUID) throws ApplicationManagementException { + return null; + } + + @Test + public List getLifecycleStateChangeFlow(String releaseUuid) throws ApplicationManagementException { + return null; + } + + @Test + public void changeLifecycleState(String releaseUuid, String stateName) throws ApplicationManagementException { + + } + + @Test + public void updateApplicationImageArtifact(String uuid, ApplicationArtifact applicationArtifact) throws ApplicationManagementException { + + } + + @Test + public void updateApplicationArtifact(String deviceType, String appType, String uuid, ApplicationArtifact applicationArtifact) throws ApplicationManagementException { + + } + + @Test + public ApplicationRelease createRelease(int applicationId, ApplicationReleaseWrapper applicationReleaseWrapper, ApplicationArtifact applicationArtifact) throws ApplicationManagementException { + return null; + } + + @Test + public boolean updateRelease(String deviceType, String applicationType, String releaseUuid, ApplicationReleaseWrapper applicationReleaseWrapper, ApplicationArtifact applicationArtifact) throws ApplicationManagementException { + return false; + } + + @Test + public void validateAppCreatingRequest(ApplicationWrapper applicationWrapper) throws RequestValidatingException { + + } + + @Test + public void validateReleaseCreatingRequest(ApplicationReleaseWrapper applicationReleaseWrapper, String applicationType) throws RequestValidatingException { + + } + + @Test + public void validateImageArtifacts(Attachment iconFile, Attachment bannerFile, List attachmentList) throws RequestValidatingException { + + } + + @Test + public void validateBinaryArtifact(Attachment binaryFile, String applicationType) throws RequestValidatingException { + + } + + @Test(dependsOnMethods = ("addDeviceVersions")) + public void addApplicationCategories() throws ApplicationManagementException { + List categories = new ArrayList<>(); + categories.add("Test Category"); + categories.add("Test Category2"); + ApplicationManager manager = new ApplicationManagerImpl(); + manager.addApplicationCategories(categories); + + } + + @Test + public void addDeviceVersions() throws ApplicationManagementException { + List deviceTypeVersions = new ArrayList<>(); + List supportingVersions = new ArrayList<>(); + + //add supporting versions + supportingVersions.add("4.0"); + supportingVersions.add("5.0"); + supportingVersions.add("6.0"); + supportingVersions.add("7.0"); + supportingVersions.add("8.0"); + + DeviceManagementProviderServiceImpl deviceManagementProviderService = new DeviceManagementProviderServiceImpl(); + try { + List deviceTypes = deviceManagementProviderService.getDeviceTypes(); + + for (DeviceType deviceType: deviceTypes){ + for (String version : supportingVersions){ + DeviceTypeVersion deviceTypeVersion = new DeviceTypeVersion(); + deviceTypeVersion.setDeviceTypeId(deviceType.getId()); + deviceTypeVersion.setVersionName(version); + deviceTypeVersions.add(deviceTypeVersion); + } + } + + for (DeviceTypeVersion deviceTypeVersion : deviceTypeVersions){ + deviceManagementProviderService.addDeviceTypeVersion(deviceTypeVersion); + } + } catch (DeviceManagementException e) { + String msg = "Error Occured while adding device type versions"; + log.error(msg); + throw new ApplicationManagementException(msg); + } + } + + @Test + public List getRegisteredTags() throws ApplicationManagementException { + return null; + } + + @Test + public List getRegisteredCategories() throws ApplicationManagementException { + return null; + } + + @Test + public void deleteTagMapping(int appId, String tagName) throws ApplicationManagementException { + + } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/admin/ReviewManagementAdminAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/admin/ReviewManagementAdminAPI.java new file mode 100644 index 00000000000..2ed8047ef7e --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/admin/ReviewManagementAdminAPI.java @@ -0,0 +1,313 @@ +/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you 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.wso2.carbon.device.application.mgt.publisher.api.services.admin; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.Extension; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.Info; +import io.swagger.annotations.SwaggerDefinition; +import io.swagger.annotations.Tag; +import org.wso2.carbon.apimgt.annotations.api.Scope; +import org.wso2.carbon.apimgt.annotations.api.Scopes; +import org.wso2.carbon.device.application.mgt.common.ErrorResponse; +import org.wso2.carbon.device.application.mgt.common.PaginationResult; +import org.wso2.carbon.device.application.mgt.common.response.Review; +import org.wso2.carbon.device.application.mgt.common.wrapper.ReviewWrapper; + +import javax.validation.Valid; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.util.List; + +/** +* APIs to handle admin review management related tasks in publisher. +*/ + +@SwaggerDefinition( +info = @Info( + version = "1.0.0", + title = "Publisher Review Management Admin Service", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "name", value = "PublisherReviewManagementAdminService"), + @ExtensionProperty(name = "context", value = "/api/application-mgt/v1.0/admin/review"), + }) + } +), +tags = { + @Tag(name = "review_management", description = "Publisher Review Management related Admin APIs") +} +) +@Scopes( +scopes = { + @Scope( + name = "Update a Review", + description = "Update a Review of applications.", + key = "perm:admin:app:review:update", + permissions = {"/app-mgt/publisher/admin/review/update"} + ), + @Scope( + name = "Get Review Details", + description = "Get review details of applications.", + key = "perm:admin:app:review:view", + permissions = {"/app-mgt/publisher/admin/review/view"} + ) +} +) + +@Path("/admin/reviews") +@Api(value = "Publisher Review Management Admin API") +@Produces(MediaType.APPLICATION_JSON) +public interface ReviewManagementAdminAPI { +String SCOPE = "scope"; + + @PUT + @Path("/{uuid}/{reviewId}") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + produces = MediaType.APPLICATION_JSON, + httpMethod = "PUT", + value = "Edit a review", + notes = "This will edit the review", + tags = "Review Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "perm:admin:app:review:update") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully updated reviewTmp.", + response = Review.class), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Error occurred while updating the new reviewTmp.", + response = ErrorResponse.class) + }) + Response updateReview( + @ApiParam( + name = "reviewTmp", + value = "The review that need to be updated.", + required = true) + @Valid ReviewWrapper updatingReview, + @ApiParam( + name = "uuid", + value = "uuid of the application release", + required = true) + @PathParam("uuid") String uuid, + @ApiParam( + name = "reviewId", + value = "review id of the updating reviewTmp.", + required = true) + @PathParam("reviewId") int reviewId); + + @DELETE + @Path("/{uuid}/{reviewId}") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + produces = MediaType.APPLICATION_JSON, + httpMethod = "DELETE", + value = "Remove review", + notes = "Remove review", + tags = "Review Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "perm:admin:app:review:update") + }) + } + ) + + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully deleted the review"), + @ApiResponse( + code = 404, + message = "Not Found. \n No activity found with the given ID.", + response = ErrorResponse.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Error occurred while deleting the review.", + response = ErrorResponse.class) + }) + + Response deleteReview( + @ApiParam( + name = "uuid", + value = "UUID of the application release.", + required = true) + @PathParam("uuid") String uuid, + @ApiParam( + name = "reviewId", + value = "Id of the review.", + required = true) + @PathParam("reviewId") int reviewId); + + @GET + @Path("/release/{uuid}") + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = "GET", + value = "get app release reviews", + notes = "Get all app release reviews", + tags = "Review Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "perm:admin:app:review:view") + }) + } + ) + + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully retrieved app release reviews.", + response = PaginationResult.class, + responseContainer = "PaginationResult"), + @ApiResponse( + code = 404, + message = "Not Found. \n Not found an application release for requested UUID."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Error occurred while getting the review list.", + response = ErrorResponse.class) + }) + + Response getAllReleaseReviews( + @ApiParam( + name = "uuid", + value = "uuid of the application release.", + required = true) + @PathParam("uuid") String uuid, + @ApiParam( + name = "offset", + value = "Starting review number.", + defaultValue = "0") + @QueryParam("offSet") int offSet, + @ApiParam( + name = "limit", + value = "Limit of paginated reviews", + defaultValue = "20") + @QueryParam("limit") int limit); + + @GET + @Path("/{uuid}/release-rating") + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = "GET", + value = "get ratings", + notes = "Get all ratings", + tags = "Review Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "perm:admin:app:review:view") + }) + } + ) + + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully retrieved ratings.", + response = List.class, + responseContainer = "List"), + @ApiResponse( + code = 404, + message = "Not Found. \n No Application release found for application release UUID.", + response = ErrorResponse.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Error occurred while getting ratings", + response = ErrorResponse.class) + }) + + Response getAppReleaseRating( + @ApiParam( + name = "uuid", + value = "uuid of the application release", + required = true) + @PathParam("uuid") String uuid); + + @GET + @Path("/{uuid}/app-rating") + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = "GET", + value = "get app ratings", + notes = "Get all app ratings", + tags = "Store Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "perm:admin:app:review:view") + }) + } + ) + + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully retrieved ratings.", + response = List.class, + responseContainer = "List"), + @ApiResponse( + code = 404, + message = "Not Found. \n No Application found which has application release of UUID.", + response = ErrorResponse.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Error occurred while getting ratings", + response = ErrorResponse.class) + }) + + Response getAppRating( + @ApiParam( + name = "uuid", + value = "uuid of the application release", + required = true) + @PathParam("uuid") + String uuid); +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/admin/ReviewManagementAdminAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/impl/admin/ReviewManagementAdminAPIImpl.java similarity index 54% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/admin/ReviewManagementAdminAPIImpl.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/impl/admin/ReviewManagementAdminAPIImpl.java index 97bc433e172..f99e014baac 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/admin/ReviewManagementAdminAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/impl/admin/ReviewManagementAdminAPIImpl.java @@ -14,24 +14,30 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.application.mgt.store.api.services.impl.admin; +package org.wso2.carbon.device.application.mgt.publisher.api.services.impl.admin; import io.swagger.annotations.ApiParam; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.application.mgt.common.PaginationRequest; +import org.wso2.carbon.device.application.mgt.common.PaginationResult; +import org.wso2.carbon.device.application.mgt.common.Rating; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; import org.wso2.carbon.device.application.mgt.common.exception.ReviewManagementException; import org.wso2.carbon.device.application.mgt.common.services.ReviewManager; import org.wso2.carbon.device.application.mgt.common.wrapper.ReviewWrapper; import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException; import org.wso2.carbon.device.application.mgt.core.util.APIUtil; -import org.wso2.carbon.device.application.mgt.store.api.services.admin.ReviewManagementAdminAPI; +import org.wso2.carbon.device.application.mgt.publisher.api.services.admin.ReviewManagementAdminAPI; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; /** @@ -99,4 +105,73 @@ public class ReviewManagementAdminAPIImpl implements ReviewManagementAdminAPI { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } } + + @Override + @GET + @Path("/release/{uuid}") + public Response getAllReleaseReviews( + @PathParam("uuid") String uuid, + @DefaultValue("0") @QueryParam("offset") int offSet, + @DefaultValue("20") @QueryParam("limit") int limit) { + ReviewManager reviewManager = APIUtil.getReviewManager(); + PaginationRequest request = new PaginationRequest(offSet, limit); + try { + PaginationResult paginationResult = reviewManager.getAllReleaseReviews(request, uuid); + return Response.status(Response.Status.OK).entity(paginationResult).build(); + } catch (NotFoundException e) { + String msg = "Couldn't find an application release for UUID: " + uuid; + log.error(msg, e); + return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); + } catch (ReviewManagementException e) { + String msg = "Error occurred while retrieving reviews for application UUID: " + uuid; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } catch (ApplicationManagementException e) { + String msg = "Error occurred while retrieving application release details for application UUID: " + uuid; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } + + @Override + @GET + @Path("/{uuid}/release-rating") + public Response getAppReleaseRating( + @PathParam("uuid") String uuid) { + ReviewManager reviewManager = APIUtil.getReviewManager(); + Rating rating; + try { + rating = reviewManager.getAppReleaseRating(uuid); + } catch (NotFoundException e) { + String msg = "Couldn't found an application release for UUID: " + uuid; + log.error(msg, e); + return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); + } catch (ReviewManagementException | ApplicationManagementException e) { + String msg = "Error occured while getting review data for application release UUID: " + uuid; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } + return Response.status(Response.Status.OK).entity(rating).build(); + } + + @Override + @GET + @Path("/{uuid}/app-rating") + public Response getAppRating( + @PathParam("uuid") String uuid) { + ReviewManager reviewManager = APIUtil.getReviewManager(); + Rating rating; + try { + rating = reviewManager.getAppRating(uuid); + } catch (NotFoundException e) { + String msg = "Couldn't found an application for application release UUID: " + uuid; + log.error(msg, e); + return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); + } catch (ReviewManagementException | ApplicationManagementException e) { + String msg = "Error occured while getting review data for application release UUID: " + uuid; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + } + return Response.status(Response.Status.OK).entity(rating).build(); + } } \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/webapp/WEB-INF/cxf-servlet.xml index 661cc26f85b..6f108fe5143 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -26,6 +26,7 @@ + @@ -55,6 +56,7 @@ + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/ReviewManagementAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/ReviewManagementAPI.java index e840e02a6d3..d72e9e4c275 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/ReviewManagementAPI.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/ReviewManagementAPI.java @@ -49,9 +49,9 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; - /** - * APIs to handle review management related tasks. - */ +/** +* APIs to handle review management related tasks. +*/ @SwaggerDefinition( info = @Info( @@ -60,7 +60,7 @@ import java.util.List; extensions = { @Extension(properties = { @ExtensionProperty(name = "name", value = "ReviewManagementService"), - @ExtensionProperty(name = "context", value = "/api/application-mgt/v1.0/review"), + @ExtensionProperty(name = "context", value = "/api/application-mgt/v1.0/store/review"), }) } ), @@ -92,13 +92,13 @@ public interface ReviewManagementAPI { String SCOPE = "scope"; @GET - @Path("/release/{uuid}") + @Path("/app/user/{uuid}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation( produces = MediaType.APPLICATION_JSON, httpMethod = "GET", - value = "get app release reviews", - notes = "Get all app release reviews", + value = "get app reviews", + notes = "Get all app reviews", tags = "Store Management", extensions = { @Extension(properties = { @@ -111,19 +111,20 @@ public interface ReviewManagementAPI { value = { @ApiResponse( code = 200, - message = "OK. \n Successfully retrieved app release reviews.", + message = "OK. \n Successfully retrieved app reviews.", response = PaginationResult.class, responseContainer = "PaginationResult"), @ApiResponse( code = 404, - message = "Not Found. \n Not found an application release for requested UUID."), + message = "Not Found. \n Not found an application release associated with requested " + + "UUID."), @ApiResponse( code = 500, message = "Internal Server Error. \n Error occurred while getting the review list.", response = ErrorResponse.class) }) - Response getAllReleaseReviews( + Response getUserReviews( @ApiParam( name="uuid", value="uuid of the application release.", @@ -140,105 +141,55 @@ public interface ReviewManagementAPI { defaultValue = "20") @QueryParam("limit") int limit); - @GET - @Path("/app/user/{uuid}") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get app reviews", - notes = "Get all app reviews", - tags = "Store Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:review:view") - }) - } - ) - - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully retrieved app reviews.", - response = PaginationResult.class, - responseContainer = "PaginationResult"), - @ApiResponse( - code = 404, - message = "Not Found. \n Not found an application release associated with requested " - + "UUID."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting the review list.", - response = ErrorResponse.class) + @GET + @Path("/app/{uuid}") + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = "GET", + value = "get app reviews", + notes = "Get all app reviews", + tags = "Store Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "perm:app:review:view") }) + } + ) - Response getUserReviews( - @ApiParam( - name="uuid", - value="uuid of the application release.", - required = true) - @PathParam("uuid") String uuid, - @ApiParam( - name="offset", - value="Starting review number.", - defaultValue = "0") - @QueryParam("offSet") int offSet, - @ApiParam( - name="limit", - value = "Limit of paginated reviews", - defaultValue = "20") - @QueryParam("limit") int limit); - - @GET - @Path("/app/{uuid}") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get app reviews", - notes = "Get all app reviews", - tags = "Store Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:review:view") - }) - } - ) - - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully retrieved app reviews.", - response = PaginationResult.class, - responseContainer = "PaginationResult"), - @ApiResponse( - code = 404, - message = "Not Found. \n Not found an application release associated with requested " - + "UUID."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting the review list.", - response = ErrorResponse.class) - }) + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully retrieved app reviews.", + response = PaginationResult.class, + responseContainer = "PaginationResult"), + @ApiResponse( + code = 404, + message = "Not Found. \n Not found an application release associated with requested " + + "UUID."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Error occurred while getting the review list.", + response = ErrorResponse.class) + }) - Response getAllAppReviews( - @ApiParam( - name="uuid", - value="uuid of the application release.", - required = true) - @PathParam("uuid") String uuid, - @ApiParam( - name="offset", - value="Starting review number.", - defaultValue = "0") - @QueryParam("offSet") int offSet, - @ApiParam( - name="limit", - value = "Limit of paginated reviews", - defaultValue = "20") - @QueryParam("limit") int limit); + Response getAllAppReviews( + @ApiParam( + name="uuid", + value="uuid of the application release.", + required = true) + @PathParam("uuid") String uuid, + @ApiParam( + name="offset", + value="Starting review number.", + defaultValue = "0") + @QueryParam("offSet") int offSet, + @ApiParam( + name="limit", + value = "Limit of paginated reviews", + defaultValue = "20") + @QueryParam("limit") int limit); @POST @Path("/{uuid}") @@ -442,13 +393,13 @@ public interface ReviewManagementAPI { @PathParam("reviewId") int reviewId); @GET - @Path("/{uuid}/release-rating") + @Path("/{uuid}/app-rating") @Produces(MediaType.APPLICATION_JSON) @ApiOperation( produces = MediaType.APPLICATION_JSON, httpMethod = "GET", - value = "get ratings", - notes = "Get all ratings", + value = "get app ratings", + notes = "Get all app ratings", tags = "Store Management", extensions = { @Extension(properties = { @@ -466,7 +417,7 @@ public interface ReviewManagementAPI { responseContainer = "List"), @ApiResponse( code = 404, - message = "Not Found. \n No Application release found for application release UUID.", + message = "Not Found. \n No Application found which has application release of UUID.", response = ErrorResponse.class), @ApiResponse( code = 500, @@ -474,52 +425,11 @@ public interface ReviewManagementAPI { response = ErrorResponse.class) }) - Response getAppReleaseRating( + Response getAppRating( @ApiParam( name = "uuid", value = "uuid of the application release", required = true) @PathParam("uuid") String uuid); - - @GET - @Path("/{uuid}/app-rating") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get app ratings", - notes = "Get all app ratings", - tags = "Store Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:app:review:view") - }) - } - ) - - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully retrieved ratings.", - response = List.class, - responseContainer = "List"), - @ApiResponse( - code = 404, - message = "Not Found. \n No Application found which has application release of UUID.", - response = ErrorResponse.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting ratings", - response = ErrorResponse.class) - }) - - Response getAppRating( - @ApiParam( - name = "uuid", - value = "uuid of the application release", - required = true) - @PathParam("uuid") - String uuid); } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/admin/ReviewManagementAdminAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/admin/ReviewManagementAdminAPI.java deleted file mode 100644 index 471924a1228..00000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/admin/ReviewManagementAdminAPI.java +++ /dev/null @@ -1,174 +0,0 @@ -/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. licenses this file to you 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.wso2.carbon.device.application.mgt.store.api.services.admin; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; -import org.wso2.carbon.apimgt.annotations.api.Scope; -import org.wso2.carbon.apimgt.annotations.api.Scopes; -import org.wso2.carbon.device.application.mgt.common.ErrorResponse; -import org.wso2.carbon.device.application.mgt.common.response.Review; -import org.wso2.carbon.device.application.mgt.common.wrapper.ReviewWrapper; - -import javax.validation.Valid; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -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; - -/** -* APIs to handle review management related tasks. -*/ - -@SwaggerDefinition( -info = @Info( - version = "1.0.0", - title = "Review Management Admin Service", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = "name", value = "ReviewManagementAdminService"), - @ExtensionProperty(name = "context", value = "/api/application-mgt/v1.0/admin/review"), - }) - } -), -tags = { - @Tag(name = "review_management", description = "Review Management related Admin APIs") -} -) -@Scopes( -scopes = { - @Scope( - name = "Update a Review", - description = "Update a Review from the application store.", - key = "perm:admin:app:review:update", - permissions = {"/app-mgt/store/admin/review/update"} - ) -} -) - -@Path("/admin/reviews") -@Api(value = "Review Management Admin API") -@Produces(MediaType.APPLICATION_JSON) -public interface ReviewManagementAdminAPI { -String SCOPE = "scope"; - -@PUT -@Path("/{uuid}/{reviewId}") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -@ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "PUT", - value = "Edit a reviewTmp", - notes = "This will edit the reviewTmp", - tags = "Store Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:admin:app:review:update") - }) - } -) -@ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully updated reviewTmp.", - response = Review.class), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while updating the new reviewTmp.", - response = ErrorResponse.class) - }) -Response updateReview( - @ApiParam( - name = "reviewTmp", - value = "The reviewTmp that need to be updated.", - required = true) - @Valid ReviewWrapper updatingReview, - @ApiParam( - name = "uuid", - value = "uuid of the application release", - required = true) - @PathParam("uuid") String uuid, - @ApiParam( - name = "reviewId", - value = "reviewTmp id of the updating reviewTmp.", - required = true) - @PathParam("reviewId") int reviewId); - -@DELETE -@Path("/{uuid}/{reviewId}") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -@ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "DELETE", - value = "Remove comment", - notes = "Remove comment", - tags = "Store Management", - extensions = { - @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:admin:app:review:update") - }) - } -) - -@ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully deleted the review"), - @ApiResponse( - code = 404, - message = "Not Found. \n No activity found with the given ID.", - response = ErrorResponse.class), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while deleting the review.", - response = ErrorResponse.class) - }) - -Response deleteReview( - @ApiParam( - name = "uuid", - value = "UUID of the application release.", - required = true) - @PathParam("uuid") String uuid, - @ApiParam(name = "reviewId", - value = "Id of the review.", - required = true) - @PathParam("reviewId") int reviewId); - - -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/ReviewManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/ReviewManagementAPIImpl.java index b35c00efd5c..f4293bb00f0 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/ReviewManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/java/org/wso2/carbon/device/application/mgt/store/api/services/impl/ReviewManagementAPIImpl.java @@ -53,33 +53,6 @@ public class ReviewManagementAPIImpl implements ReviewManagementAPI { private static Log log = LogFactory.getLog(ReviewManagementAPIImpl.class); - @Override - @GET - @Path("/release/{uuid}") - public Response getAllReleaseReviews( - @PathParam("uuid") String uuid, - @DefaultValue("0") @QueryParam("offset") int offSet, - @DefaultValue("20") @QueryParam("limit") int limit) { - ReviewManager reviewManager = APIUtil.getReviewManager(); - PaginationRequest request = new PaginationRequest(offSet, limit); - try { - PaginationResult paginationResult = reviewManager.getAllReleaseReviews(request, uuid); - return Response.status(Response.Status.OK).entity(paginationResult).build(); - } catch (NotFoundException e) { - String msg = "Couldn't find an application release for UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ReviewManagementException e) { - String msg = "Error occurred while retrieving reviews for application UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (ApplicationManagementException e) { - String msg = "Error occurred while retrieving application release details for application UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - @Override @GET @Path("/app/user/{uuid}") @@ -281,27 +254,6 @@ public class ReviewManagementAPIImpl implements ReviewManagementAPI { } } - @Override - @GET - @Path("/{uuid}/release-rating") - public Response getAppReleaseRating( - @PathParam("uuid") String uuid) { - ReviewManager reviewManager = APIUtil.getReviewManager(); - Rating rating; - try { - rating = reviewManager.getAppReleaseRating(uuid); - } catch (NotFoundException e) { - String msg = "Couldn't found an application release for UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); - } catch (ReviewManagementException | ApplicationManagementException e) { - String msg = "Error occured while getting review data for application release UUID: " + uuid; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } - return Response.status(Response.Status.OK).entity(rating).build(); - } - @Override @GET @Path("/{uuid}/app-rating") diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/webapp/WEB-INF/cxf-servlet.xml index da49a119c7e..da9e97cceab 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -26,7 +26,6 @@ - @@ -56,7 +55,6 @@ - diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml index 11ce3c44c09..2e58edcc37d 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml @@ -154,6 +154,7 @@ perm:app:subscription:install perm:app:subscription:uninstall perm:admin:app:review:update + perm:admin:app:review:view perm:admin:app:publisher:update