diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Application.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Application.java index eb08e78034b..ed0864599dc 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Application.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Application.java @@ -24,7 +24,6 @@ import io.swagger.annotations.ApiModelProperty; import java.util.List; - @ApiModel(value = "Application", description = "Application represents the an Application in Application Store") public class Application { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationRelease.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationRelease.java index 6f451266167..379ef0f691d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationRelease.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationRelease.java @@ -177,7 +177,6 @@ public class ApplicationRelease { this.price = price; } - public String getAppHashValue() { return appHashValue; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/EnterpriseApplication.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/EnterpriseApplication.java index b1b3aac4c1f..0cf6dfb554f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/EnterpriseApplication.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/EnterpriseApplication.java @@ -18,8 +18,6 @@ */ package org.wso2.carbon.device.application.mgt.common; -import com.google.gson.Gson; - import java.io.Serializable; /** diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/FilterProperty.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/FilterProperty.java deleted file mode 100644 index 49d6f2d83fa..00000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/FilterProperty.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.common; - -//TODO - -/** - * FilterProperty defines the property that can be used to filter the Application. - */ -public class FilterProperty { - - /** - * Operators that can be used in search. - */ - public enum Operator { - EQUALS ("="), - GRATER_THAN (">"), - GREATER_THAN_AND_EQUAL(">="), - LESS_THAN ("<"), - LESS_THAN_AND_EQUAL ("<="); - - private final String value; - - Operator(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - } - - public FilterProperty(String key, Operator operator, String value) { - this.key = key; - this.operator = operator; - this.value = value; - } - - private String key; - - private Operator operator; - - private String value; - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public Operator getOperator() { - return operator; - } - - public void setOperator(Operator operator) { - this.operator = operator; - } - -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/LifecycleStateTransition.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/LifecycleStateTransition.java deleted file mode 100644 index 44382599a27..00000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/LifecycleStateTransition.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.wso2.carbon.device.application.mgt.common; - -/** - * This represents the LifeCycleStateTransition from one state to next state. - */ -public class LifecycleStateTransition { - private String nextState; - private String permission; - private String description; - - public String getNextState() { - return nextState; - } - - public String getPermission() { - return permission; - } - - public String getDescription() { - return description; - } - - public void setNextState(String nextState) { - this.nextState = nextState; - } - - public void setPermission(String permission) { - this.permission = permission; - } - - public void setDescription(String description) { - this.description = description; - } -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Payment.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Payment.java deleted file mode 100644 index bbb96fbb306..00000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Payment.java +++ /dev/null @@ -1,53 +0,0 @@ -/* -* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* WSO2 Inc. 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.common; - -/** - * Represents the payment related information for the {@link Application}. - */ -public class Payment { - private boolean freeApp; - - private String paymentCurrency; - - private float paymentPrice; - - public boolean isFreeApp() { - return freeApp; - } - - public void setFreeApp(boolean freeApp) { - this.freeApp = freeApp; - } - - public String getPaymentCurrency() { - return paymentCurrency; - } - - public void setPaymentCurrency(String paymentCurrency) { - this.paymentCurrency = paymentCurrency; - } - - public float getPaymentPrice() { - return paymentPrice; - } - - public void setPaymentPrice(float paymentPrice) { - this.paymentPrice = paymentPrice; - } -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Subscription.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Subscription.java deleted file mode 100644 index 42d942664d2..00000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Subscription.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.common; - -import java.util.Date; - -/** - * Represents subscription of an {@link Application} - */ -public class Subscription { - - private Visibility.Type type; - - private String value; - - private Date createdAt; - - private Application application; - - private ApplicationRelease applicationRelease; - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public Visibility.Type getType() { - return type; - } - - public void setType(Visibility.Type type) { - this.type = type; - } - - public Date getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } - - public Application getApplication() { - return application; - } - - public void setApplication(Application application) { - this.application = application; - } - - public ApplicationRelease getApplicationRelease() { - return applicationRelease; - } - - public void setApplicationRelease(ApplicationRelease applicationRelease) { - this.applicationRelease = applicationRelease; - } -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Visibility.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Visibility.java deleted file mode 100644 index c2992aa6706..00000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Visibility.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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.common; - -import java.util.List; - -/** - * This class represents the visibility details of an Application. - */ -public class Visibility { - - private Type type; - - private List allowedList; - - public Type getType() { - return type; - } - - public void setType(Type type) { - this.type = type; - } - - public List getAllowedList() { - return allowedList; - } - - public void setAllowedList(List allowedList) { - this.allowedList = allowedList; - } - - /** - * Type of the visibility of the application. - */ - public enum Type { - PUBLIC, ROLES, DEVICE_GROUPS - } -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/ReviewDoesNotExistException.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/ReviewDoesNotExistException.java new file mode 100644 index 00000000000..7329f05591d --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/ReviewDoesNotExistException.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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.common.exception; + +public class ReviewDoesNotExistException extends Exception { + private String message; + + public ReviewDoesNotExistException(String message, Throwable throwable) { + super(message, throwable); + setMessage(message); + } + + public ReviewDoesNotExistException(String message) { + super(message); + setMessage(message); + } + + public ReviewDoesNotExistException() { + + } + + @Override public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java index 4df7b50d33a..9eefd339eab 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java @@ -23,10 +23,8 @@ import org.wso2.carbon.device.application.mgt.common.ApplicationList; import org.wso2.carbon.device.application.mgt.common.ApplicationRelease; import org.wso2.carbon.device.application.mgt.common.Filter; import org.wso2.carbon.device.application.mgt.common.LifecycleState; -import org.wso2.carbon.device.application.mgt.common.LifecycleStateTransition; import org.wso2.carbon.device.application.mgt.common.UnrestrictedRole; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; -import org.wso2.carbon.device.application.mgt.common.exception.LifecycleManagementException; import java.util.List; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ReviewManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ReviewManager.java index b8c010fa5a9..43090b158cf 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ReviewManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ReviewManager.java @@ -22,25 +22,29 @@ import org.wso2.carbon.device.application.mgt.common.Rating; import org.wso2.carbon.device.application.mgt.common.Review; 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.exception.RequestValidatingException; +import org.wso2.carbon.device.application.mgt.common.exception.ReviewDoesNotExistException; import org.wso2.carbon.device.application.mgt.common.exception.ReviewManagementException; + + /** * ReviewManager is responsible for handling all the add/update/delete/get operations related with */ public interface ReviewManager { /** - * To add a review to a application + * To add a review to an application release * * @param review review of the application. * @param uuid uuid of the application release. * @return {@link Review} Review added * @throws ReviewManagementException Exceptions of the review management. */ - boolean addReview(Review review, String uuid) throws ReviewManagementException; + boolean addReview(Review review, String uuid) throws ReviewManagementException, RequestValidatingException; /** - * Get all comments to pagination + * Get all review with pagination * * @param request Pagination request {@link PaginationRequest} * @param uuid uuid of the application release @@ -49,15 +53,6 @@ public interface ReviewManager { */ PaginationResult getAllReviews(PaginationRequest request, String uuid) throws ReviewManagementException; - /** - * To get the comment with id. - * - * @param commentId id of the comment - * @return {@link Review}Review of the comment id - * @throws ReviewManagementException Exceptions of the comment management. - */ - Review getReview(int commentId) throws ReviewManagementException; - /** * To delete review using review id. * @@ -66,7 +61,8 @@ public interface ReviewManager { * @return If review is successfully deleted return true, otherwise returns false * @throws ReviewManagementException Exceptions of the comment management */ - boolean deleteReview(String uuid, int commentId) throws ReviewManagementException; + boolean deleteReview(String uuid, int commentId) + throws ReviewManagementException, ReviewDoesNotExistException; /** * To update a review. @@ -74,12 +70,13 @@ public interface ReviewManager { * @param review review of the application. * @param reviewId id of the review * @param uuid UUID of the application release - * @param checkExistence Pass true if it is required to check the existence of the review, otherwise pass false + * @param existingReview Pass existing review when same user adding a review for same application release, + * otherwise pass null * @return {@link Review}updated review * @throws ReviewManagementException Exceptions of the review management */ - boolean updateReview(Review review, int reviewId, String uuid, boolean checkExistence) - throws ReviewManagementException; + boolean updateReview(Review review, int reviewId, String uuid, Review existingReview) + throws ReviewManagementException, RequestValidatingException; /** * To get the overall rating for a application release diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/UnrestrictedRoleManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/UnrestrictedRoleManager.java deleted file mode 100644 index 93b7b3a0c99..00000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/UnrestrictedRoleManager.java +++ /dev/null @@ -1,59 +0,0 @@ -/* -* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* WSO2 Inc. 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.common.services; - -import org.wso2.carbon.device.application.mgt.common.UnrestrictedRole; -import org.wso2.carbon.device.application.mgt.common.Visibility; -import org.wso2.carbon.device.application.mgt.common.exception.VisibilityManagementException; - -import java.util.List; - -/** - * This interface manages all the operations related with Application Visibility. - * This will be invoking the necessary backend calls for the data bases layer - * and provide the functional implementation. - */ -public interface UnrestrictedRoleManager { - - /** - * Add (if there is no visibility configuration for the application) or - * Update (if there is already existing configuration for the application) - * the visibility related configuration for the application - * - * @param applicationID The ID of the application - * @param visibility The visibility configuration for the particular application. - */ - Visibility put(int applicationID, Visibility visibility) throws VisibilityManagementException; - - /** - * Returns the Visibility configuration of the provided applicationUUID. - * - * @param applicationID The ID of the application - * @param tenantId tenant Id - * @return Visibility configuration - */ - List getUnrestrictedRoles(int applicationID, int tenantId) throws VisibilityManagementException; - - /** - * Remove the visibility configuration mapping for the provided application. - * - * @param applicationID The ID of the application - */ - void remove(int applicationID) throws VisibilityManagementException; -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationReleaseDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationReleaseDAO.java index a542dddecd6..1add29c8355 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationReleaseDAO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationReleaseDAO.java @@ -81,19 +81,21 @@ public interface ApplicationReleaseDAO { /** * To update an Application release. - * @param id id of the ApplicationRelease that need to be updated. + * @param uuid UUID of the ApplicationRelease that need to be updated. * @param rating given stars for the application. * @param ratedUsers number of users who has rated for the application release. * @throws ApplicationManagementDAOException Application Management DAO Exception */ - int updateRatingValue(int id, double rating, int ratedUsers) throws ApplicationManagementDAOException; + void updateRatingValue(String uuid, double rating, int ratedUsers) throws ApplicationManagementDAOException; /** * To retrieve rating of an application release. + * * @param uuid UUID of the application Release. + * @param tenantId Tenant Id * @throws ApplicationManagementDAOException Application Management DAO Exception. */ - Rating getRating(String uuid) throws ApplicationManagementDAOException; + Rating getRating(String uuid, int tenantId) throws ApplicationManagementDAOException; /** diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ReviewDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ReviewDAO.java index 69ec7a2abe0..1018bc78b2d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ReviewDAO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ReviewDAO.java @@ -45,7 +45,7 @@ import java.util.List; boolean addReview(Review review, String uuid, int tenantId) throws ReviewManagementDAOException; /** - * To verify whether review is exists or not. + * To verify whether user has already commented for the application release or not. * * @param uuid UUID of the application release. * @param username username of the logged in user. @@ -58,33 +58,33 @@ import java.util.List; /** * To update already added comment. * - * @return {@link Review}Updated comment - * @throws ReviewManagementException Exceptions of the comment management. - * @throws DBConnectionException db connection exception - * @throws SQLException sql exception + * @param review Updating review + * @param reviewId id of the updating review + * @param username review owner + * @param tenantId tenant id + * @return row count if updating is succeed otherwise 0 + * @throws ReviewManagementDAOException Exceptions of the review management. */ - boolean updateReview(Review review, int reviewId, int tenantId) - throws ReviewManagementException, DBConnectionException, SQLException; + int updateReview(Review review, int reviewId, String username, int tenantId) + throws ReviewManagementDAOException; /** * To get the comment with id. * - * @param commentId id of the comment + * @param reviewId id of the review * @return {@link Review}Review - * @throws ReviewManagementException Exceptions of the comment management. - * @throws DBConnectionException db connection exception - * @throws SQLException sql exception + * @throws ReviewManagementDAOException Exceptions of the review management DAO. */ - Review getReview(int commentId) throws ReviewManagementException, SQLException, DBConnectionException; + Review getReview(int reviewId) throws ReviewManagementDAOException; /** - * To get all the comments + * To get all reviews * * @param uuid uuid of the application * @param request {@link PaginationRequest}pagination request with offSet and limit * @param tenantId Tenant id - * @return {@link List}List of all the comments in an application + * @return {@link List}List of all reviews for the application release * @throws ReviewManagementDAOException Review management DAO exception **/ List getAllReviews(String uuid, PaginationRequest request, int tenantId) @@ -92,11 +92,12 @@ import java.util.List; /** * To get list of comments using release id and application id. - * + * @param uuid UUID of the application release + * @param tenantId tenant id * @return {@link List}List of comments - * @throws ReviewManagementException Exceptions of the comment management. + * @throws ReviewManagementDAOException Exceptions of the review management DAO. */ - List getAllRatingValues(String uuid)throws SQLException, DBConnectionException; + List getAllRatingValues(String uuid, int tenantId) throws ReviewManagementDAOException; /** * To get count of comments by application details. @@ -122,15 +123,6 @@ import java.util.List; */ int deleteReview(String username, int reviewId) throws ReviewManagementDAOException; - /** - * To delete review using review id, in this case, it doesn't check whether user is review owner or not. - * - * @param reviewId id of the review - * @return If review is successfully deleted return 1, otherwise returns 0. - * @throws ReviewManagementDAOException Review management DAO exception. - */ - int deleteReviewByAdmin(int reviewId) throws ReviewManagementDAOException; - /** * To delete comments using application details. * @@ -142,12 +134,11 @@ import java.util.List; void deleteReviews(String appType, String appName, String version) throws ReviewManagementException; /** - * To get comment count for pagination + * To get review count for a specific application release * - * @param request pagination request * @param uuid uuid of the application release * @return Review count - * @throws ReviewManagementException + * @throws ReviewManagementDAOException Review management DAO exception */ - int getReviewCount(PaginationRequest request, String uuid) throws ReviewManagementException; + int getReviewCount(String uuid) throws ReviewManagementDAOException; } \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/ApplicationManagementDAOFactory.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/ApplicationManagementDAOFactory.java index 368111b9e08..0c36f071eb8 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/ApplicationManagementDAOFactory.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/ApplicationManagementDAOFactory.java @@ -23,7 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.application.mgt.common.exception.UnsupportedDatabaseEngineException; import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager; import org.wso2.carbon.device.application.mgt.core.dao.*; -import org.wso2.carbon.device.application.mgt.core.dao.impl.Comment.ReviewDAOImpl; +import org.wso2.carbon.device.application.mgt.core.dao.impl.Review.ReviewDAOImpl; import org.wso2.carbon.device.application.mgt.core.dao.impl.application.GenericApplicationDAOImpl; import org.wso2.carbon.device.application.mgt.core.dao.impl.application.release.GenericApplicationReleaseDAOImpl; import org.wso2.carbon.device.application.mgt.core.dao.impl.application.OracleApplicationDAOImpl; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/Comment/ReviewDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/Review/ReviewDAOImpl.java similarity index 76% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/Comment/ReviewDAOImpl.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/Review/ReviewDAOImpl.java index 534ff7a70aa..c1a7a39273a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/Comment/ReviewDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/Review/ReviewDAOImpl.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.device.application.mgt.core.dao.impl.Comment; +package org.wso2.carbon.device.application.mgt.core.dao.impl.Review; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -28,7 +28,6 @@ import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionExcep import org.wso2.carbon.device.application.mgt.core.dao.ReviewDAO; import org.wso2.carbon.device.application.mgt.core.dao.common.Util; import org.wso2.carbon.device.application.mgt.core.dao.impl.AbstractDAOImpl; -import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException; import org.wso2.carbon.device.application.mgt.core.exception.ReviewManagementDAOException; import java.sql.SQLException; @@ -48,14 +47,13 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { private String sql; @Override - public boolean addReview(Review review, String uuid, int tenantId) - throws ReviewManagementDAOException { + public boolean addReview(Review review, String uuid, int tenantId) throws ReviewManagementDAOException { if (log.isDebugEnabled()) { log.debug("Request received in DAO Layer to add review for application release. Application UUID: " + uuid); } PreparedStatement statement = null; ResultSet rs = null; - sql = "INSERT INTO AP_APP_Review (TENANT_ID, COMMENT, PARENT_ID, USERNAME, AP_APP_RELEASE_ID, AP_APP_ID) " + sql = "INSERT INTO AP_APP_REVIEW (TENANT_ID, COMMENT, PARENT_ID, USERNAME, AP_APP_RELEASE_ID, AP_APP_ID) " + "VALUES (?,?,?,?,(SELECT ID FROM AP_APP_RELEASE WHERE UUID= ?)," + "(SELECT AP_APP_ID FROM AP_APP_RELEASE WHERE UUID=?));"; try { @@ -102,7 +100,6 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { statement.setString(1, uuid); statement.setString(2, username); statement.setInt(3, tenantId); - rs = statement.executeQuery(); if (rs.next()){ review = new Review(); @@ -128,7 +125,8 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { } @Override - public boolean updateReview(Review review, int reviewId, int tenantId) throws ReviewManagementException, DBConnectionException, SQLException { + public int updateReview(Review review, int reviewId, String username, int tenantId) + throws ReviewManagementDAOException { if (log.isDebugEnabled()) { log.debug("Request received in DAO Layer to update the comment with ID (" + reviewId + ")"); @@ -136,55 +134,59 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { Connection connection; PreparedStatement statement = null; ResultSet rs = null; - sql = "UPDATE AP_APP_COMMENT SET COMMENT_TEXT=?, MODEFIED_BY=? WHERE ID=?;"; + sql = "UPDATE AP_APP_REVIEW SET COMMENT=?, RATING=? WHERE ID=? AND USERNAME=? AND TENANT_ID=?;"; try { connection = this.getDBConnection(); statement = connection.prepareStatement(sql); -// statement.setString(1, updatedComment); -// statement.setString(2, modifiedBy); + statement.setString(1, review.getComment()); + statement.setInt(2, review.getRating()); statement.setInt(3, reviewId); - statement.executeUpdate(); - rs = statement.executeQuery(); + statement.setString(4, username); + statement.setInt(5, tenantId); + return statement.executeUpdate(); + } catch (SQLException e) { + throw new ReviewManagementDAOException("Error occurred while executing review updating query"); + } catch (DBConnectionException e) { + throw new ReviewManagementDAOException("Error occured while getting the db connection to update review"); } finally { Util.cleanupResources(statement, rs); } - // todo - return false; } @Override - public Review getReview(int commentId) throws ReviewManagementException { + public Review getReview(int reviewId) throws ReviewManagementDAOException { if (log.isDebugEnabled()) { - log.debug("Getting review with the review id(" + commentId + ") from the database"); + log.debug("Getting review with the review id(" + reviewId + ") from the database"); } Connection conn; PreparedStatement statement = null; - ResultSet rs; + ResultSet rs = null; Review review = new Review(); try { conn = this.getDBConnection(); - sql = "SELECT COMMENT_TEXT FROM AP_APP_COMMENT WHERE ID=?;"; + sql = "SELECT ID, COMMENT, CREATED_AT, MODIFIED_AT, RATING, USERNAME FROM AP_APP_REVIEWE WHERE ID=?;"; statement = conn.prepareStatement(sql); - statement.setInt(1, commentId); + statement.setInt(1, reviewId); rs = statement.executeQuery(); if (rs.next()) { review.setId(rs.getInt("ID")); -// review.setTenantId(rs.getInt("TENANT_ID")); - review.setComment(rs.getString("COMMENT_TEXT")); + review.setComment(rs.getString("COMMENT")); review.setCreatedAt(rs.getTimestamp("CREATED_AT")); review.setUsername(rs.getString("CREATED_BY")); - review.setModifiedAt(rs.getTimestamp("MODEFIED_AT")); - Util.cleanupResources(statement, rs); + review.setModifiedAt(rs.getTimestamp("MODIFIED_AT")); + review.setRating(rs.getInt("RATING")); + review.setUsername(rs.getString("USERNAME")); return review; } } catch (SQLException e) { - throw new ReviewManagementException( - "SQL Error occurred while retrieving information of the review " + commentId, e); + throw new ReviewManagementDAOException( + "SQL Error occurred while retrieving information of the review " + reviewId, e); } catch (DBConnectionException e) { - log.error("DB Connection Exception occurred while retrieving information of the review " + commentId, e); + throw new ReviewManagementDAOException( + "DB Connection Exception occurred while retrieving information of the review " + reviewId, e); } finally { - Util.cleanupResources(statement, null); + Util.cleanupResources(statement, rs); } return review; } @@ -202,11 +204,11 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { List reviews = new ArrayList<>(); try { conn = this.getDBConnection(); - sql = "SELECT AP_APP_COMMENT.ID AS ID, AP_APP_COMMENT.COMMENT_TEXT AS COMMENT_TEXT, " - + "AP_APP_COMMENT.CREATED_BY AS CREATED_BY, AP_APP_COMMENT.MODIFIED_BY AS MODIFIED_BY, " - + "AP_APP_COMMENT.PARENT_ID AS PARENT_ID FROM AP_APP_COMMENT, AP_APP_RELEASE WHERE " - + "AP_APP_COMMENT.AP_APP_RELEASE_ID=AP_APP_RELEASE.ID AND AP_APP_RELEASE.UUID =? AND " - + "AP_APP_COMMENT.TENANT_ID = ? AND AP_APP_COMMENT.TENANT_ID = AP_APP_RELEASE.TENANT_ID " + sql = "SELECT AP_APP_REVIEW.ID AS ID, AP_APP_REVIEW.COMMENT AS COMMENT, " + + "AP_APP_REVIEW.CREATED_BY AS CREATED_BY, AP_APP_REVIEW.MODIFIED_BY AS MODIFIED_BY, " + + "AP_APP_REVIEW.PARENT_ID AS PARENT_ID FROM AP_APP_REVIEW, AP_APP_RELEASE WHERE " + + "AP_APP_REVIEW.AP_APP_RELEASE_ID=AP_APP_RELEASE.ID AND AP_APP_RELEASE.UUID =? AND " + + "AP_APP_REVIEW.TENANT_ID = ? AND AP_APP_REVIEW.TENANT_ID = AP_APP_RELEASE.TENANT_ID " + "LIMIT ? OFFSET ?;"; statement = conn.prepareStatement(sql); statement.setString(1, uuid); @@ -233,7 +235,7 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { } @Override - public List getAllRatingValues(String uuid)throws SQLException, DBConnectionException { + public List getAllRatingValues(String uuid, int tenantId) throws ReviewManagementDAOException { if (log.isDebugEnabled()) { log.debug("Getting comment of the application release (" + uuid + ") from the database"); @@ -244,18 +246,24 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { List reviews = new ArrayList<>(); try { conn = this.getDBConnection(); -// todo - sql = "SELECT AP_APP_COMMENT.ID AS ID, AP_APP_COMMENT.COMMENT_TEXT AS " - + "COMMENT_TEXT, AP_APP_COMMENT.CREATED_BY AS CREATED_BY, AP_APP_COMMENT.MODIFIED_BY AS " - + "MODIFIED_BY, AP_APP_COMMENT.PARENT_ID AS PARENT_ID FROM AP_APP_COMMENT, AP_APP_RELEASE WHERE " - + "AP_APP_COMMENT.AP_APP_RELEASE_ID=AP_APP_RELEASE.ID AND AP_APP_RELEASE.UUID =? AND " - + "AP_APP_COMMENT.TENANT_ID = ? AND AP_APP_COMMENT.TENANT_ID = AP_APP_RELEASE.TENANT_ID;"; + sql = "SELECT AP_APP_COMMENT.RATING AS RATING FROM AP_APP_REVIEW, AP_APP_RELEASE WHERE " + + "AP_APP_REVIEW.AP_APP_RELEASE_ID=AP_APP_RELEASE.ID AND AP_APP_RELEASE.UUID =? AND " + + "AP_APP_COMMENT.TENANT_ID = AP_APP_RELEASE.TENANT_ID AND AP_APP_COMMENT.TENANT_ID = ?;"; statement = conn.prepareStatement(sql); statement.setString(1, uuid); + statement.setInt(2, tenantId); rs = statement.executeQuery(); while (rs.next()) { reviews.add(rs.getInt("RATING")); } + } catch (SQLException e) { + throw new ReviewManagementDAOException( + "Error occured while getting all rating values for the application release. App release UUID: " + + uuid, e); + } catch (DBConnectionException e) { + throw new ReviewManagementDAOException( + "Error occured while getting DB connection to retrieve all rating values for the application release. App release UUID: " + + uuid, e); } finally { Util.cleanupResources(statement, rs); } @@ -263,7 +271,7 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { } @Override - public int getReviewCount(PaginationRequest request, String uuid) throws ReviewManagementException { + public int getReviewCount(String uuid) throws ReviewManagementDAOException { int commentCount = 0; Connection conn; @@ -276,20 +284,20 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { isUuidProvided = true; } if (isUuidProvided) { - sql = "SELECT COUNT(AP_APP_COMMENT.ID) FROM AP_APP_COMMENT,AP_APP_RELEASE " - + "WHERE AP_APP_COMMENT.AP_APP_RELEASE_ID= AP_APP_RELEASE.ID AND " - + "AP_APP_COMMENT.AP_APP_ID= AP_APP_RELEASE.AP_APP_ID AND AP_APP_RELEASE.UUID=?;"; + sql = "SELECT COUNT(AP_APP_REVIEW.ID) AS REVIEW_COUNT FROM AP_APP_REVIEW,AP_APP_RELEASE " + + "WHERE AP_APP_REVIEW.AP_APP_RELEASE_ID= AP_APP_RELEASE.ID AND " + + "AP_APP_REVIEW.AP_APP_ID= AP_APP_RELEASE.AP_APP_ID AND AP_APP_RELEASE.UUID=?;"; statement = conn.prepareStatement(sql); statement.setString(1, uuid); rs = statement.executeQuery(); if (rs.next()) { - commentCount = rs.getInt("COMMENTS_COUNT"); + commentCount = rs.getInt("REVIEW_COUNT"); } } } catch (SQLException e) { - throw new ReviewManagementException("SQL Error occurred while retrieving count of comments", e); + throw new ReviewManagementDAOException("SQL Error occurred while retrieving review counts", e); } catch (DBConnectionException e) { - log.error("DB Connection Exception occurred while retrieving count of comments", e); + throw new ReviewManagementDAOException("DB Connection Exception occurred while retrieving review counts", e); } finally { Util.cleanupResources(statement, rs); } @@ -302,8 +310,10 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { Connection conn; PreparedStatement statement = null; + ResultSet rs = null; int commentCount = 0; try { + //todo need to reconstruct the query conn = this.getDBConnection(); sql = "SELECT COUNT(ID) AS COMMENT_COUNT FROM AP_APP_COMMENT C, " + "(SELECT ID AS RELEASE_ID, AP_APP_ID AS RELEASE_AP_APP_ID FROM AP_APP_RELEASE R WHERE VERSION=? )R," @@ -313,12 +323,12 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { statement.setString(1, version); statement.setString(2, appName); statement.setString(3, appType); - ResultSet rs = statement.executeQuery(); + rs = statement.executeQuery(); if (rs.next()) { commentCount = rs.getInt("COMMENT_COUNT"); } } finally { - Util.cleanupResources(statement, null); + Util.cleanupResources(statement, rs); } return commentCount; } @@ -345,33 +355,13 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { } @Override - public int deleteReviewByAdmin(int reviewId) throws ReviewManagementDAOException { - Connection conn; - PreparedStatement statement = null; - try { - conn = this.getDBConnection(); - sql = "DELETE FROM AP_APP_REVIEW WHERE ID=?;"; - statement = conn.prepareStatement(sql); - statement.setInt(1, reviewId); - return statement.executeUpdate(); - } catch (SQLException e) { - throw new ReviewManagementDAOException("Error occured while accessing the Database", e); - } catch (DBConnectionException e) { - throw new ReviewManagementDAOException("Error occured while getting the database connection", e); - - } finally { - Util.cleanupResources(statement, null); - } - } - - @Override - public void deleteReviews(String appType, String appName, String version) - throws ReviewManagementException { + public void deleteReviews(String appType, String appName, String version) throws ReviewManagementException { Connection conn; PreparedStatement statement = null; try { conn = this.getDBConnection(); + //todo need to reconstruct the query, sql = "DELETE FROM AP_APP_COMMENT WHERE " + "(SELECT AP_APP_RELEASE_ID FROM AP_APP_RELEASE WHERE VERSION=? AND " + "(SELECT AP_APP_ID FROM AP_APP WHERE NAME=? AND TYPE=?)) AND " diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java index ecd793fb2d5..bd024baeaad 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java @@ -279,28 +279,28 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements /** * To Update starts of an application release. * - * @param id Id of the application Release. + * @param uuid UUID of the application Release. * @param rating given stars for the application release. * @throws ApplicationManagementDAOException Application Management DAO Exception. */ @Override - public int updateRatingValue(int id, double rating, int ratedUsers) throws ApplicationManagementDAOException { + public void updateRatingValue(String uuid, double rating, int ratedUsers) throws ApplicationManagementDAOException { Connection connection; PreparedStatement statement = null; - String sql = "UPDATE AP_APP_RELEASE SET RATING = ? AND RATED_USERS = ? WHERE ID = ?;"; + String sql = "UPDATE AP_APP_RELEASE SET RATING = ? AND RATED_USERS = ? WHERE UUID = ?;"; try { connection = this.getDBConnection(); statement = connection.prepareStatement(sql); statement.setDouble(1, rating); statement.setInt(2, ratedUsers); - statement.setInt(2, id); - return statement.executeUpdate(); + statement.setString(3, uuid); + statement.executeUpdate(); } catch (DBConnectionException e) { throw new ApplicationManagementDAOException( - "Database connection exception while trying to update the application release", e); + "Database connection exception while trying to update the application release rating value", e); } catch (SQLException e) { throw new ApplicationManagementDAOException( - "SQL exception while updating the release ,while executing the query " + sql, e); + "SQL exception while updating the release rating value ,while executing the query " + sql, e); } finally { Util.cleanupResources(statement, null); } @@ -313,16 +313,17 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements * @throws ApplicationManagementDAOException Application Management DAO Exception. */ @Override - public Rating getRating(String uuid) throws ApplicationManagementDAOException { + public Rating getRating(String uuid, int tenantId) throws ApplicationManagementDAOException { Connection connection; PreparedStatement statement = null; ResultSet resultSet = null; Rating rating = null; - String sql = "SELECT RATING, RATED_USERS FROM AP_APP_RELEASE WHERE UUID = ?;"; + String sql = "SELECT RATING, RATED_USERS FROM AP_APP_RELEASE WHERE UUID = ? AND TENANT_D=?;"; try { connection = this.getDBConnection(); statement = connection.prepareStatement(sql); statement.setString(1, uuid); + statement.setInt(2, tenantId); resultSet = statement.executeQuery(); if (resultSet.next()){ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java index ce7b68229d1..a9da364714b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java @@ -96,8 +96,7 @@ public class ApplicationManagerImpl implements ApplicationManager { String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); application.setUser(new User(userName, tenantId)); if (log.isDebugEnabled()) { - log.debug("Create Application received for the tenant : " + application.getUser().getTenantId() + " From" - + " the user : " + application.getUser().getUserName()); + log.debug("Create Application received for the tenant : " + tenantId + " From" + " the user : " + userName); } validateAppCreatingRequest(application); @@ -161,11 +160,13 @@ public class ApplicationManagerImpl implements ApplicationManager { ConnectionManagerUtil.rollbackDBTransaction(); throw new ApplicationManagementException(msg, e); } catch (DeviceManagementException e) { - e.printStackTrace(); + String msg = "Error occurred while getting device type id of " + application.getType(); + log.error(msg, e); + ConnectionManagerUtil.rollbackDBTransaction(); + throw new ApplicationManagementException(msg, e); } finally { //ConnectionManagerUtil.closeDBConnection(); //todo: check this again } - return null; } @Override diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ReviewManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ReviewManagerImpl.java index f86834ddd5d..11ed6d8cf10 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ReviewManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ReviewManagerImpl.java @@ -25,6 +25,8 @@ import org.wso2.carbon.device.application.mgt.common.Rating; import org.wso2.carbon.device.application.mgt.common.Review; 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.exception.RequestValidatingException; +import org.wso2.carbon.device.application.mgt.common.exception.ReviewDoesNotExistException; import org.wso2.carbon.device.application.mgt.common.exception.ReviewManagementException; import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException; import org.wso2.carbon.device.application.mgt.common.exception.TransactionManagementException; @@ -41,7 +43,6 @@ import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; -import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.TreeMap; @@ -64,34 +65,29 @@ public class ReviewManagerImpl implements ReviewManager { this.applicationReleaseDAO = ApplicationManagementDAOFactory.getApplicationReleaseDAO(); } - @Override public boolean addReview(Review review, String uuid) throws ReviewManagementException { + @Override public boolean addReview(Review review, String uuid) + throws ReviewManagementException, RequestValidatingException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - boolean isSuccess; + boolean isSuccess = false; try { ConnectionManagerUtil.beginDBTransaction(); Review existingReview = reviewDAO.haveUerCommented(uuid, username, tenantId); - if (existingReview != null && review.getRating() > 0 && review.getRating() != existingReview.getRating()) { + if (existingReview != null && isAuthorizedUser(username, existingReview.getUsername(), tenantId) + && review.getRating() > 0 && review.getRating() != existingReview.getRating()) { Runnable task = () -> calculateRating(review.getRating(), existingReview.getRating(), uuid); new Thread(task).start(); - isSuccess = updateReview(review, existingReview.getId(),uuid, false); - if (isSuccess) { - ConnectionManagerUtil.commitDBTransaction(); - } else { - ConnectionManagerUtil.rollbackDBTransaction(); - } - } else { - if (review.getRating() > 0) { - Runnable task = () -> calculateRating(review.getRating(), -12345, uuid); - new Thread(task).start(); - } + isSuccess = updateReview(review, existingReview.getId(), uuid, existingReview); + } else if (review.getRating() > 0) { + Runnable task = () -> calculateRating(review.getRating(), -12345, uuid); + new Thread(task).start(); review.setUsername(username); isSuccess = this.reviewDAO.addReview(review, uuid, tenantId); - if (isSuccess) { - ConnectionManagerUtil.commitDBTransaction(); - } else { - ConnectionManagerUtil.rollbackDBTransaction(); - } + } + if (isSuccess) { + ConnectionManagerUtil.commitDBTransaction(); + } else { + ConnectionManagerUtil.rollbackDBTransaction(); } return isSuccess; } catch (DBConnectionException e) { @@ -103,49 +99,54 @@ public class ReviewManagerImpl implements ReviewManager { throw new ReviewManagementException( "Transaction Management Exception occurs,Review for application release with UUID:" + uuid + " is failed ", e); + } catch (UserStoreException e) { + throw new ReviewManagementException("Error occured while verifying user's permission to update the review.", + e); } finally { ConnectionManagerUtil.closeDBConnection(); } } @Override - public boolean updateReview(Review review, int reviewId, String uuid, boolean checkExistence) + public boolean updateReview(Review review, int reviewId, String uuid, Review existingReview) throws ReviewManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - Review existingReview; - boolean isSuccess; if (log.isDebugEnabled()) { log.debug("Review updating request is received for the review id " + reviewId); } try { ConnectionManagerUtil.openDBConnection(); - // todo - if (!username.equals(review.getUsername())) { - throw new ReviewManagementException( - "User " + review.getUsername() + "doesn't match with the logged in user: " + username); - } - if (checkExistence) { + if (existingReview == null) { existingReview = this.reviewDAO.getReview(reviewId); - if (existingReview != null) { + if (existingReview != null && isAuthorizedUser(username, existingReview.getUsername(), tenantId)) { if (review.getRating() > 0 && review.getRating() != existingReview.getRating()) { - Runnable task = () -> calculateRating(review.getRating(), existingReview.getRating(), uuid); + Review finalExistingReview = existingReview; + Runnable task = () -> calculateRating(review.getRating(), finalExistingReview.getRating(), + uuid); new Thread(task).start(); } } else { - throw new ReviewManagementException("Couldn't find a review for review id: " + reviewId); + throw new ReviewManagementException( + "Please check the existence of the review, Review-Id: " + reviewId + + " or permission of the " + username + " to update the review."); } } + if (review.getComment().isEmpty()) { + review.setComment(existingReview.getComment()); + } + if (review.getRating() == 0) { + review.setRating(existingReview.getRating()); + } ConnectionManagerUtil.beginDBTransaction(); - isSuccess = this.reviewDAO.updateReview(review, reviewId, tenantId); - if (isSuccess) { + if (this.reviewDAO.updateReview(review, reviewId, username, tenantId) == 1) { ConnectionManagerUtil.commitDBTransaction(); - } else { - ConnectionManagerUtil.rollbackDBTransaction(); + return true; } - return isSuccess; - } catch (SQLException e) { - throw new ReviewManagementException("SQL Error occurs updating review with review id " + reviewId + ".", + ConnectionManagerUtil.rollbackDBTransaction(); + return false; + } catch (ReviewManagementDAOException e) { + throw new ReviewManagementException("Error occured while updating review with review id " + reviewId + ".", e); } catch (DBConnectionException e) { throw new ReviewManagementException( @@ -153,6 +154,10 @@ public class ReviewManagerImpl implements ReviewManager { } catch (TransactionManagementException e) { throw new ReviewManagementException( "Transaction management error occurs when updating review with review id " + reviewId + ".", e); + } catch (UserStoreException e) { + throw new ReviewManagementException( + "Error occured while verifying user's permission to update the review. review id: " + reviewId + + ".", e); } finally { ConnectionManagerUtil.closeDBConnection(); } @@ -203,55 +208,28 @@ public class ReviewManagerImpl implements ReviewManager { } } - @Override public Review getReview(int commentId) throws ReviewManagementException { - PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); - Review review; - if (log.isDebugEnabled()) { - log.debug("Review retrieval request is received for the review id " + commentId); - } - try { - ConnectionManagerUtil.openDBConnection(); - review = this.reviewDAO.getReview(commentId); - } catch (DBConnectionException e) { - throw new ReviewManagementException( - "DB Connection error occurs ,Review with review id " + commentId + "cannot get.", e); - } catch (SQLException e) { - throw new ReviewManagementException( - "SQL Exception occurs,Review with review id " + commentId + "cannot get.", e); - } finally { - ConnectionManagerUtil.closeDBConnection(); - } - return review; - } - @Override - public boolean deleteReview(String uuid, int reviewId) throws ReviewManagementException { + public boolean deleteReview(String uuid, int reviewId) + throws ReviewManagementException, ReviewDoesNotExistException { Review existingReview; int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - int isReviewDeleted; try { - existingReview = getReview(reviewId); + ConnectionManagerUtil.openDBConnection(); + existingReview = this.reviewDAO.getReview(reviewId); if (existingReview == null) { - throw new ReviewManagementException( + throw new ReviewDoesNotExistException( "Cannot delete a non-existing review for the application with review id" + reviewId); } Runnable task = () -> calculateRating(0, existingReview.getRating(), uuid); new Thread(task).start(); ConnectionManagerUtil.beginDBTransaction(); - if (isAdminUser(username, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) { - isReviewDeleted = this.reviewDAO.deleteReviewByAdmin(reviewId); - if (isReviewDeleted == 1) { - ConnectionManagerUtil.commitDBTransaction(); - return true; - } - } else { - isReviewDeleted = this.reviewDAO.deleteReview(username, reviewId); - if (isReviewDeleted == 1) { - ConnectionManagerUtil.commitDBTransaction(); - return true; - } + if (isAuthorizedUser(username, existingReview.getUsername(), tenantId) + && this.reviewDAO.deleteReview(username, reviewId) == 1) { + ConnectionManagerUtil.commitDBTransaction(); + return true; } + ConnectionManagerUtil.rollbackDBTransaction(); return false; } catch (DBConnectionException e) { throw new ReviewManagementException( @@ -272,17 +250,17 @@ public class ReviewManagerImpl implements ReviewManager { } @Override public Rating getRating(String appReleaseUuuid) throws ReviewManagementException { - //todo - int appReleaseId = 0; + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); try { ConnectionManagerUtil.openDBConnection(); - Rating rating = this.applicationReleaseDAO.getRating(appReleaseUuuid); + Rating rating = this.applicationReleaseDAO.getRating(appReleaseUuuid, tenantId); if (rating == null) { - throw new ReviewManagementException("Couldn't find rating for application release id: " + appReleaseId - + ". Please check the existence of the application relese"); + throw new ReviewManagementException( + "Couldn't find rating for application release UUID: " + appReleaseUuuid + + ". Please check the existence of the application release"); } - List ratingValues = this.reviewDAO.getAllRatingValues(appReleaseUuuid); + List ratingValues = this.reviewDAO.getAllRatingValues(appReleaseUuuid, tenantId); TreeMap ratingVariety = rating.getRatingVariety(); for (Integer ratingVal : ratingValues) { if (ratingVariety.containsKey(ratingVal)) { @@ -296,62 +274,59 @@ public class ReviewManagerImpl implements ReviewManager { } catch (ApplicationManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); throw new ReviewManagementException( - "Error occured while updated the rating value of the application release id: " + appReleaseId - + " can not get.", e); + "Error occured while getting the rating value of the application release uuid: " + appReleaseUuuid, + e); } catch (DBConnectionException e) { ConnectionManagerUtil.rollbackDBTransaction(); throw new ReviewManagementException( - "DB Connection error occured while updated the rating value of the application release id: " - + appReleaseId + " can not get.", e); - } catch (SQLException e) { + "DB Connection error occured while getting the rating value of the application release uuid: " + + appReleaseUuuid, e); + } catch (ReviewManagementDAOException e) { throw new ReviewManagementException( - "DB Connection error occured while updated the rating value of the application release id: " - + appReleaseId + " can not get.", e); + "Error occured while getting all rating values for the application release UUID: " + + appReleaseUuuid, e); } finally { ConnectionManagerUtil.closeDBConnection(); } } private void calculateRating(int newRatingVal, int oldRatingVal, String uuid) { - // todo need to pass app release id - int appReleaseId = 0; + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); try { ConnectionManagerUtil.beginDBTransaction(); - Rating rating = this.applicationReleaseDAO.getRating(uuid); + Rating rating = this.applicationReleaseDAO.getRating(uuid, tenantId); if (rating == null) { - log.error("Couldn't find rating for application release id: " + appReleaseId); + log.error("Couldn't find rating for application release uuid: " + uuid); } else { double updatedRating; int numOfUsers = rating.getNoOfUsers(); double currentRating = rating.getRatingValue() * numOfUsers; if (oldRatingVal == -12345) { updatedRating = (currentRating + newRatingVal) / (numOfUsers + 1); - this.applicationReleaseDAO.updateRatingValue(appReleaseId, updatedRating, numOfUsers + 1); + this.applicationReleaseDAO.updateRatingValue(uuid, updatedRating, numOfUsers + 1); } else if (newRatingVal == 0) { updatedRating = (currentRating - newRatingVal) / (numOfUsers - 1); - this.applicationReleaseDAO.updateRatingValue(appReleaseId, updatedRating, numOfUsers - 1); + this.applicationReleaseDAO.updateRatingValue(uuid, updatedRating, numOfUsers - 1); } else { double tmpVal; tmpVal = currentRating - oldRatingVal; updatedRating = (tmpVal + newRatingVal) / numOfUsers; - this.applicationReleaseDAO.updateRatingValue(appReleaseId, updatedRating, numOfUsers); + this.applicationReleaseDAO.updateRatingValue(uuid, updatedRating, numOfUsers); } } ConnectionManagerUtil.commitDBTransaction(); } catch (ApplicationManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); - log.error("Error occured while updated the rating value of the application release id: " + appReleaseId - + " can not get."); + log.error("Error occured while updated the rating value of the application release UUID: " + uuid); } catch (TransactionManagementException e) { ConnectionManagerUtil.rollbackDBTransaction(); log.error( - "Transaction Management Exception occured while updated the rating value of the application release id: " - + appReleaseId + " can not get."); - + "Transaction Management Exception occured while updated the rating value of the application release UUID: " + + uuid); } catch (DBConnectionException e) { ConnectionManagerUtil.rollbackDBTransaction(); - log.error("DB Connection error occured while updated the rating value of the application release id: " - + appReleaseId + " can not get."); + log.error("DB Connection error occured while updated the rating value of the application release UUID: " + + uuid + " can not get."); } finally { ConnectionManagerUtil.closeDBConnection(); } @@ -372,4 +347,20 @@ public class ReviewManagerImpl implements ReviewManager { .isUserAuthorized(MultitenantUtils.getTenantAwareUsername(username), permission, CarbonConstants.UI_PERMISSION_ACTION); } + + + /** + * To check whether logged in user is authorized user to do an specific action. + * + * @param loggedInUser username of the loggedin user. + * @param reviewOwner username of the review owner. + * @param tenantId ID of the tenant. + * @return true if the current user has the permission, otherwise false. + * @throws UserStoreException UserStoreException + */ + private boolean isAuthorizedUser(String loggedInUser, String reviewOwner, int tenantId) throws UserStoreException { + return loggedInUser.equals(reviewOwner) || isAdminUser(loggedInUser, tenantId, + CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION); + } + } \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/UnrestrictedRoleManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/UnrestrictedRoleManagerImpl.java deleted file mode 100644 index 861246ec539..00000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/UnrestrictedRoleManagerImpl.java +++ /dev/null @@ -1,117 +0,0 @@ -/* -* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* WSO2 Inc. 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.core.impl; - -import org.wso2.carbon.device.application.mgt.common.UnrestrictedRole; -import org.wso2.carbon.device.application.mgt.common.Visibility; -import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; -import org.wso2.carbon.device.application.mgt.common.exception.VisibilityManagementException; -import org.wso2.carbon.device.application.mgt.common.services.UnrestrictedRoleManager; -import org.wso2.carbon.device.application.mgt.core.dao.VisibilityDAO; -import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOFactory; -import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; - -import java.util.Collection; -import java.util.List; - -//todo need to work on business logic -/** - * This is the default implementation for the visibility manager. - */ -public class UnrestrictedRoleManagerImpl implements UnrestrictedRoleManager { - - @Override - public Visibility put(int applicationID, Visibility visibility) throws VisibilityManagementException { - return null; -// if (visibility == null) { -// visibility = new Visibility(); -// visibility.setType(Visibility.Type.PUBLIC); -// } -// if (visibility.getAllowedList() == null && !visibility.getType().equals(Visibility.Type.PUBLIC)) { -// throw new VisibilityManagementException("Visibility is configured for '" + visibility.getType() -// + "' but doesn't have any allowed list provided!"); -// } -// boolean isTransactionStarted = false; -// try { -// isTransactionStarted = ConnectionManagerUtil.isTransactionStarted(); -// if (!isTransactionStarted) { -// ConnectionManagerUtil.beginDBTransaction(); -// } -// VisibilityDAO visibilityDAO = ApplicationManagementDAOFactory.getVisibilityDAO(); -// int visibilityTypeId = visibilityDAO.getVisibilityID(visibility.getType()); -// visibilityDAO.delete(applicationID); -// visibilityDAO.add(applicationID, visibilityTypeId, visibility.getAllowedList()); -// if (!isTransactionStarted) { -// ConnectionManagerUtil.commitDBTransaction(); -// } -// return visibility; -// } catch (ApplicationManagementException e) { -// if (!isTransactionStarted) { -// ConnectionManagerUtil.rollbackDBTransaction(); -// } -// throw new VisibilityManagementException("Problem occured when trying to fetch the application with ID - " -// + applicationID, e); -// } finally { -// if (!isTransactionStarted) { -// ConnectionManagerUtil.closeDBConnection(); -// } -// } - } - - @Override - public List getUnrestrictedRoles(int applicationID, int tenantId) throws VisibilityManagementException { - try { - VisibilityDAO visibilityDAO = ApplicationManagementDAOFactory.getVisibilityDAO(); - List unrestrictedRoles = visibilityDAO.getUnrestrictedRoles(applicationID, tenantId); - if (unrestrictedRoles == null) { - return null; - } - return unrestrictedRoles; - } catch (ApplicationManagementException e) { - throw new VisibilityManagementException("Problem occured when trying to fetch the application with ID - " - + applicationID, e); - } - } - - @Override - public void remove(int applicationID) throws VisibilityManagementException { -// boolean isTransactionStarted = false; -// try { -// isTransactionStarted = ConnectionManagerUtil.isTransactionStarted(); -// if (!isTransactionStarted) { -// ConnectionManagerUtil.beginDBTransaction(); -// } -// VisibilityDAO visibilityDAO = ApplicationManagementDAOFactory.getVisibilityDAO(); -// visibilityDAO.delete(applicationID); -// if (!isTransactionStarted) { -// ConnectionManagerUtil.commitDBTransaction(); -// } -// } catch (ApplicationManagementException e) { -// if (!isTransactionStarted) { -// ConnectionManagerUtil.rollbackDBTransaction(); -// } -// throw new VisibilityManagementException("Problem occurred when trying to fetch the application with ID - " -// + applicationID, e); -// } finally { -// if (!isTransactionStarted) { -// ConnectionManagerUtil.closeDBConnection(); -// } -// } - } - -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementServiceComponent.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementServiceComponent.java index cf891d5d1c7..a560884d46b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementServiceComponent.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementServiceComponent.java @@ -22,15 +22,12 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.device.application.mgt.common.exception.InvalidConfigurationException; import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager; import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager; import org.wso2.carbon.device.application.mgt.common.services.ReviewManager; import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager; -import org.wso2.carbon.device.application.mgt.common.services.UnrestrictedRoleManager; import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager; import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOFactory; -import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException; import org.wso2.carbon.device.application.mgt.core.lifecycle.LifecycleStateManger; import org.wso2.carbon.device.application.mgt.core.lifecycle.config.LifecycleState; import org.wso2.carbon.device.application.mgt.core.util.ApplicationManagementUtil; @@ -38,7 +35,6 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.ndatasource.core.DataSourceService; import org.wso2.carbon.user.core.service.RealmService; -import javax.naming.NamingException; import java.util.List; /** @@ -90,10 +86,6 @@ public class ApplicationManagementServiceComponent { DataHolder.getInstance().setSubscriptionManager(subscriptionManager); bundleContext.registerService(SubscriptionManager.class.getName(), subscriptionManager, null); - UnrestrictedRoleManager unrestrictedRoleManager = ApplicationManagementUtil.getVisibilityManagerInstance(); - DataHolder.getInstance().setVisibilityManager(unrestrictedRoleManager); - bundleContext.registerService(UnrestrictedRoleManager.class.getName(), unrestrictedRoleManager, null); - ApplicationStorageManager applicationStorageManager = ApplicationManagementUtil .getApplicationStorageManagerInstance(); DataHolder.getInstance().setApplicationStorageManager(applicationStorageManager); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/DataHolder.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/DataHolder.java index 68cfce54cd1..f8e16027d5a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/DataHolder.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/DataHolder.java @@ -22,7 +22,6 @@ import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager; import org.wso2.carbon.device.application.mgt.common.services.ReviewManager; import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager; -import org.wso2.carbon.device.application.mgt.common.services.UnrestrictedRoleManager; import org.wso2.carbon.device.application.mgt.core.lifecycle.LifecycleStateManger; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.user.core.service.RealmService; @@ -42,8 +41,6 @@ public class DataHolder { private SubscriptionManager subscriptionManager; - private UnrestrictedRoleManager unrestrictedRoleManager; - private ApplicationStorageManager applicationStorageManager; private LifecycleStateManger lifecycleStateManger; @@ -90,14 +87,6 @@ public class DataHolder { this.subscriptionManager = subscriptionManager; } - public UnrestrictedRoleManager getVisibilityManager() { - return unrestrictedRoleManager; - } - - public void setVisibilityManager(UnrestrictedRoleManager unrestrictedRoleManager) { - this.unrestrictedRoleManager = unrestrictedRoleManager; - } - public RealmService getRealmService() { return realmService; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/lifecycle/LifecycleStateManger.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/lifecycle/LifecycleStateManger.java index 1a0218b20b9..bf614e07996 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/lifecycle/LifecycleStateManger.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/lifecycle/LifecycleStateManger.java @@ -26,9 +26,6 @@ public class LifecycleStateManger { } public boolean isValidStateChange(String currentState, String nextState) { - if (lifecycleStates.get(currentState).getProceedingStates().contains(nextState)) { - return true; - } - return false; + return lifecycleStates.get(currentState).getProceedingStates().contains(nextState); } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/ApplicationManagementUtil.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/ApplicationManagementUtil.java index 488f8147b57..a1088861643 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/ApplicationManagementUtil.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/ApplicationManagementUtil.java @@ -25,7 +25,6 @@ import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager; import org.wso2.carbon.device.application.mgt.common.services.ReviewManager; import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager; -import org.wso2.carbon.device.application.mgt.common.services.UnrestrictedRoleManager; import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager; import org.wso2.carbon.device.application.mgt.core.config.Extension; @@ -51,12 +50,6 @@ public class ApplicationManagementUtil { return getInstance(extension, ReviewManager.class); } - public static UnrestrictedRoleManager getVisibilityManagerInstance() throws InvalidConfigurationException { - ConfigurationManager configurationManager = ConfigurationManager.getInstance(); - Extension extension = configurationManager.getExtension(Extension.Name.VisibilityManager); - return getInstance(extension, UnrestrictedRoleManager.class); - } - public static SubscriptionManager getSubscriptionManagerInstance() throws InvalidConfigurationException { ConfigurationManager configurationManager = ConfigurationManager.getInstance(); Extension extension = configurationManager.getExtension(Extension.Name.SubscriptionManager); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/application-mgt.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/application-mgt.xml index b764b9e53e5..a896bf97396 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/application-mgt.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/application-mgt.xml @@ -23,39 +23,18 @@ jdbc/APPM_DS - - org.wso2.carbon.device.application.mgt.core.impl.ApplicationUploadManagerImpl - - repository/resources/mobileapps - - org.wso2.carbon.device.application.mgt.core.impl.ApplicationManagerImpl - - org.wso2.carbon.device.application.mgt.core.impl.ApplicationReleaseManagerImpl - - - org.wso2.carbon.device.application.mgt.core.impl.CategoryManagerImpl - - + org.wso2.carbon.device.application.mgt.core.impl.ReviewManagerImpl - org.wso2.carbon.device.application.mgt.core.impl.LifecycleStateManagerImpl - - - org.wso2.carbon.device.application.mgt.core.impl.PlatformManagerImpl + org.wso2.carbon.device.application.mgt.core.lifecycle.LifecycleStateManger org.wso2.carbon.device.application.mgt.core.impl.SubscriptionManagerImpl - - org.wso2.carbon.device.application.mgt.core.impl.UnrestrictedRoleManagerImpl - - - org.wso2.carbon.device.application.mgt.core.impl.VisibilityTypeManagerImpl - 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/APIUtil.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/APIUtil.java index b850d5c0c75..a62ba819beb 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/APIUtil.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/APIUtil.java @@ -37,7 +37,6 @@ public class APIUtil { private static ApplicationManager applicationManager; private static ApplicationStorageManager applicationStorageManager; private static SubscriptionManager subscriptionManager; - private static UnrestrictedRoleManager unrestrictedRoleManager; public static ApplicationManager getApplicationManager() { if (applicationManager == null) { @@ -116,26 +115,4 @@ public class APIUtil { return subscriptionManager; } - /** - * To get the Unrestricted Role manager from the osgi context. - * @return Unrestricted Role manager instance in the current osgi context. - */ - public static UnrestrictedRoleManager getUnrestrictedRoleManager() { - if (unrestrictedRoleManager == null) { - synchronized (APIUtil.class) { - if (unrestrictedRoleManager == null) { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - unrestrictedRoleManager = - (UnrestrictedRoleManager) ctx.getOSGiService(UnrestrictedRoleManager.class, null); - if (unrestrictedRoleManager == null) { - String msg = "Subscription Manager service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - } - } - } - - return unrestrictedRoleManager; - } } 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/ApplicationManagementAPI.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/ApplicationManagementAPI.java index cf907d4e183..b2068ec6bee 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/ApplicationManagementAPI.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/ApplicationManagementAPI.java @@ -28,23 +28,16 @@ import io.swagger.annotations.ExtensionProperty; import io.swagger.annotations.Info; import io.swagger.annotations.SwaggerDefinition; import io.swagger.annotations.Tag; -import org.apache.cxf.jaxrs.ext.multipart.Attachment; -import org.apache.cxf.jaxrs.ext.multipart.Multipart; import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.device.application.mgt.common.Filter; import org.wso2.carbon.device.application.mgt.publisher.api.beans.ErrorResponse; import org.wso2.carbon.device.application.mgt.common.Application; import org.wso2.carbon.device.application.mgt.common.ApplicationList; -import org.wso2.carbon.device.application.mgt.common.ApplicationRelease; -import java.util.List; import javax.validation.Valid; import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; @@ -53,22 +46,22 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; /** - * APIs to handle application management related tasks. + * APIs to handle application storage management related tasks. */ @SwaggerDefinition( info = @Info( version = "1.0.0", - title = "Application Management Service", + title = "Application Storage Management Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = "name", value = "ApplicationManagementService"), - @ExtensionProperty(name = "context", value = "/api/application-mgt/v1.0/applications"), + @ExtensionProperty(name = "name", value = "ApplicationStorageManagementService"), + @ExtensionProperty(name = "context", value = "/api/application-mgt/v1.0/store-applications"), }) } ), tags = { - @Tag(name = "application_management, device_management", description = "Application Management related " - + "APIs") + @Tag(name = "application_management, device_management", description = "Application Storage Management " + + "related APIs") } ) @Scopes( 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 92d2298e502..1ad57f6f9c8 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 @@ -30,6 +30,7 @@ import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.annotations.api.Scopes; +import org.wso2.carbon.device.application.mgt.common.PaginationResult; import org.wso2.carbon.device.application.mgt.publisher.api.beans.ErrorResponse; import org.wso2.carbon.device.application.mgt.common.Review; import javax.validation.Valid; @@ -47,7 +48,7 @@ import javax.ws.rs.core.Response; import java.util.List; /** - * APIs to handle comment management related tasks. + * APIs to handle review management related tasks. */ @SwaggerDefinition( @@ -56,51 +57,36 @@ import java.util.List; title = "Store Management Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = "name", value = "CommentManagementService"), - @ExtensionProperty(name = "context", value = "/api/application-mgt/v1.0/comments"), + @ExtensionProperty(name = "name", value = "ReviewManagementService"), + @ExtensionProperty(name = "context", value = "/api/application-mgt/v1.0/review"), }) } ), tags = { - @Tag(name = "store_management", description = "Review Management related " - + "APIs") + @Tag(name = "store_management", description = "Review Management related APIs") } ) @Scopes( scopes = { @Scope( - name = "Get Comments Details", - description = "Get comments details", - key = "perm:comment:get", - permissions = {"/device-mgt/comment/get"} - ), - @Scope( - name = "Add a Review", - description = "Add a comment", - key = "perm:comment:add", - permissions = {"/device-mgt/comment/add"} + name = "Get Review Details", + description = "Get review details", + key = "perm:app:review:view", + permissions = {"/device-mgt/review/view"} ), @Scope( name = "Update a Review", - description = "Update a Review", - key = "perm:comment:update", - permissions = {"/device-mgt/comment/update"} - ), - - @Scope( - name = "Delete a Review", - description = "Delete a comment", - key = "perm:comment:delete", - permissions = {"/device-mgt/comment/delete"} + description = "Update a comment", + key = "perm:app:review:update", + permissions = {"/device-mgt/review/update"} ), } ) @Path("/review") -@Api(value = "Comments Management", description = "This API carries all comments management related operations " + - "such as get all the comments, add comment, etc.") +@Api(value = "Review Management", description = "This API carries all review management related operations such as get " + + "all the reviews, add review, etc.") @Produces(MediaType.APPLICATION_JSON) - public interface ReviewManagementAPI { String SCOPE = "scope"; @@ -110,12 +96,12 @@ public interface ReviewManagementAPI { @ApiOperation( produces = MediaType.APPLICATION_JSON, httpMethod = "GET", - value = "get comments", - notes = "Get all comments", + value = "get reviews", + notes = "Get all reviews", tags = "Store Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:store:get") + @ExtensionProperty(name = SCOPE, value = "perm:app:review:view") }) } ) @@ -124,36 +110,30 @@ public interface ReviewManagementAPI { value = { @ApiResponse( code = 200, - message = "OK. \n Successfully retrieved comments.", - response = List.class, - responseContainer = "List"), - @ApiResponse( - code = 404, - message = "Not Found. \n No activity found with the given ID.", - response = ErrorResponse.class), + message = "OK. \n Successfully retrieved reviews.", + response = PaginationResult.class, + responseContainer = "PaginationResult"), @ApiResponse( code = 500, - message = "Internal Server Error. \n Error occurred while getting the comment list.", + message = "Internal Server Error. \n Error occurred while getting the review list.", response = ErrorResponse.class) }) Response getAllReviews( @ApiParam( name="uuid", - value="uuid of the released version of application.", + value="uuid of the application release.", required = true) @PathParam("uuid") String uuid, @ApiParam( name="offSet", - value="Starting comment number.",defaultValue = "1", - required = false) + value="Starting review number.",defaultValue = "0") @QueryParam("offSet") int offSet, @ApiParam( name="limit", - value = "Limit of paginated comments",defaultValue = "20", - required = false) + value = "Limit of paginated reviews",defaultValue = "20") @QueryParam("limit") int limit); @@ -170,7 +150,7 @@ public interface ReviewManagementAPI { tags = "Store Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:store:add") + @ExtensionProperty(name = SCOPE, value = "perm:app:review:update") }) } ) @@ -215,23 +195,19 @@ public interface ReviewManagementAPI { tags = "Store Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:store:edit") + @ExtensionProperty(name = SCOPE, value = "perm:app:review:update") }) } ) @ApiResponses( value = { @ApiResponse( - code = 201, + code = 200, message = "OK. \n Successfully updated review.", response = Review.class), @ApiResponse( code = 400, message = "Bad Request. \n Invalid request or validation error."), - @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 updating the new review.", @@ -267,7 +243,7 @@ public interface ReviewManagementAPI { tags = "Store Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:store:remove") + @ExtensionProperty(name = SCOPE, value = "perm:app:review:update") }) } ) @@ -276,14 +252,14 @@ public interface ReviewManagementAPI { value = { @ApiResponse( code = 200, - message = "OK. \n Successfully deleted the comment"), + 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 comment.", + message = "Internal Server Error. \n Error occurred while deleting the review.", response = ErrorResponse.class) }) @@ -300,17 +276,17 @@ public interface ReviewManagementAPI { @PathParam("reviewId") int reviewId); @GET - @Path("/{uuid}/{stars}") + @Path("/{uuid}/rating") @Produces(MediaType.APPLICATION_JSON) @ApiOperation( produces = MediaType.APPLICATION_JSON, httpMethod = "GET", - value = "get stars", - notes = "Get all stars", + value = "get ratings", + notes = "Get all ratings", tags = "Store Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = SCOPE, value = "perm:stars:get") + @ExtensionProperty(name = SCOPE, value = "perm:app:review:view") }) } ) @@ -319,12 +295,12 @@ public interface ReviewManagementAPI { value = { @ApiResponse( code = 200, - message = "OK. \n Successfully retrieved stars.", + message = "OK. \n Successfully retrieved ratings.", response = List.class, responseContainer = "List"), @ApiResponse( code = 500, - message = "Internal Server Error. \n Error occurred while getting the stars", + message = "Internal Server Error. \n Error occurred while getting ratings", response = ErrorResponse.class) }) 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/SubscriptionManagementAPI.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/SubscriptionManagementAPI.java index 8449da1cf5d..ea945b8f35e 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/SubscriptionManagementAPI.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/SubscriptionManagementAPI.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.application.mgt.publisher.api.services; +package org.wso2.carbon.device.application.mgt.store.api.services; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; 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 ebcefc0fe28..202e9a220b2 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 @@ -25,6 +25,8 @@ import org.wso2.carbon.device.application.mgt.common.Application; 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.Review; +import org.wso2.carbon.device.application.mgt.common.exception.RequestValidatingException; +import org.wso2.carbon.device.application.mgt.common.exception.ReviewDoesNotExistException; import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager; import org.wso2.carbon.device.application.mgt.common.services.ReviewManager; import org.wso2.carbon.device.application.mgt.store.api.APIUtil; @@ -106,6 +108,10 @@ public class ReviewManagementAPIImpl implements ReviewManagementAPI { log.error("Error occured while getting the application for application UUID: " + uuid); return Response.status(Response.Status.INTERNAL_SERVER_ERROR) .entity("").build(); + } catch (RequestValidatingException e) { + String msg = "Error occurred while adding for application release. UUID of the application release: " + uuid; + log.error(msg, e); + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); } } @@ -119,7 +125,7 @@ public class ReviewManagementAPIImpl implements ReviewManagementAPI { @PathParam("reviewId") int reviewId) { ReviewManager reviewManager = APIUtil.getReviewManager(); try { - if (reviewManager.updateReview(review, reviewId, uuid, true)) { + if (reviewManager.updateReview(review, reviewId, uuid, null)) { return Response.status(Response.Status.OK).entity(review).build(); } else { String msg = "Review updating failed. Please contact the administrator"; @@ -130,6 +136,10 @@ public class ReviewManagementAPIImpl implements ReviewManagementAPI { String msg = "Error occurred while retrieving comments."; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } catch (RequestValidatingException e) { + String msg = "Error occurred while updating review. Review id: " + reviewId; + log.error(msg, e); + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); } } @@ -142,9 +152,7 @@ public class ReviewManagementAPIImpl implements ReviewManagementAPI { ReviewManager reviewManager = APIUtil.getReviewManager(); try { - if (reviewId == 0) { - return Response.status(Response.Status.NOT_FOUND).entity("Review not found").build(); - } else if (reviewManager.deleteReview(uuid, reviewId)) { + if (reviewManager.deleteReview(uuid, reviewId)) { return Response.status(Response.Status.OK).entity("Review is deleted successfully.").build(); } else { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Review deleting is failed.") @@ -154,6 +162,10 @@ public class ReviewManagementAPIImpl implements ReviewManagementAPI { String msg = "Error occurred while deleting the comment."; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } catch (ReviewDoesNotExistException e) { + String msg = "Couldn't find a review for review-id: " + reviewId + " to delete."; + log.error(msg, e); + return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); } } 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/SubscriptionManagementAPIImpl.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/SubscriptionManagementAPIImpl.java index 558400b39cf..716f40f4a4a 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/SubscriptionManagementAPIImpl.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/SubscriptionManagementAPIImpl.java @@ -23,18 +23,16 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.application.mgt.common.ApplicationInstallResponse; import org.wso2.carbon.device.application.mgt.common.EnterpriseInstallationDetails; import org.wso2.carbon.device.application.mgt.store.api.APIUtil; -import org.wso2.carbon.device.application.mgt.publisher.api.services.SubscriptionManagementAPI; +import org.wso2.carbon.device.application.mgt.store.api.services.SubscriptionManagementAPI; import org.wso2.carbon.device.application.mgt.common.InstallationDetails; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import javax.validation.Valid; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; -import java.util.HashMap; import java.util.List; /** 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 9bcbcf4fa49..59ae25af097 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 @@ -25,27 +25,15 @@ org.wso2.carbon.device.application.mgt.core.impl.ApplicationManagerImpl - - org.wso2.carbon.device.application.mgt.core.impl.ApplicationReleaseManagerImpl - - - org.wso2.carbon.device.application.mgt.core.impl.CategoryManagerImpl - org.wso2.carbon.device.application.mgt.core.impl.ReviewManagerImpl - org.wso2.carbon.device.application.mgt.core.impl.LifecycleStateManagerImpl - - - org.wso2.carbon.device.application.mgt.core.impl.PlatformManagerImpl + org.wso2.carbon.device.application.mgt.core.lifecycle.LifecycleStateManger org.wso2.carbon.device.application.mgt.core.impl.SubscriptionManagerImpl - - org.wso2.carbon.device.application.mgt.core.impl.UnrestrictedRoleManagerImpl - org.wso2.carbon.device.application.mgt.core.impl.ApplicationStorageManagerImpl @@ -53,12 +41,6 @@ 6 - - org.wso2.carbon.device.application.mgt.core.impl.PlatformStorageManagerImpl - - repository/resources/platforms - -