Improve app release getting and review delete functionalities See merge request entgra/carbon-device-mgt!170merge-requests/171/head
commit
ded64aa1a5
49
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 → components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/admin/ReviewManagementPublisherAdminAPI.java
49
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 → components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/admin/ReviewManagementPublisherAdminAPI.java
37
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 → 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/ReviewManagementPublisherAdminAPIImpl.java
37
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 → 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/ReviewManagementPublisherAdminAPIImpl.java
@ -0,0 +1,121 @@
|
||||
/* 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 javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
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 admin review management related tasks in store.
|
||||
*/
|
||||
|
||||
@SwaggerDefinition(
|
||||
info = @Info(
|
||||
version = "1.0.0",
|
||||
title = "Store Review Management Admin Service",
|
||||
extensions = {
|
||||
@Extension(properties = {
|
||||
@ExtensionProperty(name = "name", value = "StoreReviewManagementAdminService"),
|
||||
@ExtensionProperty(name = "context", value = "/api/application-mgt-store/v1.0/admin/review"),
|
||||
})
|
||||
}
|
||||
),
|
||||
tags = {
|
||||
@Tag(name = "review_management", description = "Store 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/store/admin/review/update"}
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
@Path("/admin/reviews")
|
||||
@Api(value = "Store Review Management Admin API")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public interface ReviewManagementStoreAdminAPI {
|
||||
String SCOPE = "scope";
|
||||
|
||||
@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);
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
/* 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.impl.admin;
|
||||
|
||||
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.core.exception.NotFoundException;
|
||||
import org.wso2.carbon.device.application.mgt.core.util.APIUtil;
|
||||
import org.wso2.carbon.device.application.mgt.store.api.services.admin.ReviewManagementStoreAdminAPI;
|
||||
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
/**
|
||||
* Review Management related jax-rs APIs.
|
||||
*/
|
||||
@Path("/admin/reviews")
|
||||
public class ReviewManagementStoreAdminAPIImpl implements ReviewManagementStoreAdminAPI {
|
||||
|
||||
private static Log log = LogFactory.getLog(ReviewManagementStoreAdminAPIImpl.class);
|
||||
|
||||
@Override
|
||||
@DELETE
|
||||
@Path("/{uuid}/{reviewId}")
|
||||
public Response deleteReview(
|
||||
@PathParam("uuid") String uuid,
|
||||
@PathParam("reviewId") int reviewId) {
|
||||
|
||||
ReviewManager reviewManager = APIUtil.getReviewManager();
|
||||
try {
|
||||
reviewManager.deleteReview(uuid, reviewId, true);
|
||||
return Response.status(Response.Status.OK).entity("Review is deleted successfully.").build();
|
||||
} catch (NotFoundException e) {
|
||||
String msg = "Couldn't found an application review to delete which match with the request.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
|
||||
} catch (ReviewManagementException e) {
|
||||
String msg = "Error occurred while deleting the comment.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
} catch (ApplicationManagementException e) {
|
||||
String msg = "Error occurred while getting application release data.";
|
||||
log.error(msg, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue