fixing conflicts

feature/appm-store/pbac
inoshperera 6 years ago
commit ae476d85df

@ -24,7 +24,6 @@ import io.swagger.annotations.ApiModelProperty;
import java.util.List; import java.util.List;
@ApiModel(value = "Application", description = "Application represents the an Application in Application Store") @ApiModel(value = "Application", description = "Application represents the an Application in Application Store")
public class Application { public class Application {

@ -177,7 +177,6 @@ public class ApplicationRelease {
this.price = price; this.price = price;
} }
public String getAppHashValue() { public String getAppHashValue() {
return appHashValue; return appHashValue;
} }

@ -18,8 +18,6 @@
*/ */
package org.wso2.carbon.device.application.mgt.common; package org.wso2.carbon.device.application.mgt.common;
import com.google.gson.Gson;
import java.io.Serializable; import java.io.Serializable;
/** /**

@ -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;
}
}

@ -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;
}
}

@ -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;
}
}

@ -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;
}
}

@ -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<String> allowedList;
public Type getType() {
return type;
}
public void setType(Type type) {
this.type = type;
}
public List<String> getAllowedList() {
return allowedList;
}
public void setAllowedList(List<String> allowedList) {
this.allowedList = allowedList;
}
/**
* Type of the visibility of the application.
*/
public enum Type {
PUBLIC, ROLES, DEVICE_GROUPS
}
}

@ -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;
}
}

@ -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.ApplicationRelease;
import org.wso2.carbon.device.application.mgt.common.Filter; 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.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.UnrestrictedRole;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
import org.wso2.carbon.device.application.mgt.common.exception.LifecycleManagementException;
import java.util.List; import java.util.List;

@ -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.Review;
import org.wso2.carbon.device.application.mgt.common.PaginationRequest; 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.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.ReviewManagementException;
/** /**
* ReviewManager is responsible for handling all the add/update/delete/get operations related with * ReviewManager is responsible for handling all the add/update/delete/get operations related with
*/ */
public interface ReviewManager { 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 review review of the application.
* @param uuid uuid of the application release. * @param uuid uuid of the application release.
* @return {@link Review} Review added * @return {@link Review} Review added
* @throws ReviewManagementException Exceptions of the review management. * @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 request Pagination request {@link PaginationRequest}
* @param uuid uuid of the application release * @param uuid uuid of the application release
@ -49,15 +53,6 @@ public interface ReviewManager {
*/ */
PaginationResult getAllReviews(PaginationRequest request, String uuid) throws ReviewManagementException; 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. * To delete review using review id.
* *
@ -66,7 +61,8 @@ public interface ReviewManager {
* @return If review is successfully deleted return true, otherwise returns false * @return If review is successfully deleted return true, otherwise returns false
* @throws ReviewManagementException Exceptions of the comment management * @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. * To update a review.
@ -74,12 +70,13 @@ public interface ReviewManager {
* @param review review of the application. * @param review review of the application.
* @param reviewId id of the review * @param reviewId id of the review
* @param uuid UUID of the application release * @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 * @return {@link Review}updated review
* @throws ReviewManagementException Exceptions of the review management * @throws ReviewManagementException Exceptions of the review management
*/ */
boolean updateReview(Review review, int reviewId, String uuid, boolean checkExistence) boolean updateReview(Review review, int reviewId, String uuid, Review existingReview)
throws ReviewManagementException; throws ReviewManagementException, RequestValidatingException;
/** /**
* To get the overall rating for a application release * To get the overall rating for a application release

@ -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<UnrestrictedRole> 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;
}

@ -81,19 +81,21 @@ public interface ApplicationReleaseDAO {
/** /**
* To update an Application release. * 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 rating given stars for the application.
* @param ratedUsers number of users who has rated for the application release. * @param ratedUsers number of users who has rated for the application release.
* @throws ApplicationManagementDAOException Application Management DAO Exception * @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. * To retrieve rating of an application release.
*
* @param uuid UUID of the application Release. * @param uuid UUID of the application Release.
* @param tenantId Tenant Id
* @throws ApplicationManagementDAOException Application Management DAO Exception. * @throws ApplicationManagementDAOException Application Management DAO Exception.
*/ */
Rating getRating(String uuid) throws ApplicationManagementDAOException; Rating getRating(String uuid, int tenantId) throws ApplicationManagementDAOException;
/** /**

@ -45,7 +45,7 @@ import java.util.List;
boolean addReview(Review review, String uuid, int tenantId) throws ReviewManagementDAOException; 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 uuid UUID of the application release.
* @param username username of the logged in user. * @param username username of the logged in user.
@ -58,33 +58,33 @@ import java.util.List;
/** /**
* To update already added comment. * To update already added comment.
* *
* @return {@link Review}Updated comment * @param review Updating review
* @throws ReviewManagementException Exceptions of the comment management. * @param reviewId id of the updating review
* @throws DBConnectionException db connection exception * @param username review owner
* @throws SQLException sql exception * @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) int updateReview(Review review, int reviewId, String username, int tenantId)
throws ReviewManagementException, DBConnectionException, SQLException; throws ReviewManagementDAOException;
/** /**
* To get the comment with id. * To get the comment with id.
* *
* @param commentId id of the comment * @param reviewId id of the review
* @return {@link Review}Review * @return {@link Review}Review
* @throws ReviewManagementException Exceptions of the comment management. * @throws ReviewManagementDAOException Exceptions of the review management DAO.
* @throws DBConnectionException db connection exception
* @throws SQLException sql exception
*/ */
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 uuid uuid of the application
* @param request {@link PaginationRequest}pagination request with offSet and limit * @param request {@link PaginationRequest}pagination request with offSet and limit
* @param tenantId Tenant id * @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 * @throws ReviewManagementDAOException Review management DAO exception
**/ **/
List<Review> getAllReviews(String uuid, PaginationRequest request, int tenantId) List<Review> 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. * 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 * @return {@link List}List of comments
* @throws ReviewManagementException Exceptions of the comment management. * @throws ReviewManagementDAOException Exceptions of the review management DAO.
*/ */
List<Integer> getAllRatingValues(String uuid)throws SQLException, DBConnectionException; List<Integer> getAllRatingValues(String uuid, int tenantId) throws ReviewManagementDAOException;
/** /**
* To get count of comments by application details. * To get count of comments by application details.
@ -122,15 +123,6 @@ import java.util.List;
*/ */
int deleteReview(String username, int reviewId) throws ReviewManagementDAOException; 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. * To delete comments using application details.
* *
@ -142,12 +134,11 @@ import java.util.List;
void deleteReviews(String appType, String appName, String version) throws ReviewManagementException; 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 * @param uuid uuid of the application release
* @return Review count * @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;
} }

@ -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.common.exception.UnsupportedDatabaseEngineException;
import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager; 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.*;
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.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.release.GenericApplicationReleaseDAOImpl;
import org.wso2.carbon.device.application.mgt.core.dao.impl.application.OracleApplicationDAOImpl; import org.wso2.carbon.device.application.mgt.core.dao.impl.application.OracleApplicationDAOImpl;

@ -16,7 +16,7 @@
* under the License. * 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.Log;
import org.apache.commons.logging.LogFactory; 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.ReviewDAO;
import org.wso2.carbon.device.application.mgt.core.dao.common.Util; 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.dao.impl.AbstractDAOImpl;
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
import org.wso2.carbon.device.application.mgt.core.exception.ReviewManagementDAOException; import org.wso2.carbon.device.application.mgt.core.exception.ReviewManagementDAOException;
import java.sql.SQLException; import java.sql.SQLException;
@ -48,14 +47,13 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
private String sql; private String sql;
@Override @Override
public boolean addReview(Review review, String uuid, int tenantId) public boolean addReview(Review review, String uuid, int tenantId) throws ReviewManagementDAOException {
throws ReviewManagementDAOException {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to add review for application release. Application UUID: " + uuid); log.debug("Request received in DAO Layer to add review for application release. Application UUID: " + uuid);
} }
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet rs = 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= ?)," + "VALUES (?,?,?,?,(SELECT ID FROM AP_APP_RELEASE WHERE UUID= ?),"
+ "(SELECT AP_APP_ID FROM AP_APP_RELEASE WHERE UUID=?));"; + "(SELECT AP_APP_ID FROM AP_APP_RELEASE WHERE UUID=?));";
try { try {
@ -102,7 +100,6 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
statement.setString(1, uuid); statement.setString(1, uuid);
statement.setString(2, username); statement.setString(2, username);
statement.setInt(3, tenantId); statement.setInt(3, tenantId);
rs = statement.executeQuery(); rs = statement.executeQuery();
if (rs.next()){ if (rs.next()){
review = new Review(); review = new Review();
@ -128,7 +125,8 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
} }
@Override @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()) { if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to update the comment with ID (" + reviewId + ")"); 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; Connection connection;
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet rs = 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 { try {
connection = this.getDBConnection(); connection = this.getDBConnection();
statement = connection.prepareStatement(sql); statement = connection.prepareStatement(sql);
// statement.setString(1, updatedComment); statement.setString(1, review.getComment());
// statement.setString(2, modifiedBy); statement.setInt(2, review.getRating());
statement.setInt(3, reviewId); statement.setInt(3, reviewId);
statement.executeUpdate(); statement.setString(4, username);
rs = statement.executeQuery(); 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 { } finally {
Util.cleanupResources(statement, rs); Util.cleanupResources(statement, rs);
} }
// todo
return false;
} }
@Override @Override
public Review getReview(int commentId) throws ReviewManagementException { public Review getReview(int reviewId) throws ReviewManagementDAOException {
if (log.isDebugEnabled()) { 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; Connection conn;
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet rs; ResultSet rs = null;
Review review = new Review(); Review review = new Review();
try { try {
conn = this.getDBConnection(); 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 = conn.prepareStatement(sql);
statement.setInt(1, commentId); statement.setInt(1, reviewId);
rs = statement.executeQuery(); rs = statement.executeQuery();
if (rs.next()) { if (rs.next()) {
review.setId(rs.getInt("ID")); review.setId(rs.getInt("ID"));
// review.setTenantId(rs.getInt("TENANT_ID")); review.setComment(rs.getString("COMMENT"));
review.setComment(rs.getString("COMMENT_TEXT"));
review.setCreatedAt(rs.getTimestamp("CREATED_AT")); review.setCreatedAt(rs.getTimestamp("CREATED_AT"));
review.setUsername(rs.getString("CREATED_BY")); review.setUsername(rs.getString("CREATED_BY"));
review.setModifiedAt(rs.getTimestamp("MODEFIED_AT")); review.setModifiedAt(rs.getTimestamp("MODIFIED_AT"));
Util.cleanupResources(statement, rs); review.setRating(rs.getInt("RATING"));
review.setUsername(rs.getString("USERNAME"));
return review; return review;
} }
} catch (SQLException e) { } catch (SQLException e) {
throw new ReviewManagementException( throw new ReviewManagementDAOException(
"SQL Error occurred while retrieving information of the review " + commentId, e); "SQL Error occurred while retrieving information of the review " + reviewId, e);
} catch (DBConnectionException 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 { } finally {
Util.cleanupResources(statement, null); Util.cleanupResources(statement, rs);
} }
return review; return review;
} }
@ -202,11 +204,11 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
List<Review> reviews = new ArrayList<>(); List<Review> reviews = new ArrayList<>();
try { try {
conn = this.getDBConnection(); conn = this.getDBConnection();
sql = "SELECT AP_APP_COMMENT.ID AS ID, AP_APP_COMMENT.COMMENT_TEXT AS COMMENT_TEXT, " sql = "SELECT AP_APP_REVIEW.ID AS ID, AP_APP_REVIEW.COMMENT AS COMMENT, "
+ "AP_APP_COMMENT.CREATED_BY AS CREATED_BY, AP_APP_COMMENT.MODIFIED_BY AS MODIFIED_BY, " + "AP_APP_REVIEW.CREATED_BY AS CREATED_BY, AP_APP_REVIEW.MODIFIED_BY AS MODIFIED_BY, "
+ "AP_APP_COMMENT.PARENT_ID AS PARENT_ID FROM AP_APP_COMMENT, AP_APP_RELEASE WHERE " + "AP_APP_REVIEW.PARENT_ID AS PARENT_ID FROM AP_APP_REVIEW, AP_APP_RELEASE WHERE "
+ "AP_APP_COMMENT.AP_APP_RELEASE_ID=AP_APP_RELEASE.ID AND AP_APP_RELEASE.UUID =? AND " + "AP_APP_REVIEW.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 " + "AP_APP_REVIEW.TENANT_ID = ? AND AP_APP_REVIEW.TENANT_ID = AP_APP_RELEASE.TENANT_ID "
+ "LIMIT ? OFFSET ?;"; + "LIMIT ? OFFSET ?;";
statement = conn.prepareStatement(sql); statement = conn.prepareStatement(sql);
statement.setString(1, uuid); statement.setString(1, uuid);
@ -233,7 +235,7 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
} }
@Override @Override
public List<Integer> getAllRatingValues(String uuid)throws SQLException, DBConnectionException { public List<Integer> getAllRatingValues(String uuid, int tenantId) throws ReviewManagementDAOException {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Getting comment of the application release (" + uuid + ") from the database"); log.debug("Getting comment of the application release (" + uuid + ") from the database");
@ -244,18 +246,24 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
List<Integer> reviews = new ArrayList<>(); List<Integer> reviews = new ArrayList<>();
try { try {
conn = this.getDBConnection(); conn = this.getDBConnection();
// todo sql = "SELECT AP_APP_COMMENT.RATING AS RATING FROM AP_APP_REVIEW, AP_APP_RELEASE WHERE "
sql = "SELECT AP_APP_COMMENT.ID AS ID, AP_APP_COMMENT.COMMENT_TEXT AS " + "AP_APP_REVIEW.AP_APP_RELEASE_ID=AP_APP_RELEASE.ID AND AP_APP_RELEASE.UUID =? AND "
+ "COMMENT_TEXT, AP_APP_COMMENT.CREATED_BY AS CREATED_BY, AP_APP_COMMENT.MODIFIED_BY AS " + "AP_APP_COMMENT.TENANT_ID = AP_APP_RELEASE.TENANT_ID AND AP_APP_COMMENT.TENANT_ID = ?;";
+ "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;";
statement = conn.prepareStatement(sql); statement = conn.prepareStatement(sql);
statement.setString(1, uuid); statement.setString(1, uuid);
statement.setInt(2, tenantId);
rs = statement.executeQuery(); rs = statement.executeQuery();
while (rs.next()) { while (rs.next()) {
reviews.add(rs.getInt("RATING")); 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 { } finally {
Util.cleanupResources(statement, rs); Util.cleanupResources(statement, rs);
} }
@ -263,7 +271,7 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
} }
@Override @Override
public int getReviewCount(PaginationRequest request, String uuid) throws ReviewManagementException { public int getReviewCount(String uuid) throws ReviewManagementDAOException {
int commentCount = 0; int commentCount = 0;
Connection conn; Connection conn;
@ -276,20 +284,20 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
isUuidProvided = true; isUuidProvided = true;
} }
if (isUuidProvided) { if (isUuidProvided) {
sql = "SELECT COUNT(AP_APP_COMMENT.ID) FROM AP_APP_COMMENT,AP_APP_RELEASE " sql = "SELECT COUNT(AP_APP_REVIEW.ID) AS REVIEW_COUNT FROM AP_APP_REVIEW,AP_APP_RELEASE "
+ "WHERE AP_APP_COMMENT.AP_APP_RELEASE_ID= AP_APP_RELEASE.ID AND " + "WHERE AP_APP_REVIEW.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=?;"; + "AP_APP_REVIEW.AP_APP_ID= AP_APP_RELEASE.AP_APP_ID AND AP_APP_RELEASE.UUID=?;";
statement = conn.prepareStatement(sql); statement = conn.prepareStatement(sql);
statement.setString(1, uuid); statement.setString(1, uuid);
rs = statement.executeQuery(); rs = statement.executeQuery();
if (rs.next()) { if (rs.next()) {
commentCount = rs.getInt("COMMENTS_COUNT"); commentCount = rs.getInt("REVIEW_COUNT");
} }
} }
} catch (SQLException e) { } 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) { } 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 { } finally {
Util.cleanupResources(statement, rs); Util.cleanupResources(statement, rs);
} }
@ -302,8 +310,10 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
Connection conn; Connection conn;
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet rs = null;
int commentCount = 0; int commentCount = 0;
try { try {
//todo need to reconstruct the query
conn = this.getDBConnection(); conn = this.getDBConnection();
sql = "SELECT COUNT(ID) AS COMMENT_COUNT FROM AP_APP_COMMENT C, " 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," + "(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(1, version);
statement.setString(2, appName); statement.setString(2, appName);
statement.setString(3, appType); statement.setString(3, appType);
ResultSet rs = statement.executeQuery(); rs = statement.executeQuery();
if (rs.next()) { if (rs.next()) {
commentCount = rs.getInt("COMMENT_COUNT"); commentCount = rs.getInt("COMMENT_COUNT");
} }
} finally { } finally {
Util.cleanupResources(statement, null); Util.cleanupResources(statement, rs);
} }
return commentCount; return commentCount;
} }
@ -345,33 +355,13 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
} }
@Override @Override
public int deleteReviewByAdmin(int reviewId) throws ReviewManagementDAOException { public void deleteReviews(String appType, String appName, String version) throws ReviewManagementException {
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 {
Connection conn; Connection conn;
PreparedStatement statement = null; PreparedStatement statement = null;
try { try {
conn = this.getDBConnection(); conn = this.getDBConnection();
//todo need to reconstruct the query,
sql = "DELETE FROM AP_APP_COMMENT WHERE " sql = "DELETE FROM AP_APP_COMMENT WHERE "
+ "(SELECT AP_APP_RELEASE_ID FROM AP_APP_RELEASE WHERE VERSION=? AND " + "(SELECT AP_APP_RELEASE_ID FROM AP_APP_RELEASE WHERE VERSION=? AND "
+ "(SELECT AP_APP_ID FROM AP_APP WHERE NAME=? AND TYPE=?)) AND " + "(SELECT AP_APP_ID FROM AP_APP WHERE NAME=? AND TYPE=?)) AND "

@ -279,28 +279,28 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
/** /**
* To Update starts of an application release. * 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. * @param rating given stars for the application release.
* @throws ApplicationManagementDAOException Application Management DAO Exception. * @throws ApplicationManagementDAOException Application Management DAO Exception.
*/ */
@Override @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; Connection connection;
PreparedStatement statement = null; 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 { try {
connection = this.getDBConnection(); connection = this.getDBConnection();
statement = connection.prepareStatement(sql); statement = connection.prepareStatement(sql);
statement.setDouble(1, rating); statement.setDouble(1, rating);
statement.setInt(2, ratedUsers); statement.setInt(2, ratedUsers);
statement.setInt(2, id); statement.setString(3, uuid);
return statement.executeUpdate(); statement.executeUpdate();
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new ApplicationManagementDAOException( 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) { } catch (SQLException e) {
throw new ApplicationManagementDAOException( 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 { } finally {
Util.cleanupResources(statement, null); Util.cleanupResources(statement, null);
} }
@ -313,16 +313,17 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
* @throws ApplicationManagementDAOException Application Management DAO Exception. * @throws ApplicationManagementDAOException Application Management DAO Exception.
*/ */
@Override @Override
public Rating getRating(String uuid) throws ApplicationManagementDAOException { public Rating getRating(String uuid, int tenantId) throws ApplicationManagementDAOException {
Connection connection; Connection connection;
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet resultSet = null; ResultSet resultSet = null;
Rating rating = 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 { try {
connection = this.getDBConnection(); connection = this.getDBConnection();
statement = connection.prepareStatement(sql); statement = connection.prepareStatement(sql);
statement.setString(1, uuid); statement.setString(1, uuid);
statement.setInt(2, tenantId);
resultSet = statement.executeQuery(); resultSet = statement.executeQuery();
if (resultSet.next()){ if (resultSet.next()){

@ -96,8 +96,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
application.setUser(new User(userName, tenantId)); application.setUser(new User(userName, tenantId));
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Create Application received for the tenant : " + application.getUser().getTenantId() + " From" log.debug("Create Application received for the tenant : " + tenantId + " From" + " the user : " + userName);
+ " the user : " + application.getUser().getUserName());
} }
@ -185,7 +184,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
ConnectionManagerUtil.rollbackDBTransaction(); ConnectionManagerUtil.rollbackDBTransaction();
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String msg = "Error occurred while getting device type details";
String msg = "Error occurred while getting device type id of " + application.getType();
log.error(msg, e); log.error(msg, e);
ConnectionManagerUtil.rollbackDBTransaction(); ConnectionManagerUtil.rollbackDBTransaction();
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);

@ -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.Review;
import org.wso2.carbon.device.application.mgt.common.PaginationRequest; 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.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.ReviewManagementException;
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException; import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
import org.wso2.carbon.device.application.mgt.common.exception.TransactionManagementException; 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.user.api.UserStoreException;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.TreeMap; import java.util.TreeMap;
@ -64,34 +65,29 @@ public class ReviewManagerImpl implements ReviewManager {
this.applicationReleaseDAO = ApplicationManagementDAOFactory.getApplicationReleaseDAO(); 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); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
boolean isSuccess; boolean isSuccess = false;
try { try {
ConnectionManagerUtil.beginDBTransaction(); ConnectionManagerUtil.beginDBTransaction();
Review existingReview = reviewDAO.haveUerCommented(uuid, username, tenantId); 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); Runnable task = () -> calculateRating(review.getRating(), existingReview.getRating(), uuid);
new Thread(task).start(); new Thread(task).start();
isSuccess = updateReview(review, existingReview.getId(),uuid, false); isSuccess = updateReview(review, existingReview.getId(), uuid, existingReview);
if (isSuccess) { } else if (review.getRating() > 0) {
ConnectionManagerUtil.commitDBTransaction(); Runnable task = () -> calculateRating(review.getRating(), -12345, uuid);
} else { new Thread(task).start();
ConnectionManagerUtil.rollbackDBTransaction();
}
} else {
if (review.getRating() > 0) {
Runnable task = () -> calculateRating(review.getRating(), -12345, uuid);
new Thread(task).start();
}
review.setUsername(username); review.setUsername(username);
isSuccess = this.reviewDAO.addReview(review, uuid, tenantId); isSuccess = this.reviewDAO.addReview(review, uuid, tenantId);
if (isSuccess) { }
ConnectionManagerUtil.commitDBTransaction(); if (isSuccess) {
} else { ConnectionManagerUtil.commitDBTransaction();
ConnectionManagerUtil.rollbackDBTransaction(); } else {
} ConnectionManagerUtil.rollbackDBTransaction();
} }
return isSuccess; return isSuccess;
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
@ -103,49 +99,54 @@ public class ReviewManagerImpl implements ReviewManager {
throw new ReviewManagementException( throw new ReviewManagementException(
"Transaction Management Exception occurs,Review for application release with UUID:" + uuid + "Transaction Management Exception occurs,Review for application release with UUID:" + uuid +
" is failed ", e); " is failed ", e);
} catch (UserStoreException e) {
throw new ReviewManagementException("Error occured while verifying user's permission to update the review.",
e);
} finally { } finally {
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
} }
} }
@Override @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 { throws ReviewManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
Review existingReview;
boolean isSuccess;
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Review updating request is received for the review id " + reviewId); log.debug("Review updating request is received for the review id " + reviewId);
} }
try { try {
ConnectionManagerUtil.openDBConnection(); ConnectionManagerUtil.openDBConnection();
// todo if (existingReview == null) {
if (!username.equals(review.getUsername())) {
throw new ReviewManagementException(
"User " + review.getUsername() + "doesn't match with the logged in user: " + username);
}
if (checkExistence) {
existingReview = this.reviewDAO.getReview(reviewId); existingReview = this.reviewDAO.getReview(reviewId);
if (existingReview != null) { if (existingReview != null && isAuthorizedUser(username, existingReview.getUsername(), tenantId)) {
if (review.getRating() > 0 && review.getRating() != existingReview.getRating()) { 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(); new Thread(task).start();
} }
} else { } 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(); ConnectionManagerUtil.beginDBTransaction();
isSuccess = this.reviewDAO.updateReview(review, reviewId, tenantId); if (this.reviewDAO.updateReview(review, reviewId, username, tenantId) == 1) {
if (isSuccess) {
ConnectionManagerUtil.commitDBTransaction(); ConnectionManagerUtil.commitDBTransaction();
} else { return true;
ConnectionManagerUtil.rollbackDBTransaction();
} }
return isSuccess; ConnectionManagerUtil.rollbackDBTransaction();
} catch (SQLException e) { return false;
throw new ReviewManagementException("SQL Error occurs updating review with review id " + reviewId + ".", } catch (ReviewManagementDAOException e) {
throw new ReviewManagementException("Error occured while updating review with review id " + reviewId + ".",
e); e);
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new ReviewManagementException( throw new ReviewManagementException(
@ -153,6 +154,10 @@ public class ReviewManagerImpl implements ReviewManager {
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
throw new ReviewManagementException( throw new ReviewManagementException(
"Transaction management error occurs when updating review with review id " + reviewId + ".", e); "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 { } finally {
ConnectionManagerUtil.closeDBConnection(); 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 @Override
public boolean deleteReview(String uuid, int reviewId) throws ReviewManagementException { public boolean deleteReview(String uuid, int reviewId)
throws ReviewManagementException, ReviewDoesNotExistException {
Review existingReview; Review existingReview;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
int isReviewDeleted;
try { try {
existingReview = getReview(reviewId); ConnectionManagerUtil.openDBConnection();
existingReview = this.reviewDAO.getReview(reviewId);
if (existingReview == null) { if (existingReview == null) {
throw new ReviewManagementException( throw new ReviewDoesNotExistException(
"Cannot delete a non-existing review for the application with review id" + reviewId); "Cannot delete a non-existing review for the application with review id" + reviewId);
} }
Runnable task = () -> calculateRating(0, existingReview.getRating(), uuid); Runnable task = () -> calculateRating(0, existingReview.getRating(), uuid);
new Thread(task).start(); new Thread(task).start();
ConnectionManagerUtil.beginDBTransaction(); ConnectionManagerUtil.beginDBTransaction();
if (isAdminUser(username, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) { if (isAuthorizedUser(username, existingReview.getUsername(), tenantId)
isReviewDeleted = this.reviewDAO.deleteReviewByAdmin(reviewId); && this.reviewDAO.deleteReview(username, reviewId) == 1) {
if (isReviewDeleted == 1) { ConnectionManagerUtil.commitDBTransaction();
ConnectionManagerUtil.commitDBTransaction(); return true;
return true;
}
} else {
isReviewDeleted = this.reviewDAO.deleteReview(username, reviewId);
if (isReviewDeleted == 1) {
ConnectionManagerUtil.commitDBTransaction();
return true;
}
} }
ConnectionManagerUtil.rollbackDBTransaction();
return false; return false;
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new ReviewManagementException( throw new ReviewManagementException(
@ -272,17 +250,17 @@ public class ReviewManagerImpl implements ReviewManager {
} }
@Override public Rating getRating(String appReleaseUuuid) throws ReviewManagementException { @Override public Rating getRating(String appReleaseUuuid) throws ReviewManagementException {
//todo int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
int appReleaseId = 0;
try { try {
ConnectionManagerUtil.openDBConnection(); ConnectionManagerUtil.openDBConnection();
Rating rating = this.applicationReleaseDAO.getRating(appReleaseUuuid); Rating rating = this.applicationReleaseDAO.getRating(appReleaseUuuid, tenantId);
if (rating == null) { if (rating == null) {
throw new ReviewManagementException("Couldn't find rating for application release id: " + appReleaseId throw new ReviewManagementException(
+ ". Please check the existence of the application relese"); "Couldn't find rating for application release UUID: " + appReleaseUuuid
+ ". Please check the existence of the application release");
} }
List<Integer> ratingValues = this.reviewDAO.getAllRatingValues(appReleaseUuuid); List<Integer> ratingValues = this.reviewDAO.getAllRatingValues(appReleaseUuuid, tenantId);
TreeMap<Integer, Integer> ratingVariety = rating.getRatingVariety(); TreeMap<Integer, Integer> ratingVariety = rating.getRatingVariety();
for (Integer ratingVal : ratingValues) { for (Integer ratingVal : ratingValues) {
if (ratingVariety.containsKey(ratingVal)) { if (ratingVariety.containsKey(ratingVal)) {
@ -296,62 +274,59 @@ public class ReviewManagerImpl implements ReviewManager {
} catch (ApplicationManagementDAOException e) { } catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction(); ConnectionManagerUtil.rollbackDBTransaction();
throw new ReviewManagementException( throw new ReviewManagementException(
"Error occured while updated the rating value of the application release id: " + appReleaseId "Error occured while getting the rating value of the application release uuid: " + appReleaseUuuid,
+ " can not get.", e); e);
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
ConnectionManagerUtil.rollbackDBTransaction(); ConnectionManagerUtil.rollbackDBTransaction();
throw new ReviewManagementException( throw new ReviewManagementException(
"DB Connection error occured while updated the rating value of the application release id: " "DB Connection error occured while getting the rating value of the application release uuid: "
+ appReleaseId + " can not get.", e); + appReleaseUuuid, e);
} catch (SQLException e) { } catch (ReviewManagementDAOException e) {
throw new ReviewManagementException( throw new ReviewManagementException(
"DB Connection error occured while updated the rating value of the application release id: " "Error occured while getting all rating values for the application release UUID: "
+ appReleaseId + " can not get.", e); + appReleaseUuuid, e);
} finally { } finally {
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
} }
} }
private void calculateRating(int newRatingVal, int oldRatingVal, String uuid) { private void calculateRating(int newRatingVal, int oldRatingVal, String uuid) {
// todo need to pass app release id int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
int appReleaseId = 0;
try { try {
ConnectionManagerUtil.beginDBTransaction(); ConnectionManagerUtil.beginDBTransaction();
Rating rating = this.applicationReleaseDAO.getRating(uuid); Rating rating = this.applicationReleaseDAO.getRating(uuid, tenantId);
if (rating == null) { 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 { } else {
double updatedRating; double updatedRating;
int numOfUsers = rating.getNoOfUsers(); int numOfUsers = rating.getNoOfUsers();
double currentRating = rating.getRatingValue() * numOfUsers; double currentRating = rating.getRatingValue() * numOfUsers;
if (oldRatingVal == -12345) { if (oldRatingVal == -12345) {
updatedRating = (currentRating + newRatingVal) / (numOfUsers + 1); updatedRating = (currentRating + newRatingVal) / (numOfUsers + 1);
this.applicationReleaseDAO.updateRatingValue(appReleaseId, updatedRating, numOfUsers + 1); this.applicationReleaseDAO.updateRatingValue(uuid, updatedRating, numOfUsers + 1);
} else if (newRatingVal == 0) { } else if (newRatingVal == 0) {
updatedRating = (currentRating - newRatingVal) / (numOfUsers - 1); updatedRating = (currentRating - newRatingVal) / (numOfUsers - 1);
this.applicationReleaseDAO.updateRatingValue(appReleaseId, updatedRating, numOfUsers - 1); this.applicationReleaseDAO.updateRatingValue(uuid, updatedRating, numOfUsers - 1);
} else { } else {
double tmpVal; double tmpVal;
tmpVal = currentRating - oldRatingVal; tmpVal = currentRating - oldRatingVal;
updatedRating = (tmpVal + newRatingVal) / numOfUsers; updatedRating = (tmpVal + newRatingVal) / numOfUsers;
this.applicationReleaseDAO.updateRatingValue(appReleaseId, updatedRating, numOfUsers); this.applicationReleaseDAO.updateRatingValue(uuid, updatedRating, numOfUsers);
} }
} }
ConnectionManagerUtil.commitDBTransaction(); ConnectionManagerUtil.commitDBTransaction();
} catch (ApplicationManagementDAOException e) { } catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction(); ConnectionManagerUtil.rollbackDBTransaction();
log.error("Error occured while updated the rating value of the application release id: " + appReleaseId log.error("Error occured while updated the rating value of the application release UUID: " + uuid);
+ " can not get.");
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
ConnectionManagerUtil.rollbackDBTransaction(); ConnectionManagerUtil.rollbackDBTransaction();
log.error( log.error(
"Transaction Management Exception occured while updated the rating value of the application release id: " "Transaction Management Exception occured while updated the rating value of the application release UUID: "
+ appReleaseId + " can not get."); + uuid);
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
ConnectionManagerUtil.rollbackDBTransaction(); ConnectionManagerUtil.rollbackDBTransaction();
log.error("DB Connection error occured while updated the rating value of the application release id: " log.error("DB Connection error occured while updated the rating value of the application release UUID: "
+ appReleaseId + " can not get."); + uuid + " can not get.");
} finally { } finally {
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
} }
@ -372,4 +347,20 @@ public class ReviewManagerImpl implements ReviewManager {
.isUserAuthorized(MultitenantUtils.getTenantAwareUsername(username), permission, .isUserAuthorized(MultitenantUtils.getTenantAwareUsername(username), permission,
CarbonConstants.UI_PERMISSION_ACTION); 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);
}
} }

@ -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<UnrestrictedRole> getUnrestrictedRoles(int applicationID, int tenantId) throws VisibilityManagementException {
try {
VisibilityDAO visibilityDAO = ApplicationManagementDAOFactory.getVisibilityDAO();
List<UnrestrictedRole> 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();
// }
// }
}
}

@ -22,15 +22,12 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext; 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.ApplicationManager;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager; 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.ReviewManager;
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager; 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.ConfigurationManager;
import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOFactory; 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.LifecycleStateManger;
import org.wso2.carbon.device.application.mgt.core.lifecycle.config.LifecycleState; import org.wso2.carbon.device.application.mgt.core.lifecycle.config.LifecycleState;
import org.wso2.carbon.device.application.mgt.core.util.ApplicationManagementUtil; 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.ndatasource.core.DataSourceService;
import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.user.core.service.RealmService;
import javax.naming.NamingException;
import java.util.List; import java.util.List;
/** /**
@ -90,10 +86,6 @@ public class ApplicationManagementServiceComponent {
DataHolder.getInstance().setSubscriptionManager(subscriptionManager); DataHolder.getInstance().setSubscriptionManager(subscriptionManager);
bundleContext.registerService(SubscriptionManager.class.getName(), subscriptionManager, null); 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 ApplicationStorageManager applicationStorageManager = ApplicationManagementUtil
.getApplicationStorageManagerInstance(); .getApplicationStorageManagerInstance();
DataHolder.getInstance().setApplicationStorageManager(applicationStorageManager); DataHolder.getInstance().setApplicationStorageManager(applicationStorageManager);

@ -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.ApplicationStorageManager;
import org.wso2.carbon.device.application.mgt.common.services.ReviewManager; import org.wso2.carbon.device.application.mgt.common.services.ReviewManager;
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager; 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.application.mgt.core.lifecycle.LifecycleStateManger;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.user.core.service.RealmService;
@ -42,8 +41,6 @@ public class DataHolder {
private SubscriptionManager subscriptionManager; private SubscriptionManager subscriptionManager;
private UnrestrictedRoleManager unrestrictedRoleManager;
private ApplicationStorageManager applicationStorageManager; private ApplicationStorageManager applicationStorageManager;
private LifecycleStateManger lifecycleStateManger; private LifecycleStateManger lifecycleStateManger;
@ -90,14 +87,6 @@ public class DataHolder {
this.subscriptionManager = subscriptionManager; this.subscriptionManager = subscriptionManager;
} }
public UnrestrictedRoleManager getVisibilityManager() {
return unrestrictedRoleManager;
}
public void setVisibilityManager(UnrestrictedRoleManager unrestrictedRoleManager) {
this.unrestrictedRoleManager = unrestrictedRoleManager;
}
public RealmService getRealmService() { public RealmService getRealmService() {
return realmService; return realmService;
} }

@ -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.ApplicationStorageManager;
import org.wso2.carbon.device.application.mgt.common.services.ReviewManager; import org.wso2.carbon.device.application.mgt.common.services.ReviewManager;
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager; 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.ConfigurationManager;
import org.wso2.carbon.device.application.mgt.core.config.Extension; import org.wso2.carbon.device.application.mgt.core.config.Extension;
@ -51,12 +50,6 @@ public class ApplicationManagementUtil {
return getInstance(extension, ReviewManager.class); 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 { public static SubscriptionManager getSubscriptionManagerInstance() throws InvalidConfigurationException {
ConfigurationManager configurationManager = ConfigurationManager.getInstance(); ConfigurationManager configurationManager = ConfigurationManager.getInstance();
Extension extension = configurationManager.getExtension(Extension.Name.SubscriptionManager); Extension extension = configurationManager.getExtension(Extension.Name.SubscriptionManager);

@ -23,39 +23,18 @@
<DatasourceName>jdbc/APPM_DS</DatasourceName> <DatasourceName>jdbc/APPM_DS</DatasourceName>
<Extensions> <Extensions>
<Extension name="ApplicationUploadManager">
<ClassName>org.wso2.carbon.device.application.mgt.core.impl.ApplicationUploadManagerImpl</ClassName>
<Parameters>
<Parameter name="UploadPath">repository/resources/mobileapps</Parameter>
</Parameters>
</Extension>
<Extension name="ApplicationManager"> <Extension name="ApplicationManager">
<ClassName>org.wso2.carbon.device.application.mgt.core.impl.ApplicationManagerImpl</ClassName> <ClassName>org.wso2.carbon.device.application.mgt.core.impl.ApplicationManagerImpl</ClassName>
</Extension> </Extension>
<Extension name="ApplicationReleaseManager"> <Extension name="ReviewManager">
<ClassName>org.wso2.carbon.device.application.mgt.core.impl.ApplicationReleaseManagerImpl</ClassName>
</Extension>
<Extension name="CategoryManager">
<ClassName>org.wso2.carbon.device.application.mgt.core.impl.CategoryManagerImpl</ClassName>
</Extension>
<Extension name="CommentsManager">
<ClassName>org.wso2.carbon.device.application.mgt.core.impl.ReviewManagerImpl</ClassName> <ClassName>org.wso2.carbon.device.application.mgt.core.impl.ReviewManagerImpl</ClassName>
</Extension> </Extension>
<Extension name="LifecycleStateManager"> <Extension name="LifecycleStateManager">
<ClassName>org.wso2.carbon.device.application.mgt.core.impl.LifecycleStateManagerImpl</ClassName> <ClassName>org.wso2.carbon.device.application.mgt.core.lifecycle.LifecycleStateManger</ClassName>
</Extension>
<Extension name="PlatformManager">
<ClassName>org.wso2.carbon.device.application.mgt.core.impl.PlatformManagerImpl</ClassName>
</Extension> </Extension>
<Extension name="SubscriptionManager"> <Extension name="SubscriptionManager">
<ClassName>org.wso2.carbon.device.application.mgt.core.impl.SubscriptionManagerImpl</ClassName> <ClassName>org.wso2.carbon.device.application.mgt.core.impl.SubscriptionManagerImpl</ClassName>
</Extension> </Extension>
<Extension name="VisibilityManager">
<ClassName>org.wso2.carbon.device.application.mgt.core.impl.UnrestrictedRoleManagerImpl</ClassName>
</Extension>
<Extension name="VisibilityTypeManager">
<ClassName>org.wso2.carbon.device.application.mgt.core.impl.VisibilityTypeManagerImpl</ClassName>
</Extension>
</Extensions> </Extensions>
<LifecycleStates> <LifecycleStates>

@ -37,7 +37,6 @@ public class APIUtil {
private static ApplicationManager applicationManager; private static ApplicationManager applicationManager;
private static ApplicationStorageManager applicationStorageManager; private static ApplicationStorageManager applicationStorageManager;
private static SubscriptionManager subscriptionManager; private static SubscriptionManager subscriptionManager;
private static UnrestrictedRoleManager unrestrictedRoleManager;
public static ApplicationManager getApplicationManager() { public static ApplicationManager getApplicationManager() {
if (applicationManager == null) { if (applicationManager == null) {
@ -116,26 +115,4 @@ public class APIUtil {
return subscriptionManager; 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;
}
} }

@ -28,23 +28,16 @@ import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.Info; import io.swagger.annotations.Info;
import io.swagger.annotations.SwaggerDefinition; import io.swagger.annotations.SwaggerDefinition;
import io.swagger.annotations.Tag; 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.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.application.mgt.common.Filter; 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.publisher.api.beans.ErrorResponse;
import org.wso2.carbon.device.application.mgt.common.Application; 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.ApplicationList;
import org.wso2.carbon.device.application.mgt.common.ApplicationRelease;
import java.util.List;
import javax.validation.Valid; import javax.validation.Valid;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
@ -53,22 +46,22 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
/** /**
* APIs to handle application management related tasks. * APIs to handle application storage management related tasks.
*/ */
@SwaggerDefinition( @SwaggerDefinition(
info = @Info( info = @Info(
version = "1.0.0", version = "1.0.0",
title = "Application Management Service", title = "Application Storage Management Service",
extensions = { extensions = {
@Extension(properties = { @Extension(properties = {
@ExtensionProperty(name = "name", value = "ApplicationManagementService"), @ExtensionProperty(name = "name", value = "ApplicationStorageManagementService"),
@ExtensionProperty(name = "context", value = "/api/application-mgt/v1.0/applications"), @ExtensionProperty(name = "context", value = "/api/application-mgt/v1.0/store-applications"),
}) })
} }
), ),
tags = { tags = {
@Tag(name = "application_management, device_management", description = "Application Management related " @Tag(name = "application_management, device_management", description = "Application Storage Management "
+ "APIs") + "related APIs")
} }
) )
@Scopes( @Scopes(

@ -30,6 +30,7 @@ import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes; 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.publisher.api.beans.ErrorResponse;
import org.wso2.carbon.device.application.mgt.common.Review; import org.wso2.carbon.device.application.mgt.common.Review;
import javax.validation.Valid; import javax.validation.Valid;
@ -47,7 +48,7 @@ import javax.ws.rs.core.Response;
import java.util.List; import java.util.List;
/** /**
* APIs to handle comment management related tasks. * APIs to handle review management related tasks.
*/ */
@SwaggerDefinition( @SwaggerDefinition(
@ -56,51 +57,36 @@ import java.util.List;
title = "Store Management Service", title = "Store Management Service",
extensions = { extensions = {
@Extension(properties = { @Extension(properties = {
@ExtensionProperty(name = "name", value = "CommentManagementService"), @ExtensionProperty(name = "name", value = "ReviewManagementService"),
@ExtensionProperty(name = "context", value = "/api/application-mgt/v1.0/comments"), @ExtensionProperty(name = "context", value = "/api/application-mgt/v1.0/review"),
}) })
} }
), ),
tags = { tags = {
@Tag(name = "store_management", description = "Review Management related " @Tag(name = "store_management", description = "Review Management related APIs")
+ "APIs")
} }
) )
@Scopes( @Scopes(
scopes = { scopes = {
@Scope( @Scope(
name = "Get Comments Details", name = "Get Review Details",
description = "Get comments details", description = "Get review details",
key = "perm:comment:get", key = "perm:app:review:view",
permissions = {"/device-mgt/comment/get"} permissions = {"/device-mgt/review/view"}
),
@Scope(
name = "Add a Review",
description = "Add a comment",
key = "perm:comment:add",
permissions = {"/device-mgt/comment/add"}
), ),
@Scope( @Scope(
name = "Update a Review", name = "Update a Review",
description = "Update a Review", description = "Update a comment",
key = "perm:comment:update", key = "perm:app:review:update",
permissions = {"/device-mgt/comment/update"} permissions = {"/device-mgt/review/update"}
),
@Scope(
name = "Delete a Review",
description = "Delete a comment",
key = "perm:comment:delete",
permissions = {"/device-mgt/comment/delete"}
), ),
} }
) )
@Path("/review") @Path("/review")
@Api(value = "Comments Management", description = "This API carries all comments management related operations " + @Api(value = "Review Management", description = "This API carries all review management related operations such as get "
"such as get all the comments, add comment, etc.") + "all the reviews, add review, etc.")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public interface ReviewManagementAPI { public interface ReviewManagementAPI {
String SCOPE = "scope"; String SCOPE = "scope";
@ -110,12 +96,12 @@ public interface ReviewManagementAPI {
@ApiOperation( @ApiOperation(
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "GET", httpMethod = "GET",
value = "get comments", value = "get reviews",
notes = "Get all comments", notes = "Get all reviews",
tags = "Store Management", tags = "Store Management",
extensions = { extensions = {
@Extension(properties = { @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 = { value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
message = "OK. \n Successfully retrieved comments.", message = "OK. \n Successfully retrieved reviews.",
response = List.class, response = PaginationResult.class,
responseContainer = "List"), responseContainer = "PaginationResult"),
@ApiResponse(
code = 404,
message = "Not Found. \n No activity found with the given ID.",
response = ErrorResponse.class),
@ApiResponse( @ApiResponse(
code = 500, 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 = ErrorResponse.class)
}) })
Response getAllReviews( Response getAllReviews(
@ApiParam( @ApiParam(
name="uuid", name="uuid",
value="uuid of the released version of application.", value="uuid of the application release.",
required = true) required = true)
@PathParam("uuid") @PathParam("uuid")
String uuid, String uuid,
@ApiParam( @ApiParam(
name="offSet", name="offSet",
value="Starting comment number.",defaultValue = "1", value="Starting review number.",defaultValue = "0")
required = false)
@QueryParam("offSet") @QueryParam("offSet")
int offSet, int offSet,
@ApiParam( @ApiParam(
name="limit", name="limit",
value = "Limit of paginated comments",defaultValue = "20", value = "Limit of paginated reviews",defaultValue = "20")
required = false)
@QueryParam("limit") @QueryParam("limit")
int limit); int limit);
@ -170,7 +150,7 @@ public interface ReviewManagementAPI {
tags = "Store Management", tags = "Store Management",
extensions = { extensions = {
@Extension(properties = { @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", tags = "Store Management",
extensions = { extensions = {
@Extension(properties = { @Extension(properties = {
@ExtensionProperty(name = SCOPE, value = "perm:store:edit") @ExtensionProperty(name = SCOPE, value = "perm:app:review:update")
}) })
} }
) )
@ApiResponses( @ApiResponses(
value = { value = {
@ApiResponse( @ApiResponse(
code = 201, code = 200,
message = "OK. \n Successfully updated review.", message = "OK. \n Successfully updated review.",
response = Review.class), response = Review.class),
@ApiResponse( @ApiResponse(
code = 400, code = 400,
message = "Bad Request. \n Invalid request or validation error."), 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( @ApiResponse(
code = 500, code = 500,
message = "Internal Server Error. \n Error occurred while updating the new review.", message = "Internal Server Error. \n Error occurred while updating the new review.",
@ -267,7 +243,7 @@ public interface ReviewManagementAPI {
tags = "Store Management", tags = "Store Management",
extensions = { extensions = {
@Extension(properties = { @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 = { value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
message = "OK. \n Successfully deleted the comment"), message = "OK. \n Successfully deleted the review"),
@ApiResponse( @ApiResponse(
code = 404, code = 404,
message = "Not Found. \n No activity found with the given ID.", message = "Not Found. \n No activity found with the given ID.",
response = ErrorResponse.class), response = ErrorResponse.class),
@ApiResponse( @ApiResponse(
code = 500, 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) response = ErrorResponse.class)
}) })
@ -300,17 +276,17 @@ public interface ReviewManagementAPI {
@PathParam("reviewId") int reviewId); @PathParam("reviewId") int reviewId);
@GET @GET
@Path("/{uuid}/{stars}") @Path("/{uuid}/rating")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@ApiOperation( @ApiOperation(
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "GET", httpMethod = "GET",
value = "get stars", value = "get ratings",
notes = "Get all stars", notes = "Get all ratings",
tags = "Store Management", tags = "Store Management",
extensions = { extensions = {
@Extension(properties = { @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 = { value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
message = "OK. \n Successfully retrieved stars.", message = "OK. \n Successfully retrieved ratings.",
response = List.class, response = List.class,
responseContainer = "List"), responseContainer = "List"),
@ApiResponse( @ApiResponse(
code = 500, 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) response = ErrorResponse.class)
}) })

@ -15,7 +15,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * 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.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;

@ -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.PaginationResult;
import org.wso2.carbon.device.application.mgt.common.Rating; 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.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.ApplicationManager;
import org.wso2.carbon.device.application.mgt.common.services.ReviewManager; import org.wso2.carbon.device.application.mgt.common.services.ReviewManager;
import org.wso2.carbon.device.application.mgt.store.api.APIUtil; 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); log.error("Error occured while getting the application for application UUID: " + uuid);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR) return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
.entity("").build(); .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) { @PathParam("reviewId") int reviewId) {
ReviewManager reviewManager = APIUtil.getReviewManager(); ReviewManager reviewManager = APIUtil.getReviewManager();
try { try {
if (reviewManager.updateReview(review, reviewId, uuid, true)) { if (reviewManager.updateReview(review, reviewId, uuid, null)) {
return Response.status(Response.Status.OK).entity(review).build(); return Response.status(Response.Status.OK).entity(review).build();
} else { } else {
String msg = "Review updating failed. Please contact the administrator"; 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."; String msg = "Error occurred while retrieving comments.";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); 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(); ReviewManager reviewManager = APIUtil.getReviewManager();
try { try {
if (reviewId == 0) { if (reviewManager.deleteReview(uuid, reviewId)) {
return Response.status(Response.Status.NOT_FOUND).entity("Review not found").build();
} else if (reviewManager.deleteReview(uuid, reviewId)) {
return Response.status(Response.Status.OK).entity("Review is deleted successfully.").build(); return Response.status(Response.Status.OK).entity("Review is deleted successfully.").build();
} else { } else {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Review deleting is failed.") 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."; String msg = "Error occurred while deleting the comment.";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); 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();
} }
} }

@ -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.ApplicationInstallResponse;
import org.wso2.carbon.device.application.mgt.common.EnterpriseInstallationDetails; 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.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.InstallationDetails;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager; import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import javax.validation.Valid; import javax.validation.Valid;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.HashMap;
import java.util.List; import java.util.List;
/** /**

@ -25,27 +25,15 @@
<Extension name="ApplicationManager"> <Extension name="ApplicationManager">
<ClassName>org.wso2.carbon.device.application.mgt.core.impl.ApplicationManagerImpl</ClassName> <ClassName>org.wso2.carbon.device.application.mgt.core.impl.ApplicationManagerImpl</ClassName>
</Extension> </Extension>
<Extension name="ApplicationReleaseManager">
<ClassName>org.wso2.carbon.device.application.mgt.core.impl.ApplicationReleaseManagerImpl</ClassName>
</Extension>
<Extension name="CategoryManager">
<ClassName>org.wso2.carbon.device.application.mgt.core.impl.CategoryManagerImpl</ClassName>
</Extension>
<Extension name="ReviewManager"> <Extension name="ReviewManager">
<ClassName>org.wso2.carbon.device.application.mgt.core.impl.ReviewManagerImpl</ClassName> <ClassName>org.wso2.carbon.device.application.mgt.core.impl.ReviewManagerImpl</ClassName>
</Extension> </Extension>
<Extension name="LifecycleStateManager"> <Extension name="LifecycleStateManager">
<ClassName>org.wso2.carbon.device.application.mgt.core.impl.LifecycleStateManagerImpl</ClassName> <ClassName>org.wso2.carbon.device.application.mgt.core.lifecycle.LifecycleStateManger</ClassName>
</Extension>
<Extension name="PlatformManager">
<ClassName>org.wso2.carbon.device.application.mgt.core.impl.PlatformManagerImpl</ClassName>
</Extension> </Extension>
<Extension name="SubscriptionManager"> <Extension name="SubscriptionManager">
<ClassName>org.wso2.carbon.device.application.mgt.core.impl.SubscriptionManagerImpl</ClassName> <ClassName>org.wso2.carbon.device.application.mgt.core.impl.SubscriptionManagerImpl</ClassName>
</Extension> </Extension>
<Extension name="VisibilityManager">
<ClassName>org.wso2.carbon.device.application.mgt.core.impl.UnrestrictedRoleManagerImpl</ClassName>
</Extension>
<Extension name="ApplicationStorageManager"> <Extension name="ApplicationStorageManager">
<ClassName>org.wso2.carbon.device.application.mgt.core.impl.ApplicationStorageManagerImpl</ClassName> <ClassName>org.wso2.carbon.device.application.mgt.core.impl.ApplicationStorageManagerImpl</ClassName>
<Parameters> <Parameters>
@ -53,12 +41,6 @@
<Parameter name="MaxScreenShotCount">6</Parameter> <Parameter name="MaxScreenShotCount">6</Parameter>
</Parameters> </Parameters>
</Extension> </Extension>
<Extension name="PlatformStorageManager">
<ClassName>org.wso2.carbon.device.application.mgt.core.impl.PlatformStorageManagerImpl</ClassName>
<Parameters>
<Parameter name="StoragePath">repository/resources/platforms</Parameter>
</Parameters>
</Extension>
</Extensions> </Extensions>
<!-- This is for publisher lifecycle --> <!-- This is for publisher lifecycle -->

Loading…
Cancel
Save