mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge branch 'application-mgt-new' into 'application-mgt-new'
Improve app release getting and review delete functionalities See merge request entgra/carbon-device-mgt!170
This commit is contained in:
commit
ded64aa1a5
@ -134,6 +134,8 @@ public interface ApplicationDAO {
|
|||||||
*/
|
*/
|
||||||
ApplicationDTO getApplication(String releaseUuid, int tenantId) throws ApplicationManagementDAOException;
|
ApplicationDTO getApplication(String releaseUuid, int tenantId) throws ApplicationManagementDAOException;
|
||||||
|
|
||||||
|
ApplicationDTO getAppWithRelatedRelease(String releaseUuid, int tenantId) throws ApplicationManagementDAOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify whether application exist for given application name and device type. Because a name and device type is
|
* Verify whether application exist for given application name and device type. Because a name and device type is
|
||||||
* unique for an application.
|
* unique for an application.
|
||||||
|
|||||||
@ -407,6 +407,79 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApplicationDTO getAppWithRelatedRelease(String releaseUuid, int tenantId)
|
||||||
|
throws ApplicationManagementDAOException {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Getting application and releated application release for the release UUID: " + releaseUuid +
|
||||||
|
" from the database");
|
||||||
|
}
|
||||||
|
String sql = "SELECT "
|
||||||
|
+ "AP_APP.ID AS APP_ID, "
|
||||||
|
+ "AP_APP.NAME AS APP_NAME, "
|
||||||
|
+ "AP_APP.DESCRIPTION AS APP_DESCRIPTION, "
|
||||||
|
+ "AP_APP.TYPE AS APP_TYPE, "
|
||||||
|
+ "AP_APP.STATUS AS APP_STATUS, "
|
||||||
|
+ "AP_APP.SUB_TYPE AS APP_SUB_TYPE, "
|
||||||
|
+ "AP_APP.CURRENCY AS APP_CURRENCY, "
|
||||||
|
+ "AP_APP.RATING AS APP_RATING, "
|
||||||
|
+ "AP_APP.DEVICE_TYPE_ID AS APP_DEVICE_TYPE_ID, "
|
||||||
|
+ "AP_APP_RELEASE.ID AS RELEASE_ID, "
|
||||||
|
+ "AP_APP_RELEASE.DESCRIPTION AS RELEASE_DESCRIPTION, "
|
||||||
|
+ "AP_APP_RELEASE.VERSION AS RELEASE_VERSION, "
|
||||||
|
+ "AP_APP_RELEASE.UUID AS RELEASE_UUID, "
|
||||||
|
+ "AP_APP_RELEASE.RELEASE_TYPE AS RELEASE_TYPE, "
|
||||||
|
+ "AP_APP_RELEASE.INSTALLER_LOCATION AS AP_RELEASE_STORED_LOC, "
|
||||||
|
+ "AP_APP_RELEASE.ICON_LOCATION AS AP_RELEASE_ICON_LOC, "
|
||||||
|
+ "AP_APP_RELEASE.BANNER_LOCATION AS AP_RELEASE_BANNER_LOC, "
|
||||||
|
+ "AP_APP_RELEASE.SC_1_LOCATION AS AP_RELEASE_SC1, "
|
||||||
|
+ "AP_APP_RELEASE.SC_2_LOCATION AS AP_RELEASE_SC2, "
|
||||||
|
+ "AP_APP_RELEASE.SC_3_LOCATION AS AP_RELEASE_SC3, "
|
||||||
|
+ "AP_APP_RELEASE.APP_HASH_VALUE AS RELEASE_HASH_VALUE, "
|
||||||
|
+ "AP_APP_RELEASE.APP_PRICE AS RELEASE_PRICE, "
|
||||||
|
+ "AP_APP_RELEASE.APP_META_INFO AS RELEASE_META_INFO, "
|
||||||
|
+ "AP_APP_RELEASE.PACKAGE_NAME AS PACKAGE_NAME, "
|
||||||
|
+ "AP_APP_RELEASE.SUPPORTED_OS_VERSIONS AS RELEASE_SUP_OS_VERSIONS, "
|
||||||
|
+ "AP_APP_RELEASE.RATING AS RELEASE_RATING, "
|
||||||
|
+ "AP_APP_RELEASE.CURRENT_STATE AS RELEASE_CURRENT_STATE, "
|
||||||
|
+ "AP_APP_RELEASE.RATED_USERS AS RATED_USER_COUNT "
|
||||||
|
+ "FROM AP_APP "
|
||||||
|
+ "INNER JOIN AP_APP_RELEASE ON "
|
||||||
|
+ "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID AND "
|
||||||
|
+ "AP_APP.TENANT_ID = AP_APP_RELEASE.TENANT_ID "
|
||||||
|
+ "WHERE "
|
||||||
|
+ "AP_APP_RELEASE.UUID = ? "
|
||||||
|
+ "AND AP_APP.TENANT_ID = ?";
|
||||||
|
try {
|
||||||
|
Connection conn = this.getDBConnection();
|
||||||
|
try (PreparedStatement stmt = conn.prepareStatement(sql)){
|
||||||
|
stmt.setString(1, releaseUuid);
|
||||||
|
stmt.setInt(2, tenantId);
|
||||||
|
try (ResultSet rs = stmt.executeQuery()) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Successfully retrieved basic details of the application and related application "
|
||||||
|
+ "release for the application release which has UUID: " + releaseUuid);
|
||||||
|
}
|
||||||
|
return DAOUtil.loadApplication(rs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (DBConnectionException e) {
|
||||||
|
String msg = "Error occurred while obtaining the DB connection to get application and related application "
|
||||||
|
+ "release for release UUID: " + releaseUuid;
|
||||||
|
log.error(msg);
|
||||||
|
throw new ApplicationManagementDAOException(msg, e);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg = "Error occurred while getting application and related app release details for app release "
|
||||||
|
+ "uuid " + releaseUuid + " while executing query. Executed query: " + sql;
|
||||||
|
log.error(msg);
|
||||||
|
throw new ApplicationManagementDAOException(msg, e);
|
||||||
|
} catch (UnexpectedServerErrorException e) {
|
||||||
|
String msg = "Found more than one application for application release UUID: " + releaseUuid;
|
||||||
|
log.error(msg);
|
||||||
|
throw new ApplicationManagementDAOException(msg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationDTO getApplication(int applicationId, int tenantId)
|
public ApplicationDTO getApplication(int applicationId, int tenantId)
|
||||||
throws ApplicationManagementDAOException {
|
throws ApplicationManagementDAOException {
|
||||||
@ -1003,12 +1076,12 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Request received in DAO Layer to get tag for given tag name.");
|
log.debug("Request received in DAO Layer to get tag for given tag name.");
|
||||||
}
|
}
|
||||||
|
String sql = "SELECT AP_APP_TAG.ID AS ID"
|
||||||
|
+ " FROM AP_APP_TAG "
|
||||||
|
+ "WHERE AP_APP_TAG.TAG = ? AND "
|
||||||
|
+ "AP_APP_TAG.TENANT_ID = ?";
|
||||||
try {
|
try {
|
||||||
Connection conn = this.getDBConnection();
|
Connection conn = this.getDBConnection();
|
||||||
String sql = "SELECT AP_APP_TAG.ID AS ID"
|
|
||||||
+ " FROM AP_APP_TAG "
|
|
||||||
+ "WHERE AP_APP_TAG.TAG = ? AND "
|
|
||||||
+ "AP_APP_TAG.TENANT_ID = ?";
|
|
||||||
try (PreparedStatement ps = conn.prepareStatement(sql)) {
|
try (PreparedStatement ps = conn.prepareStatement(sql)) {
|
||||||
ps.setString(1, tagName);
|
ps.setString(1, tagName);
|
||||||
ps.setInt(2, tenantId);
|
ps.setInt(2, tenantId);
|
||||||
@ -1023,11 +1096,12 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
} catch (DBConnectionException e) {
|
} catch (DBConnectionException e) {
|
||||||
String msg = "Error occurred while obtaining the DB connection when getting tag for given tag name";
|
String msg = "Error occurred while obtaining the DB connection when getting tag for given tag name: "
|
||||||
|
+ tagName;
|
||||||
log.error(msg);
|
log.error(msg);
|
||||||
throw new ApplicationManagementDAOException(msg, e);
|
throw new ApplicationManagementDAOException(msg, e);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
String msg = "SQL Error occurred while getting tag for tag name.";
|
String msg = "SQL Error occurred while getting tag for tag name: " + tagName + ". Executed query: " + sql;
|
||||||
throw new ApplicationManagementDAOException(msg, e);
|
throw new ApplicationManagementDAOException(msg, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1037,10 +1111,10 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Request received in DAO Layer to get distinct tag ids in tag mapping.");
|
log.debug("Request received in DAO Layer to get distinct tag ids in tag mapping.");
|
||||||
}
|
}
|
||||||
|
String sql = "SELECT DISTINCT tm.AP_APP_TAG_ID AS ID FROM AP_APP_TAG_MAPPING tm";
|
||||||
try {
|
try {
|
||||||
Connection conn = this.getDBConnection();
|
Connection conn = this.getDBConnection();
|
||||||
List<Integer> distinctTagIds = new ArrayList<>();
|
List<Integer> distinctTagIds = new ArrayList<>();
|
||||||
String sql = "SELECT DISTINCT tm.AP_APP_TAG_ID AS ID FROM AP_APP_TAG_MAPPING tm";
|
|
||||||
try (PreparedStatement ps = conn.prepareStatement(sql)) {
|
try (PreparedStatement ps = conn.prepareStatement(sql)) {
|
||||||
try (ResultSet rs = ps.executeQuery()) {
|
try (ResultSet rs = ps.executeQuery()) {
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
@ -1050,16 +1124,23 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
|
|||||||
}
|
}
|
||||||
return distinctTagIds;
|
return distinctTagIds;
|
||||||
} catch (DBConnectionException e) {
|
} catch (DBConnectionException e) {
|
||||||
throw new ApplicationManagementDAOException(
|
String msg = "Error occurred while obtaining the DB connection when getting distinct tag ids in tag "
|
||||||
"Error occurred while obtaining the DB connection when getting distinct tag ids in tag mapping", e);
|
+ "mapping";
|
||||||
|
log.error(msg);
|
||||||
|
throw new ApplicationManagementDAOException(msg, e);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new ApplicationManagementDAOException("Error occurred while getting distinct tag ids in tag mapping", e);
|
String msg = "SQL Error occurred while getting distinct tag ids in tag mapping. Executed query: " + sql;
|
||||||
|
log.error(msg);
|
||||||
|
throw new ApplicationManagementDAOException(msg, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTagMapping (List<Integer> tagIds, int applicationId, int tenantId) throws ApplicationManagementDAOException {
|
@Override
|
||||||
|
public void addTagMapping(List<Integer> tagIds, int applicationId, int tenantId)
|
||||||
|
throws ApplicationManagementDAOException {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Request received in DAO Layer to add tags");
|
log.debug("Request received in DAO Layer to add application tags which has application ID: "
|
||||||
|
+ applicationId);
|
||||||
}
|
}
|
||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
|
|||||||
@ -951,8 +951,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
ConnectionManagerUtil.openDBConnection();
|
ConnectionManagerUtil.openDBConnection();
|
||||||
ApplicationDTO applicationDTO = applicationDAO.getApplication(releaseUuid, tenantId);
|
ApplicationDTO applicationDTO = applicationDAO.getAppWithRelatedRelease(releaseUuid, tenantId);
|
||||||
|
|
||||||
if (applicationDTO == null) {
|
if (applicationDTO == null) {
|
||||||
String msg = "Couldn't found an application for application release UUID: " + releaseUuid;
|
String msg = "Couldn't found an application for application release UUID: " + releaseUuid;
|
||||||
log.error(msg);
|
log.error(msg);
|
||||||
@ -1399,7 +1398,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
ConnectionManagerUtil.beginDBTransaction();
|
ConnectionManagerUtil.beginDBTransaction();
|
||||||
ApplicationDTO applicationDTO = this.applicationDAO.getApplication(releaseUuid, tenantId);
|
ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(releaseUuid, tenantId);
|
||||||
if (applicationDTO == null) {
|
if (applicationDTO == null) {
|
||||||
String msg = "Couldn't found an application which has application release for UUID: " + releaseUuid;
|
String msg = "Couldn't found an application which has application release for UUID: " + releaseUuid;
|
||||||
log.error(msg);
|
log.error(msg);
|
||||||
@ -2290,7 +2289,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
try {
|
try {
|
||||||
ConnectionManagerUtil.beginDBTransaction();
|
ConnectionManagerUtil.beginDBTransaction();
|
||||||
ApplicationDTO applicationDTO = this.applicationDAO.getApplication(releaseUuid, tenantId);
|
ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(releaseUuid, tenantId);
|
||||||
|
|
||||||
AtomicReference<ApplicationReleaseDTO> applicationReleaseDTO = new AtomicReference<>(
|
AtomicReference<ApplicationReleaseDTO> applicationReleaseDTO = new AtomicReference<>(
|
||||||
applicationDTO.getApplicationReleaseDTOs().get(0));
|
applicationDTO.getApplicationReleaseDTOs().get(0));
|
||||||
@ -2356,7 +2355,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
try {
|
try {
|
||||||
ConnectionManagerUtil.beginDBTransaction();
|
ConnectionManagerUtil.beginDBTransaction();
|
||||||
ApplicationDTO applicationDTO = this.applicationDAO.getApplication(releaseUuid, tenantId);
|
ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(releaseUuid, tenantId);
|
||||||
validateAppReleaseUpdating(applicationDTO, ApplicationType.PUBLIC.toString());
|
validateAppReleaseUpdating(applicationDTO, ApplicationType.PUBLIC.toString());
|
||||||
AtomicReference<ApplicationReleaseDTO> applicationReleaseDTO = new AtomicReference<>(
|
AtomicReference<ApplicationReleaseDTO> applicationReleaseDTO = new AtomicReference<>(
|
||||||
applicationDTO.getApplicationReleaseDTOs().get(0));
|
applicationDTO.getApplicationReleaseDTOs().get(0));
|
||||||
@ -2423,7 +2422,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
try {
|
try {
|
||||||
ConnectionManagerUtil.beginDBTransaction();
|
ConnectionManagerUtil.beginDBTransaction();
|
||||||
ApplicationDTO applicationDTO = this.applicationDAO.getApplication(releaseUuid, tenantId);
|
ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(releaseUuid, tenantId);
|
||||||
validateAppReleaseUpdating(applicationDTO, ApplicationType.WEB_CLIP.toString());
|
validateAppReleaseUpdating(applicationDTO, ApplicationType.WEB_CLIP.toString());
|
||||||
AtomicReference<ApplicationReleaseDTO> applicationReleaseDTO = new AtomicReference<>(
|
AtomicReference<ApplicationReleaseDTO> applicationReleaseDTO = new AtomicReference<>(
|
||||||
applicationDTO.getApplicationReleaseDTOs().get(0));
|
applicationDTO.getApplicationReleaseDTOs().get(0));
|
||||||
@ -2851,7 +2850,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
try {
|
try {
|
||||||
ConnectionManagerUtil.openDBConnection();
|
ConnectionManagerUtil.openDBConnection();
|
||||||
ApplicationDTO applicationDTO = this.applicationDAO.getApplication(releaseUuid, tenantId);
|
ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(releaseUuid, tenantId);
|
||||||
if (applicationDTO == null) {
|
if (applicationDTO == null) {
|
||||||
String msg = "Couldn't find application for the release UUID: " + releaseUuid;
|
String msg = "Couldn't find application for the release UUID: " + releaseUuid;
|
||||||
log.error(msg);
|
log.error(msg);
|
||||||
|
|||||||
@ -296,7 +296,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|||||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
||||||
try {
|
try {
|
||||||
ConnectionManagerUtil.openDBConnection();
|
ConnectionManagerUtil.openDBConnection();
|
||||||
applicationDTO = this.applicationDAO.getApplication(uuid, tenantId);
|
applicationDTO = this.applicationDAO.getAppWithRelatedRelease(uuid, tenantId);
|
||||||
if (applicationDTO == null) {
|
if (applicationDTO == null) {
|
||||||
String msg = "Couldn't fond an application for application release UUID: " + uuid;
|
String msg = "Couldn't fond an application for application release UUID: " + uuid;
|
||||||
log.error(msg);
|
log.error(msg);
|
||||||
|
|||||||
@ -57,7 +57,7 @@ info = @Info(
|
|||||||
extensions = {
|
extensions = {
|
||||||
@Extension(properties = {
|
@Extension(properties = {
|
||||||
@ExtensionProperty(name = "name", value = "PublisherReviewManagementAdminService"),
|
@ExtensionProperty(name = "name", value = "PublisherReviewManagementAdminService"),
|
||||||
@ExtensionProperty(name = "context", value = "/api/application-mgt/v1.0/admin/review"),
|
@ExtensionProperty(name = "context", value = "/api/application-mgt-publisher/v1.0/admin/review"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
@ -85,54 +85,9 @@ scopes = {
|
|||||||
@Path("/admin/reviews")
|
@Path("/admin/reviews")
|
||||||
@Api(value = "Publisher Review Management Admin API")
|
@Api(value = "Publisher Review Management Admin API")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public interface ReviewManagementAdminAPI {
|
public interface ReviewManagementPublisherAdminAPI {
|
||||||
String SCOPE = "scope";
|
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);
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/release/{uuid}")
|
@Path("/release/{uuid}")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.publisher.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.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.device.application.mgt.common.PaginationRequest;
|
import org.wso2.carbon.device.application.mgt.common.PaginationRequest;
|
||||||
@ -25,16 +24,12 @@ 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.ApplicationManagementException;
|
||||||
import org.wso2.carbon.device.application.mgt.common.exception.ReviewManagementException;
|
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.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.exception.NotFoundException;
|
||||||
import org.wso2.carbon.device.application.mgt.core.util.APIUtil;
|
import org.wso2.carbon.device.application.mgt.core.util.APIUtil;
|
||||||
import org.wso2.carbon.device.application.mgt.publisher.api.services.admin.ReviewManagementAdminAPI;
|
import org.wso2.carbon.device.application.mgt.publisher.api.services.admin.ReviewManagementPublisherAdminAPI;
|
||||||
|
|
||||||
import javax.ws.rs.Consumes;
|
|
||||||
import javax.ws.rs.DELETE;
|
|
||||||
import javax.ws.rs.DefaultValue;
|
import javax.ws.rs.DefaultValue;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.PUT;
|
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.QueryParam;
|
import javax.ws.rs.QueryParam;
|
||||||
@ -44,35 +39,9 @@ import javax.ws.rs.core.Response;
|
|||||||
* Review Management related jax-rs APIs.
|
* Review Management related jax-rs APIs.
|
||||||
*/
|
*/
|
||||||
@Path("/admin/reviews")
|
@Path("/admin/reviews")
|
||||||
public class ReviewManagementAdminAPIImpl implements ReviewManagementAdminAPI {
|
public class ReviewManagementPublisherAdminAPIImpl implements ReviewManagementPublisherAdminAPI {
|
||||||
|
|
||||||
private static Log log = LogFactory.getLog(ReviewManagementAdminAPIImpl.class);
|
private static Log log = LogFactory.getLog(ReviewManagementPublisherAdminAPIImpl.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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@GET
|
@GET
|
||||||
@ -56,7 +56,7 @@
|
|||||||
|
|
||||||
<bean id="applicationMgtServiceBean" class="org.wso2.carbon.device.application.mgt.publisher.api.services.impl.ApplicationManagementPublisherAPIImpl"/>
|
<bean id="applicationMgtServiceBean" class="org.wso2.carbon.device.application.mgt.publisher.api.services.impl.ApplicationManagementPublisherAPIImpl"/>
|
||||||
<bean id="applicationMgtAdminServiceBean" class="org.wso2.carbon.device.application.mgt.publisher.api.services.impl.admin.ApplicationManagementPublisherAdminAPIImpl"/>
|
<bean id="applicationMgtAdminServiceBean" class="org.wso2.carbon.device.application.mgt.publisher.api.services.impl.admin.ApplicationManagementPublisherAdminAPIImpl"/>
|
||||||
<bean id="reviewMgtAdminServiceBean" class="org.wso2.carbon.device.application.mgt.publisher.api.services.impl.admin.ReviewManagementAdminAPIImpl" />
|
<bean id="reviewMgtAdminServiceBean" class="org.wso2.carbon.device.application.mgt.publisher.api.services.impl.admin.ReviewManagementPublisherAdminAPIImpl" />
|
||||||
<bean id="jsonProvider" class="org.wso2.carbon.device.application.mgt.addons.JSONMessageHandler"/>
|
<bean id="jsonProvider" class="org.wso2.carbon.device.application.mgt.addons.JSONMessageHandler"/>
|
||||||
<bean id="multipartProvider" class="org.wso2.carbon.device.application.mgt.addons.MultipartCustomProvider"/>
|
<bean id="multipartProvider" class="org.wso2.carbon.device.application.mgt.addons.MultipartCustomProvider"/>
|
||||||
|
|
||||||
|
|||||||
@ -53,7 +53,7 @@ import javax.ws.rs.core.Response;
|
|||||||
extensions = {
|
extensions = {
|
||||||
@Extension(properties = {
|
@Extension(properties = {
|
||||||
@ExtensionProperty(name = "name", value = "ApplicationStorageManagementService"),
|
@ExtensionProperty(name = "name", value = "ApplicationStorageManagementService"),
|
||||||
@ExtensionProperty(name = "context", value = "/api/application-mgt/v1.0/store-applications"),
|
@ExtensionProperty(name = "context", value = "/api/application-mgt-store/v1.0/store-applications"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
|||||||
@ -60,7 +60,7 @@ import java.util.List;
|
|||||||
extensions = {
|
extensions = {
|
||||||
@Extension(properties = {
|
@Extension(properties = {
|
||||||
@ExtensionProperty(name = "name", value = "ReviewManagementService"),
|
@ExtensionProperty(name = "name", value = "ReviewManagementService"),
|
||||||
@ExtensionProperty(name = "context", value = "/api/application-mgt/v1.0/store/review"),
|
@ExtensionProperty(name = "context", value = "/api/application-mgt-store/v1.0/store/review"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
|||||||
@ -49,7 +49,7 @@ import java.util.List;
|
|||||||
extensions = {
|
extensions = {
|
||||||
@Extension(properties = {
|
@Extension(properties = {
|
||||||
@ExtensionProperty(name = "name", value = "SubscriptionManagementService"),
|
@ExtensionProperty(name = "name", value = "SubscriptionManagementService"),
|
||||||
@ExtensionProperty(name = "context", value = "/api/application-mgt/v1.0/subscription"),
|
@ExtensionProperty(name = "context", value = "/api/application-mgt-store/v1.0/subscription"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
|||||||
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
<jaxrs:server id="applicationMgtService" address="/">
|
<jaxrs:server id="applicationMgtService" address="/">
|
||||||
<jaxrs:serviceBeans>
|
<jaxrs:serviceBeans>
|
||||||
|
<ref bean="reviewMgtAdminServiceBean"/>
|
||||||
<ref bean="applicationMgtServiceBean"/>
|
<ref bean="applicationMgtServiceBean"/>
|
||||||
<ref bean="reviewMgtServiceBean"/>
|
<ref bean="reviewMgtServiceBean"/>
|
||||||
<ref bean="subscriptionMgtServiceBean"/>
|
<ref bean="subscriptionMgtServiceBean"/>
|
||||||
@ -53,6 +54,7 @@
|
|||||||
<bean id="swaggerWriter" class="io.swagger.jaxrs.listing.SwaggerSerializers" />
|
<bean id="swaggerWriter" class="io.swagger.jaxrs.listing.SwaggerSerializers" />
|
||||||
<bean id="swaggerResource" class="io.swagger.jaxrs.listing.ApiListingResource" />
|
<bean id="swaggerResource" class="io.swagger.jaxrs.listing.ApiListingResource" />
|
||||||
|
|
||||||
|
<bean id="reviewMgtAdminServiceBean" class="org.wso2.carbon.device.application.mgt.store.api.services.impl.admin.ReviewManagementStoreAdminAPIImpl" />
|
||||||
<bean id="applicationMgtServiceBean" class="org.wso2.carbon.device.application.mgt.store.api.services.impl.ApplicationManagementAPIImpl"/>
|
<bean id="applicationMgtServiceBean" class="org.wso2.carbon.device.application.mgt.store.api.services.impl.ApplicationManagementAPIImpl"/>
|
||||||
<bean id="reviewMgtServiceBean" class="org.wso2.carbon.device.application.mgt.store.api.services.impl.ReviewManagementAPIImpl" />
|
<bean id="reviewMgtServiceBean" class="org.wso2.carbon.device.application.mgt.store.api.services.impl.ReviewManagementAPIImpl" />
|
||||||
<bean id="subscriptionMgtServiceBean" class="org.wso2.carbon.device.application.mgt.store.api.services.impl.SubscriptionManagementAPIImpl"/>
|
<bean id="subscriptionMgtServiceBean" class="org.wso2.carbon.device.application.mgt.store.api.services.impl.SubscriptionManagementAPIImpl"/>
|
||||||
|
|||||||
@ -155,6 +155,7 @@
|
|||||||
<Scope>perm:admin:app:review:update</Scope>
|
<Scope>perm:admin:app:review:update</Scope>
|
||||||
<Scope>perm:admin:app:review:view</Scope>
|
<Scope>perm:admin:app:review:view</Scope>
|
||||||
<Scope>perm:admin:app:publisher:update</Scope>
|
<Scope>perm:admin:app:publisher:update</Scope>
|
||||||
|
<Scope>perm:admin:app:review:update</Scope>
|
||||||
</Scopes>
|
</Scopes>
|
||||||
<SSOConfiguration>
|
<SSOConfiguration>
|
||||||
<Issuer>app-mgt</Issuer>
|
<Issuer>app-mgt</Issuer>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user