Improve review management

feature/appm-store/pbac
lasanthaDLPDS 6 years ago
parent 25d9569952
commit a1b8632aa4

@ -0,0 +1,67 @@
package org.wso2.carbon.device.application.mgt.common;
/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.util.ArrayList;
import java.util.List;
public class ReviewNode<T> {
private T data = null;
private List<ReviewNode<T>> children = new ArrayList<>();
private ReviewNode<T> parent = null;
public ReviewNode(T data) {
this.data = data;
}
public ReviewNode<T> addChild(ReviewNode<T> child) {
child.setParent(this);
this.children.add(child);
return child;
}
public void addChildren(List<ReviewNode<T>> children) {
children.forEach(each -> each.setParent(this));
this.children.addAll(children);
}
public List<ReviewNode<T>> getChildren() {
return children;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
private void setParent(ReviewNode<T> parent) {
this.parent = parent;
}
public ReviewNode<T> getParent() {
return parent;
}
}

@ -94,6 +94,9 @@ import java.util.List;
List<ReviewDTO> getAllReviews(String uuid, PaginationRequest request, int tenantId) List<ReviewDTO> getAllReviews(String uuid, PaginationRequest request, int tenantId)
throws ReviewManagementDAOException; throws ReviewManagementDAOException;
List<ReviewDTO> getReplyComments(int parentId, PaginationRequest request, int tenantId)
throws ReviewManagementDAOException;
/** /**
* 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 uuid UUID of the application release

@ -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.Review.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;

@ -30,7 +30,7 @@ import org.wso2.carbon.device.application.mgt.common.Filter;
import org.wso2.carbon.device.application.mgt.common.dto.TagDTO; import org.wso2.carbon.device.application.mgt.common.dto.TagDTO;
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.core.dao.ApplicationDAO; import org.wso2.carbon.device.application.mgt.core.dao.ApplicationDAO;
import org.wso2.carbon.device.application.mgt.core.dao.common.Util; import org.wso2.carbon.device.application.mgt.core.util.DAOUtil;
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.ApplicationManagementDAOException;
import org.wso2.carbon.device.application.mgt.core.exception.UnexpectedServerErrorException; import org.wso2.carbon.device.application.mgt.core.exception.UnexpectedServerErrorException;
@ -90,7 +90,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} catch (SQLException e) { } catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while adding the application", e); throw new ApplicationManagementDAOException("Error occurred while adding the application", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
@ -120,7 +120,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
throw new ApplicationManagementDAOException( throw new ApplicationManagementDAOException(
"DB connection error occured while checking whether application exist or not.", e); "DB connection error occured while checking whether application exist or not.", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
@ -248,7 +248,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} }
stmt.setInt(paramIndex, filter.getOffset()); stmt.setInt(paramIndex, filter.getOffset());
rs = stmt.executeQuery(); rs = stmt.executeQuery();
return Util.loadApplications(rs); return DAOUtil.loadApplications(rs);
} catch (SQLException e) { } catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while getting application list for the tenant" throw new ApplicationManagementDAOException("Error occurred while getting application list for the tenant"
+ " " + tenantId + ". While executing " + sql, e); + " " + tenantId + ". While executing " + sql, e);
@ -259,7 +259,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} catch (JSONException e) { } catch (JSONException e) {
throw new ApplicationManagementDAOException("Error occurred while parsing JSON ", e); throw new ApplicationManagementDAOException("Error occurred while parsing JSON ", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
@ -294,7 +294,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection for " throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection for "
+ "getting app release id", e); + "getting app release id", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
@ -338,7 +338,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e); throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
return count; return count;
} }
@ -373,7 +373,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
+ appType + "and app name " + appName); + appType + "and app name " + appName);
} }
return Util.loadApplication(rs); return DAOUtil.loadApplication(rs);
} catch (SQLException e) { } catch (SQLException e) {
throw new ApplicationManagementDAOException( throw new ApplicationManagementDAOException(
@ -386,7 +386,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} catch (UnexpectedServerErrorException e) { } catch (UnexpectedServerErrorException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e); throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
@ -416,7 +416,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
log.debug("Successfully retrieved basic details of the application with the id:" + id); log.debug("Successfully retrieved basic details of the application with the id:" + id);
} }
return Util.loadApplication(rs); return DAOUtil.loadApplication(rs);
} catch (SQLException e) { } catch (SQLException e) {
throw new ApplicationManagementDAOException( throw new ApplicationManagementDAOException(
@ -429,7 +429,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} catch (UnexpectedServerErrorException e) { } catch (UnexpectedServerErrorException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e); throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
@ -490,7 +490,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
+ releaseUuid); + releaseUuid);
} }
return Util.loadApplication(rs); return DAOUtil.loadApplication(rs);
} catch (SQLException e) { } catch (SQLException e) {
throw new ApplicationManagementDAOException( throw new ApplicationManagementDAOException(
@ -503,7 +503,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} catch (UnexpectedServerErrorException e) { } catch (UnexpectedServerErrorException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e); throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
@ -562,7 +562,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
log.debug("Successfully retrieved basic details of the application with the id " log.debug("Successfully retrieved basic details of the application with the id "
+ applicationId); + applicationId);
} }
return Util.loadApplication(rs); return DAOUtil.loadApplication(rs);
} catch (SQLException e) { } catch (SQLException e) {
throw new ApplicationManagementDAOException( throw new ApplicationManagementDAOException(
"Error occurred while getting application details with app id " + applicationId + "Error occurred while getting application details with app id " + applicationId +
@ -574,7 +574,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} catch (UnexpectedServerErrorException e) { } catch (UnexpectedServerErrorException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e); throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
@ -607,7 +607,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e); throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
@ -662,7 +662,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} catch (SQLException e) { } catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while deleting the application: ", e); throw new ApplicationManagementDAOException("Error occurred while deleting the application: ", e);
} finally { } finally {
Util.cleanupResources(stmt, null); DAOUtil.cleanupResources(stmt, null);
} }
} }
@ -693,7 +693,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} catch (SQLException e) { } catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while adding tags", e); throw new ApplicationManagementDAOException("Error occurred while adding tags", e);
} finally { } finally {
Util.cleanupResources(stmt, null); DAOUtil.cleanupResources(stmt, null);
} }
} }
@ -730,7 +730,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} catch (SQLException e) { } catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while adding tags", e); throw new ApplicationManagementDAOException("Error occurred while adding tags", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
@ -767,7 +767,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} catch (SQLException e) { } catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while getting categories", e); throw new ApplicationManagementDAOException("Error occurred while getting categories", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
@ -859,7 +859,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} catch (SQLException e) { } catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while adding categories.", e); throw new ApplicationManagementDAOException("Error occurred while adding categories.", e);
} finally { } finally {
Util.cleanupResources(stmt, null); DAOUtil.cleanupResources(stmt, null);
} }
} }
@ -892,7 +892,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} catch (SQLException e) { } catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while adding data into category mapping.", e); throw new ApplicationManagementDAOException("Error occurred while adding data into category mapping.", e);
} finally { } finally {
Util.cleanupResources(stmt, null); DAOUtil.cleanupResources(stmt, null);
} }
} }
@ -1101,7 +1101,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} catch (SQLException e) { } catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while adding tags", e); throw new ApplicationManagementDAOException("Error occurred while adding tags", e);
} finally { } finally {
Util.cleanupResources(stmt, null); DAOUtil.cleanupResources(stmt, null);
} }
} }
@ -1459,7 +1459,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
throw new ApplicationManagementDAOException( throw new ApplicationManagementDAOException(
"Error occurred while deleting tags of application: " + applicationId, e); "Error occurred while deleting tags of application: " + applicationId, e);
} finally { } finally {
Util.cleanupResources(stmt, null); DAOUtil.cleanupResources(stmt, null);
} }
} }
@ -1497,7 +1497,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
ApplicationDTO application = null; ApplicationDTO application = null;
while (rs.next()) { while (rs.next()) {
ApplicationReleaseDTO appRelease = Util.loadApplicationRelease(rs); ApplicationReleaseDTO appRelease = DAOUtil.loadApplicationRelease(rs);
application = new ApplicationDTO(); application = new ApplicationDTO();
application.setId(rs.getInt("APP_ID")); application.setId(rs.getInt("APP_ID"));
@ -1528,7 +1528,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e); throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
@ -1557,7 +1557,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
} catch (SQLException e) { } catch (SQLException e) {
throw new ApplicationManagementDAOException("Error occurred while getting application List", e); throw new ApplicationManagementDAOException("Error occurred while getting application List", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }

@ -21,20 +21,6 @@ package org.wso2.carbon.device.application.mgt.core.dao.impl.application;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.json.JSONException;
import org.wso2.carbon.device.application.mgt.common.AppLifecycleState;
import org.wso2.carbon.device.application.mgt.common.ApplicationList;
import org.wso2.carbon.device.application.mgt.common.Filter;
import org.wso2.carbon.device.application.mgt.common.Pagination;
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
import org.wso2.carbon.device.application.mgt.core.dao.common.Util;
import org.wso2.carbon.device.application.mgt.core.dao.impl.application.GenericApplicationDAOImpl;
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/** /**
* This is a ApplicationDAO Implementation specific to Oracle. * This is a ApplicationDAO Implementation specific to Oracle.

@ -21,13 +21,11 @@ package org.wso2.carbon.device.application.mgt.core.dao.impl.application.release
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.application.mgt.common.AppLifecycleState;
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationReleaseDTO; import org.wso2.carbon.device.application.mgt.common.dto.ApplicationReleaseDTO;
import org.wso2.carbon.device.application.mgt.common.ApplicationReleaseArtifactPaths;
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.exception.DBConnectionException; import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationReleaseDAO; import org.wso2.carbon.device.application.mgt.core.dao.ApplicationReleaseDAO;
import org.wso2.carbon.device.application.mgt.core.dao.common.Util; import org.wso2.carbon.device.application.mgt.core.util.DAOUtil;
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.ApplicationManagementDAOException;
@ -118,7 +116,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
throw new ApplicationManagementDAOException( throw new ApplicationManagementDAOException(
"Database Connection Exception while trying to release a new version", e); "Database Connection Exception while trying to release a new version", e);
} finally { } finally {
Util.cleanupResources(statement, resultSet); DAOUtil.cleanupResources(statement, resultSet);
} }
} }
@ -160,7 +158,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
resultSet = statement.executeQuery(); resultSet = statement.executeQuery();
if (resultSet.next()) { if (resultSet.next()) {
return Util.loadApplicationRelease(resultSet); return DAOUtil.loadApplicationRelease(resultSet);
} }
return null; return null;
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
@ -170,7 +168,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
throw new ApplicationManagementDAOException( throw new ApplicationManagementDAOException(
"Error while getting release details of the application " + applicationName + " and version " + versionName + " , while executing the query " + sql, e); "Error while getting release details of the application " + applicationName + " and version " + versionName + " , while executing the query " + sql, e);
} finally { } finally {
Util.cleanupResources(statement, resultSet); DAOUtil.cleanupResources(statement, resultSet);
} }
} }
@ -207,7 +205,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
resultSet = statement.executeQuery(); resultSet = statement.executeQuery();
if (resultSet.next()) { if (resultSet.next()) {
return Util.loadApplicationRelease(resultSet); return DAOUtil.loadApplicationRelease(resultSet);
} }
return null; return null;
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
@ -219,7 +217,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
"Error while getting release details of the application id: " + applicationId "Error while getting release details of the application id: " + applicationId
+ " and theUUID of the application " + "release: " + releaseUuid + " , while executing the query " + sql, e); + " and theUUID of the application " + "release: " + releaseUuid + " , while executing the query " + sql, e);
} finally { } finally {
Util.cleanupResources(statement, resultSet); DAOUtil.cleanupResources(statement, resultSet);
} }
} }
@ -255,7 +253,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
statement.setInt(2, tenantId); statement.setInt(2, tenantId);
try (ResultSet resultSet = statement.executeQuery()) { try (ResultSet resultSet = statement.executeQuery()) {
if (resultSet.next()) { if (resultSet.next()) {
return Util.loadAppRelease(resultSet); return DAOUtil.loadAppRelease(resultSet);
} }
return null; return null;
} }
@ -299,7 +297,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
resultSet = statement.executeQuery(); resultSet = statement.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
ApplicationReleaseDTO applicationRelease = Util.loadApplicationRelease(resultSet); ApplicationReleaseDTO applicationRelease = DAOUtil.loadApplicationRelease(resultSet);
applicationReleases.add(applicationRelease); applicationReleases.add(applicationRelease);
} }
return applicationReleases; return applicationReleases;
@ -311,7 +309,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
"Error while getting all the release details of the app ID: " + applicationId "Error while getting all the release details of the app ID: " + applicationId
+ ", while executing the query " + sql, e); + ", while executing the query " + sql, e);
} finally { } finally {
Util.cleanupResources(statement, resultSet); DAOUtil.cleanupResources(statement, resultSet);
} }
} }
@ -342,7 +340,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
resultSet = statement.executeQuery(); resultSet = statement.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
ApplicationReleaseDTO appRelease = Util.loadApplicationRelease(resultSet); ApplicationReleaseDTO appRelease = DAOUtil.loadApplicationRelease(resultSet);
applicationReleases.add(appRelease); applicationReleases.add(appRelease);
} }
return applicationReleases; return applicationReleases;
@ -354,7 +352,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
"Error while getting all the release details of the app id" + appId + " application" "Error while getting all the release details of the app id" + appId + " application"
+ ", while executing the query " + sql, e); + ", while executing the query " + sql, e);
} finally { } finally {
Util.cleanupResources(statement, resultSet); DAOUtil.cleanupResources(statement, resultSet);
} }
} }
@ -384,7 +382,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
throw new ApplicationManagementDAOException( throw new ApplicationManagementDAOException(
"SQL exception while updating the release rating value ,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); DAOUtil.cleanupResources(statement, null);
} }
} }
@ -420,7 +418,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
throw new ApplicationManagementDAOException( throw new ApplicationManagementDAOException(
"SQL exception while updating the release ,while executing the query " + sql, e); "SQL exception while updating the release ,while executing the query " + sql, e);
} finally { } finally {
Util.cleanupResources(statement, resultSet); DAOUtil.cleanupResources(statement, resultSet);
} }
} }
@ -487,7 +485,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
throw new ApplicationManagementDAOException( throw new ApplicationManagementDAOException(
"SQL exception while updating the release ,while executing the query " + sql, e); "SQL exception while updating the release ,while executing the query " + sql, e);
} finally { } finally {
Util.cleanupResources(statement, null); DAOUtil.cleanupResources(statement, null);
} }
return applicationReleaseDTO; return applicationReleaseDTO;
} }
@ -512,7 +510,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
"SQL exception while deleting the release for release ID: " + id + ",while executing the query sql" "SQL exception while deleting the release for release ID: " + id + ",while executing the query sql"
, e); , e);
} finally { } finally {
Util.cleanupResources(statement, null); DAOUtil.cleanupResources(statement, null);
} }
} }
@ -566,7 +564,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e); throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
@ -603,7 +601,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
throw new ApplicationManagementDAOException( throw new ApplicationManagementDAOException(
"Error occurred while obtaining the DB connection to get application release package name.", e); "Error occurred while obtaining the DB connection to get application release package name.", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
@ -640,7 +638,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e); throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
@ -674,7 +672,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e); throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
@ -721,7 +719,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e); throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }

@ -24,7 +24,7 @@ import org.wso2.carbon.device.application.mgt.common.AppLifecycleState;
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.exception.DBConnectionException; import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
import org.wso2.carbon.device.application.mgt.core.dao.LifecycleStateDAO; import org.wso2.carbon.device.application.mgt.core.dao.LifecycleStateDAO;
import org.wso2.carbon.device.application.mgt.core.dao.common.Util; import org.wso2.carbon.device.application.mgt.core.util.DAOUtil;
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.LifeCycleManagementDAOException; import org.wso2.carbon.device.application.mgt.core.exception.LifeCycleManagementDAOException;
@ -64,7 +64,7 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif
throw new LifeCycleManagementDAOException("Error occurred while obtaining the DB connection to get latest" throw new LifeCycleManagementDAOException("Error occurred while obtaining the DB connection to get latest"
+ " lifecycle state for a specific application", e); + " lifecycle state for a specific application", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
@ -89,7 +89,7 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif
throw new LifeCycleManagementDAOException("Error occurred while obtaining the DB connection to get latest" throw new LifeCycleManagementDAOException("Error occurred while obtaining the DB connection to get latest"
+ " lifecycle state for a specific application", e); + " lifecycle state for a specific application", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
@ -120,7 +120,7 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif
throw new LifeCycleManagementDAOException("Error occurred while obtaining the DB connection to get latest" throw new LifeCycleManagementDAOException("Error occurred while obtaining the DB connection to get latest"
+ " lifecycle state for a specific application", e); + " lifecycle state for a specific application", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
@ -199,7 +199,7 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif
log.error("Error occurred while adding lifecycle: " + state.getCurrentState(), e); log.error("Error occurred while adding lifecycle: " + state.getCurrentState(), e);
throw new LifeCycleManagementDAOException("Error occurred while adding lifecycle: " + state.getCurrentState(), e); throw new LifeCycleManagementDAOException("Error occurred while adding lifecycle: " + state.getCurrentState(), e);
} finally { } finally {
Util.cleanupResources(stmt, null); DAOUtil.cleanupResources(stmt, null);
} }
} }

@ -16,20 +16,21 @@
* under the License. * under the License.
* *
*/ */
package org.wso2.carbon.device.application.mgt.core.dao.impl.Review; 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;
import org.wso2.carbon.device.application.mgt.common.ReviewTmp;
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.dto.ReviewDTO; import org.wso2.carbon.device.application.mgt.common.dto.ReviewDTO;
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.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.exception.UnexpectedServerErrorException;
import org.wso2.carbon.device.application.mgt.core.util.DAOUtil;
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.ReviewManagementDAOException; import org.wso2.carbon.device.application.mgt.core.exception.ReviewManagementDAOException;
import org.wso2.carbon.device.application.mgt.core.util.Constants;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -165,7 +166,7 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new ReviewManagementDAOException("Error occured while getting the db connection to update reviewTmp"); throw new ReviewManagementDAOException("Error occured while getting the db connection to update reviewTmp");
} finally { } finally {
Util.cleanupResources(statement, rs); DAOUtil.cleanupResources(statement, rs);
} }
} }
@ -194,27 +195,17 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
statement = conn.prepareStatement(sql); statement = conn.prepareStatement(sql);
statement.setInt(1, reviewId); statement.setInt(1, reviewId);
rs = statement.executeQuery(); rs = statement.executeQuery();
if (rs.next()) { return DAOUtil.loadReview(rs);
ReviewDTO reviewDTO = new ReviewDTO();
reviewDTO.setId(rs.getInt("ID"));
reviewDTO.setContent(rs.getString("COMMENT"));
reviewDTO.setCreatedAt(rs.getTimestamp("CREATED_AT"));
reviewDTO.setModifiedAt(rs.getTimestamp("MODIFIED_AT"));
reviewDTO.setRating(rs.getInt("RATING"));
reviewDTO.setRootParentId(rs.getInt("ROOT_PARENT_ID"));
reviewDTO.setImmediateParentId(rs.getInt("IMMEDIATE_PARENT_ID"));
reviewDTO.setUsername(rs.getString("USERNAME"));
return reviewDTO;
}
return null;
} catch (SQLException e) { } catch (SQLException e) {
throw new ReviewManagementDAOException( throw new ReviewManagementDAOException(
"SQL Error occurred while retrieving information of the reviewTmp " + reviewId, e); "SQL Error occurred while retrieving information of the reviewTmp " + reviewId, e);
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new ReviewManagementDAOException( throw new ReviewManagementDAOException(
"DB Connection Exception occurred while retrieving information of the reviewTmp " + reviewId, e); "DB Connection Exception occurred while retrieving information of the reviewTmp " + reviewId, e);
} catch (UnexpectedServerErrorException e) {
throw new ReviewManagementDAOException("Found more than one review for review ID: " + reviewId, e);
} finally { } finally {
Util.cleanupResources(statement, rs); DAOUtil.cleanupResources(statement, rs);
} }
} }
@ -244,27 +235,17 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
statement.setInt(1, reviewId); statement.setInt(1, reviewId);
statement.setInt(2, appReleaseId); statement.setInt(2, appReleaseId);
rs = statement.executeQuery(); rs = statement.executeQuery();
if (rs.next()) { return DAOUtil.loadReview(rs);
ReviewDTO reviewDTO = new ReviewDTO();
reviewDTO.setId(rs.getInt("ID"));
reviewDTO.setContent(rs.getString("COMMENT"));
reviewDTO.setCreatedAt(rs.getTimestamp("CREATED_AT"));
reviewDTO.setModifiedAt(rs.getTimestamp("MODIFIED_AT"));
reviewDTO.setRating(rs.getInt("RATING"));
reviewDTO.setRootParentId(rs.getInt("ROOT_PARENT_ID"));
reviewDTO.setImmediateParentId(rs.getInt("IMMEDIATE_PARENT_ID"));
reviewDTO.setUsername(rs.getString("USERNAME"));
return reviewDTO;
}
return null;
} catch (SQLException e) { } catch (SQLException e) {
throw new ReviewManagementDAOException( throw new ReviewManagementDAOException(
"SQL Error occurred while retrieving information of the reviewTmp " + reviewId, e); "SQL Error occurred while retrieving information of the reviewTmp " + reviewId, e);
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new ReviewManagementDAOException( throw new ReviewManagementDAOException(
"DB Connection Exception occurred while retrieving information of the reviewTmp " + reviewId, e); "DB Connection Exception occurred while retrieving information of the reviewTmp " + reviewId, e);
} catch (UnexpectedServerErrorException e) {
throw new ReviewManagementDAOException("Found more than one review for review ID: " + reviewId, e);
} finally { } finally {
Util.cleanupResources(statement, rs); DAOUtil.cleanupResources(statement, rs);
} }
} }
@ -277,8 +258,6 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
log.debug("Getting comment of the application release (" + uuid + ") from the database"); log.debug("Getting comment of the application release (" + uuid + ") from the database");
} }
Connection conn; Connection conn;
PreparedStatement statement = null;
ResultSet rs = null;
List<ReviewDTO> reviewDTOs = new ArrayList<>(); List<ReviewDTO> reviewDTOs = new ArrayList<>();
try { try {
conn = this.getDBConnection(); conn = this.getDBConnection();
@ -297,32 +276,67 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
+ "AP_APP_RELEASE.UUID = ? AND " + "AP_APP_RELEASE.UUID = ? AND "
+ "AP_APP_REVIEW.TENANT_ID = ? AND " + "AP_APP_REVIEW.TENANT_ID = ? AND "
+ "AP_APP_REVIEW.TENANT_ID = AP_APP_RELEASE.TENANT_ID " + "AP_APP_REVIEW.TENANT_ID = AP_APP_RELEASE.TENANT_ID "
+ "LIMIT ? OFFSET ?";
try (PreparedStatement statement = conn.prepareStatement(sql)) {
statement.setString(1, uuid);
statement.setInt(2, tenantId);
statement.setInt(3, request.getLimit());
statement.setInt(4, request.getOffSet());
try (ResultSet rs = statement.executeQuery()) {
reviewDTOs = DAOUtil.loadReviews(rs);
}
}
} catch (DBConnectionException e) {
throw new ReviewManagementDAOException(
"Error occurred while obtaining the DB connection when verifying application existence", e);
} catch (SQLException e) {
throw new ReviewManagementDAOException("DB connection error occurred while getting all reviewTmps", e);
} return reviewDTOs;
}
@Override
public List<ReviewDTO> getReplyComments(int parentId, PaginationRequest request, int tenantId)
throws ReviewManagementDAOException {
if (log.isDebugEnabled()) {
log.debug("Getting comment of the application release (" + parentId + ") from the database");
}
Connection conn;
PreparedStatement statement = null;
ResultSet rs = null;
List<ReviewDTO> reviewDTOs = new ArrayList<>();
try {
conn = this.getDBConnection();
sql = "SELECT "
+ "AP_APP_REVIEW.ID AS ID, "
+ "AP_APP_REVIEW.COMMENT AS COMMENT, "
+ "AP_APP_REVIEW.CREATED_AT AS CREATED_AT, "
+ "AP_APP_REVIEW.MODIFIED_AT AS MODIFIED_AT, "
+ "AP_APP_REVIEW.USERNAME AS USERNAME, "
+ "AP_APP_REVIEW.PARENT_ID AS ROOT_PARENT_ID, "
+ "AP_APP_REVIEW.REVIEW_TYPE AS IMMEDIATE_PARENT_ID, "
+ "AP_APP_REVIEW.RATING AS RATING "
+ "FROM AP_APP_REVIEW, AP_APP_RELEASE "
+ "WHERE "
+ "AP_APP_REVIEW.AP_APP_RELEASE_ID=AP_APP_RELEASE.ID AND "
+ "AP_APP_RELEASE.PARENT_ID = ? AND "
+ "AP_APP_REVIEW.TENANT_ID = ? AND "
+ "AP_APP_REVIEW.AP_APP_RELEASE_ID = AP_APP_RELEASE.ID "
+ "LIMIT ? OFFSET ?;"; + "LIMIT ? OFFSET ?;";
statement = conn.prepareStatement(sql); statement = conn.prepareStatement(sql);
statement.setString(1, uuid); statement.setInt(1, parentId);
statement.setInt(2, tenantId); statement.setInt(2, tenantId);
statement.setInt(3, request.getLimit()); statement.setInt(3, request.getLimit());
statement.setInt(4, request.getOffSet()); statement.setInt(4, request.getOffSet());
rs = statement.executeQuery(); rs = statement.executeQuery();
while (rs.next()) { reviewDTOs = DAOUtil.loadReviews(rs);
ReviewDTO reviewDTO = new ReviewDTO();
reviewDTO.setId(rs.getInt("ID"));
reviewDTO.setContent(rs.getString("COMMENT"));
reviewDTO.setCreatedAt(rs.getTimestamp("CREATED_AT"));
reviewDTO.setModifiedAt(rs.getTimestamp("MODIFIED_AT"));
reviewDTO.setRootParentId(rs.getInt("ROOT_PARENT_ID"));
reviewDTO.setImmediateParentId(rs.getInt("IMMEDIATE_PARENT_ID"));
reviewDTO.setUsername(rs.getString("USERNAME"));
reviewDTO.setRating(rs.getInt("RATING"));
reviewDTOs.add(reviewDTO);
}
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new ReviewManagementDAOException( throw new ReviewManagementDAOException(
"Error occurred while obtaining the DB connection when verifying application existence", e); "Error occurred while obtaining the DB connection when verifying application existence", e);
} catch (SQLException e) { } catch (SQLException e) {
throw new ReviewManagementDAOException("DB connection error occurred while getting all reviewTmps", e); throw new ReviewManagementDAOException("DB connection error occurred while getting all reviewTmps", e);
}finally { }finally {
Util.cleanupResources(statement, rs); DAOUtil.cleanupResources(statement, rs);
} }
return reviewDTOs; return reviewDTOs;
} }
@ -358,7 +372,7 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
"Error occured while getting DB connection to retrieve all rating values for the application release. App release UUID: " "Error occured while getting DB connection to retrieve all rating values for the application release. App release UUID: "
+ uuid, e); + uuid, e);
} finally { } finally {
Util.cleanupResources(statement, rs); DAOUtil.cleanupResources(statement, rs);
} }
return reviews; return reviews;
} }
@ -392,7 +406,7 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new ReviewManagementDAOException("DB Connection Exception occurred while retrieving review counts", e); throw new ReviewManagementDAOException("DB Connection Exception occurred while retrieving review counts", e);
} finally { } finally {
Util.cleanupResources(statement, rs); DAOUtil.cleanupResources(statement, rs);
} }
return commentCount; return commentCount;
} }
@ -421,7 +435,7 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
commentCount = rs.getInt("COMMENT_COUNT"); commentCount = rs.getInt("COMMENT_COUNT");
} }
} finally { } finally {
Util.cleanupResources(statement, rs); DAOUtil.cleanupResources(statement, rs);
} }
return commentCount; return commentCount;
} }
@ -443,7 +457,7 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
throw new ReviewManagementDAOException("Error occured while getting the database connection", e); throw new ReviewManagementDAOException("Error occured while getting the database connection", e);
} finally { } finally {
Util.cleanupResources(statement, null); DAOUtil.cleanupResources(statement, null);
} }
} }
@ -471,7 +485,7 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
} catch (SQLException e) { } catch (SQLException e) {
throw new ReviewManagementException("SQL Error occurred while deleting comments", e); throw new ReviewManagementException("SQL Error occurred while deleting comments", e);
} finally { } finally {
Util.cleanupResources(statement, null); DAOUtil.cleanupResources(statement, null);
} }
} }
} }

@ -19,15 +19,12 @@ package org.wso2.carbon.device.application.mgt.core.dao.impl.subscription;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.json.JSONException;
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO;
import org.wso2.carbon.device.application.mgt.common.dto.DeviceSubscriptionDTO; import org.wso2.carbon.device.application.mgt.common.dto.DeviceSubscriptionDTO;
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.core.dao.SubscriptionDAO; import org.wso2.carbon.device.application.mgt.core.dao.SubscriptionDAO;
import org.wso2.carbon.device.application.mgt.core.dao.common.Util; import org.wso2.carbon.device.application.mgt.core.util.DAOUtil;
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.ApplicationManagementDAOException;
import org.wso2.carbon.device.application.mgt.core.exception.UnexpectedServerErrorException;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
@ -70,7 +67,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
throw new ApplicationManagementDAOException("Error occurred while adding device application mapping to DB", throw new ApplicationManagementDAOException("Error occurred while adding device application mapping to DB",
e); e);
} finally { } finally {
Util.cleanupResources(stmt, null); DAOUtil.cleanupResources(stmt, null);
} }
} }
@ -104,7 +101,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
throw new ApplicationManagementDAOException("Error occurred while adding device application mapping to DB", throw new ApplicationManagementDAOException("Error occurred while adding device application mapping to DB",
e); e);
} finally { } finally {
Util.cleanupResources(stmt, null); DAOUtil.cleanupResources(stmt, null);
} }
} }
@ -137,7 +134,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
throw new ApplicationManagementDAOException("Error occurred while adding device application mapping to DB", throw new ApplicationManagementDAOException("Error occurred while adding device application mapping to DB",
e); e);
} finally { } finally {
Util.cleanupResources(stmt, null); DAOUtil.cleanupResources(stmt, null);
} }
} }
@ -170,7 +167,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
throw new ApplicationManagementDAOException("Error occurred while adding device application mapping to DB", throw new ApplicationManagementDAOException("Error occurred while adding device application mapping to DB",
e); e);
} finally { } finally {
Util.cleanupResources(stmt, null); DAOUtil.cleanupResources(stmt, null);
} }
} }
@ -203,7 +200,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
log.debug("Successfully retrieved device subscriptions for application release id " log.debug("Successfully retrieved device subscriptions for application release id "
+ appReleaseId); + appReleaseId);
} }
return Util.loadDeviceSubscriptions(rs); return DAOUtil.loadDeviceSubscriptions(rs);
} }
} }
} catch (SQLException e) { } catch (SQLException e) {

@ -21,7 +21,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException; import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
import org.wso2.carbon.device.application.mgt.core.dao.VisibilityDAO; import org.wso2.carbon.device.application.mgt.core.dao.VisibilityDAO;
import org.wso2.carbon.device.application.mgt.core.dao.common.Util; import org.wso2.carbon.device.application.mgt.core.util.DAOUtil;
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.VisibilityManagementDAOException; import org.wso2.carbon.device.application.mgt.core.exception.VisibilityManagementDAOException;
@ -66,7 +66,7 @@ public class GenericVisibilityDAOImpl extends AbstractDAOImpl implements Visibil
}catch (SQLException e) { }catch (SQLException e) {
throw new VisibilityManagementDAOException("Error occurred while adding unrestricted roles", e); throw new VisibilityManagementDAOException("Error occurred while adding unrestricted roles", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
@ -100,7 +100,7 @@ public class GenericVisibilityDAOImpl extends AbstractDAOImpl implements Visibil
}catch (SQLException e) { }catch (SQLException e) {
throw new VisibilityManagementDAOException("Error occurred while adding unrestricted roles", e); throw new VisibilityManagementDAOException("Error occurred while adding unrestricted roles", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
@ -167,7 +167,7 @@ public class GenericVisibilityDAOImpl extends AbstractDAOImpl implements Visibil
}catch (SQLException e) { }catch (SQLException e) {
throw new VisibilityManagementDAOException("Error occurred while adding unrestricted roles", e); throw new VisibilityManagementDAOException("Error occurred while adding unrestricted roles", e);
} finally { } finally {
Util.cleanupResources(stmt, rs); DAOUtil.cleanupResources(stmt, rs);
} }
} }
} }

@ -65,7 +65,7 @@ import org.wso2.carbon.device.application.mgt.core.dao.LifecycleStateDAO;
import org.wso2.carbon.device.application.mgt.core.dao.SubscriptionDAO; import org.wso2.carbon.device.application.mgt.core.dao.SubscriptionDAO;
import org.wso2.carbon.device.application.mgt.core.dao.VisibilityDAO; 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.dao.common.ApplicationManagementDAOFactory;
import org.wso2.carbon.device.application.mgt.core.dao.common.Util; import org.wso2.carbon.device.application.mgt.core.util.DAOUtil;
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException; import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException; import org.wso2.carbon.device.application.mgt.core.exception.BadRequestException;
import org.wso2.carbon.device.application.mgt.core.exception.ForbiddenException; import org.wso2.carbon.device.application.mgt.core.exception.ForbiddenException;
@ -251,7 +251,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
//insert application data into databse //insert application data into databse
ApplicationStorageManager applicationStorageManager = Util.getApplicationStorageManager(); ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager();
ApplicationReleaseDTO applicationReleaseDTO = applicationDTO.getApplicationReleaseDTOs().get(0); ApplicationReleaseDTO applicationReleaseDTO = applicationDTO.getApplicationReleaseDTOs().get(0);
try { try {
List<ApplicationReleaseDTO> applicationReleaseEntities = new ArrayList<>(); List<ApplicationReleaseDTO> applicationReleaseEntities = new ArrayList<>();
@ -379,7 +379,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
private void deleteApplicationArtifacts(List<String> directoryPaths) throws ApplicationManagementException { private void deleteApplicationArtifacts(List<String> directoryPaths) throws ApplicationManagementException {
ApplicationStorageManager applicationStorageManager = Util.getApplicationStorageManager(); ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager();
try { try {
applicationStorageManager.deleteAllApplicationReleaseArtifacts(directoryPaths); applicationStorageManager.deleteAllApplicationReleaseArtifacts(directoryPaths);
@ -395,7 +395,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
ApplicationReleaseDTO applicationReleaseDTO, ApplicationArtifact applicationArtifact, boolean isNewRelease) ApplicationReleaseDTO applicationReleaseDTO, ApplicationArtifact applicationArtifact, boolean isNewRelease)
throws ResourceManagementException, ApplicationManagementException { throws ResourceManagementException, ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
ApplicationStorageManager applicationStorageManager = Util.getApplicationStorageManager(); ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager();
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
applicationReleaseDTO.setUuid(uuid); applicationReleaseDTO.setUuid(uuid);
@ -478,7 +478,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
ApplicationReleaseDTO applicationReleaseDTO, ApplicationArtifact applicationArtifact) ApplicationReleaseDTO applicationReleaseDTO, ApplicationArtifact applicationArtifact)
throws ResourceManagementException, ApplicationManagementException { throws ResourceManagementException, ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
ApplicationStorageManager applicationStorageManager = Util.getApplicationStorageManager(); ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager();
// The application executable artifacts such as apks are uploaded. // The application executable artifacts such as apks are uploaded.
if (ApplicationType.ENTERPRISE.toString().equals(applicationType)) { if (ApplicationType.ENTERPRISE.toString().equals(applicationType)) {
@ -562,7 +562,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
private ApplicationReleaseDTO addImageArtifacts(ApplicationReleaseDTO applicationReleaseDTO, private ApplicationReleaseDTO addImageArtifacts(ApplicationReleaseDTO applicationReleaseDTO,
ApplicationArtifact applicationArtifact) throws ResourceManagementException { ApplicationArtifact applicationArtifact) throws ResourceManagementException {
ApplicationStorageManager applicationStorageManager = Util.getApplicationStorageManager(); ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager();
applicationReleaseDTO.setIconName(applicationArtifact.getIconName()); applicationReleaseDTO.setIconName(applicationArtifact.getIconName());
applicationReleaseDTO.setBannerName(applicationArtifact.getBannerName()); applicationReleaseDTO.setBannerName(applicationArtifact.getBannerName());
@ -591,7 +591,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
private ApplicationReleaseDTO updateImageArtifacts(ApplicationReleaseDTO applicationReleaseDTO, private ApplicationReleaseDTO updateImageArtifacts(ApplicationReleaseDTO applicationReleaseDTO,
ApplicationArtifact applicationArtifact) throws ResourceManagementException{ ApplicationArtifact applicationArtifact) throws ResourceManagementException{
ApplicationStorageManager applicationStorageManager = Util.getApplicationStorageManager(); ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager();
applicationStorageManager.deleteImageArtifacts(applicationReleaseDTO); applicationStorageManager.deleteImageArtifacts(applicationReleaseDTO);
@ -1193,7 +1193,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
+ applicationId); + applicationId);
} }
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
ApplicationStorageManager applicationStorageManager = Util.getApplicationStorageManager(); ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager();
ApplicationDTO applicationDTO = getApplication(applicationId); ApplicationDTO applicationDTO = getApplication(applicationId);
List<ApplicationReleaseDTO> applicationReleaseDTOs = applicationDTO.getApplicationReleaseDTOs(); List<ApplicationReleaseDTO> applicationReleaseDTOs = applicationDTO.getApplicationReleaseDTOs();
for (ApplicationReleaseDTO applicationReleaseDTO : applicationReleaseDTOs) { for (ApplicationReleaseDTO applicationReleaseDTO : applicationReleaseDTOs) {
@ -1334,7 +1334,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
public void deleteApplicationRelease(String releaseUuid) public void deleteApplicationRelease(String releaseUuid)
throws ApplicationManagementException { throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
ApplicationStorageManager applicationStorageManager = Util.getApplicationStorageManager(); ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager();
try { try {
ConnectionManagerUtil.beginDBTransaction(); ConnectionManagerUtil.beginDBTransaction();
ApplicationReleaseDTO applicationReleaseDTO = this.applicationReleaseDAO ApplicationReleaseDTO applicationReleaseDTO = this.applicationReleaseDAO
@ -1477,7 +1477,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
boolean isValidDeviceType = false; boolean isValidDeviceType = false;
List<DeviceType> deviceTypes; List<DeviceType> deviceTypes;
try { try {
deviceTypes = Util.getDeviceManagementService().getDeviceTypes(); deviceTypes = DAOUtil.getDeviceManagementService().getDeviceTypes();
for (DeviceType dt : deviceTypes) { for (DeviceType dt : deviceTypes) {
if (dt.getName().equals(deviceType)) { if (dt.getName().equals(deviceType)) {
@ -2595,7 +2595,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
throws BadRequestException, UnexpectedServerErrorException { throws BadRequestException, UnexpectedServerErrorException {
List<DeviceType> deviceTypes; List<DeviceType> deviceTypes;
try { try {
deviceTypes = Util.getDeviceManagementService().getDeviceTypes(); deviceTypes = DAOUtil.getDeviceManagementService().getDeviceTypes();
if(deviceTypeAttr instanceof String){ if(deviceTypeAttr instanceof String){
for (DeviceType dt : deviceTypes) { for (DeviceType dt : deviceTypes) {

@ -29,7 +29,7 @@ import org.wso2.carbon.device.application.mgt.common.services.AppmDataHandler;
import org.wso2.carbon.device.application.mgt.common.config.UIConfiguration; import org.wso2.carbon.device.application.mgt.common.config.UIConfiguration;
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationReleaseDAO; import org.wso2.carbon.device.application.mgt.core.dao.ApplicationReleaseDAO;
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.dao.common.Util; import org.wso2.carbon.device.application.mgt.core.util.DAOUtil;
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException; import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException; import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException;
import org.wso2.carbon.device.application.mgt.core.internal.DataHolder; import org.wso2.carbon.device.application.mgt.core.internal.DataHolder;
@ -67,7 +67,7 @@ public class AppmDataHandlerImpl implements AppmDataHandler {
@Override @Override
public InputStream getArtifactStream(String uuid, String artifactName) throws ApplicationManagementException { public InputStream getArtifactStream(String uuid, String artifactName) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
ApplicationStorageManager applicationStorageManager = Util.getApplicationStorageManager(); ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager();
ApplicationReleaseDAO applicationReleaseDAO = ApplicationManagementDAOFactory.getApplicationReleaseDAO(); ApplicationReleaseDAO applicationReleaseDAO = ApplicationManagementDAOFactory.getApplicationReleaseDAO();
String artifactPath; String artifactPath;
String appReleaseHashValue; String appReleaseHashValue;

@ -22,6 +22,7 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.CarbonConstants;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
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.ReviewNode;
import org.wso2.carbon.device.application.mgt.common.ReviewTmp; import org.wso2.carbon.device.application.mgt.common.ReviewTmp;
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;
@ -283,7 +284,7 @@ public class ReviewManagerImpl implements ReviewManager {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
PaginationResult paginationResult = new PaginationResult(); PaginationResult paginationResult = new PaginationResult();
int numOfComments; int numOfComments;
TreeMap<Integer, Review> reviewTree = new TreeMap<>(); TreeMap<Integer, ReviewNode<Review>> reviewTree = new TreeMap<>();
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Get all reviewTmps of the application release uuid: " + uuid); log.debug("Get all reviewTmps of the application release uuid: " + uuid);
} }
@ -295,17 +296,13 @@ public class ReviewManagerImpl implements ReviewManager {
for (Review review : reviews) { for (Review review : reviews) {
if (review.getRootParentId() == -1 && review.getImmediateParentId() == -1) { if (review.getRootParentId() == -1 && review.getImmediateParentId() == -1) {
reviewTree.put(review.getId(), review); ReviewNode<Review> rootNode = new ReviewNode<>(review);
} else if (reviewTree.containsKey(review.getRootParentId())) { reviewTree.put(review.getId(), rootNode);
if (review.getRootParentId() == review.getImmediateParentId()) { } else if (reviewTree.containsKey(review.getImmediateParentId())) {
reviewTree.get(review.getRootParentId()).getReplyComments().put(review.getId(), review); ReviewNode<Review> childNode = new ReviewNode<>(review);
} else if (reviewTree.get(review.getRootParentId()).getReplyComments() reviewTree.get(review.getImmediateParentId()).addChild(childNode);
.containsKey(review.getImmediateParentId())) {
reviewTree.get(review.getRootParentId()).getReplyComments().get(review.getImmediateParentId())
.getReplyComments().put(review.getId(), review);
} else { } else {
//todo traverse and find reviewTree.put(review.getId(), findAndSetChild(reviewTree.get(review.getRootParentId()), review));
}
} }
} }
numOfComments = reviewTree.size(); numOfComments = reviewTree.size();
@ -329,6 +326,16 @@ public class ReviewManagerImpl implements ReviewManager {
} }
} }
private ReviewNode<Review> findAndSetChild(ReviewNode<Review> node, Review review) {
for (ReviewNode<Review> each : node.getChildren()) {
if ((each.getData()).getId() == review.getImmediateParentId()) {
ReviewNode<Review> childNode = new ReviewNode<>(review);
each.addChild(childNode);
}
}
return node;
}
@Override @Override
public boolean deleteReview(String uuid, int reviewId) public boolean deleteReview(String uuid, int reviewId)
throws ReviewManagementException, ReviewDoesNotExistException { throws ReviewManagementException, ReviewDoesNotExistException {

@ -32,7 +32,7 @@ import org.wso2.carbon.device.application.mgt.core.lifecycle.LifecycleStateManag
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
/** /**
* This Util class is responsible for making sure single instance of each Extension Manager is used throughout for * This DAOUtil class is responsible for making sure single instance of each Extension Manager is used throughout for
* all the tasks. * all the tasks.
*/ */
public class ApplicationManagementUtil { public class ApplicationManagementUtil {

@ -64,5 +64,5 @@ public class Constants {
*/ */
public static final String RELEASE_ARTIFACT = "artifact"; public static final String RELEASE_ARTIFACT = "artifact";
public static final int MAXIMUM_REVIEWS_PER_USER = 10; public static final int REVIEW_PARENT_ID = -1;
} }

@ -16,7 +16,7 @@
* under the License. * under the License.
* *
*/ */
package org.wso2.carbon.device.application.mgt.core.dao.common; package org.wso2.carbon.device.application.mgt.core.util;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -27,6 +27,7 @@ import org.wso2.carbon.device.application.mgt.common.PaginationRequest;
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationReleaseDTO; import org.wso2.carbon.device.application.mgt.common.dto.ApplicationReleaseDTO;
import org.wso2.carbon.device.application.mgt.common.dto.DeviceSubscriptionDTO; import org.wso2.carbon.device.application.mgt.common.dto.DeviceSubscriptionDTO;
import org.wso2.carbon.device.application.mgt.common.dto.ReviewDTO;
import org.wso2.carbon.device.application.mgt.common.exception.ReviewManagementException; import org.wso2.carbon.device.application.mgt.common.exception.ReviewManagementException;
import org.wso2.carbon.device.application.mgt.common.services.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;
@ -34,8 +35,6 @@ import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManage
import org.wso2.carbon.device.application.mgt.core.config.Configuration; import org.wso2.carbon.device.application.mgt.core.config.Configuration;
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.exception.UnexpectedServerErrorException; import org.wso2.carbon.device.application.mgt.core.exception.UnexpectedServerErrorException;
import org.wso2.carbon.device.application.mgt.core.impl.ApplicationStorageManagerImpl;
import org.wso2.carbon.device.application.mgt.core.util.ApplicationManagementUtil;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
@ -48,9 +47,9 @@ import java.util.List;
/** /**
* This class is responsible for handling the utils of the Application Management DAO. * This class is responsible for handling the utils of the Application Management DAO.
*/ */
public class Util { public class DAOUtil {
private static final Log log = LogFactory.getLog(Util.class); private static final Log log = LogFactory.getLog(DAOUtil.class);
/** /**
* To create application object from the result set retrieved from the Database. * To create application object from the result set retrieved from the Database.
@ -204,6 +203,36 @@ public class Util {
return applicationRelease; return applicationRelease;
} }
public static ReviewDTO loadReview(ResultSet rs) throws SQLException, UnexpectedServerErrorException {
List<ReviewDTO> reviewDTOs = loadReviews(rs);
if (reviewDTOs.isEmpty()) {
return null;
}
if (reviewDTOs.size() > 1) {
String msg = "Internal server error. Found more than one review for requested review ID";
log.error(msg);
throw new UnexpectedServerErrorException(msg);
}
return reviewDTOs.get(0);
}
public static List<ReviewDTO> loadReviews (ResultSet rs) throws SQLException {
List<ReviewDTO> reviewDTOs = new ArrayList<>();
while (rs.next()) {
ReviewDTO reviewDTO = new ReviewDTO();
reviewDTO.setId(rs.getInt("ID"));
reviewDTO.setContent(rs.getString("COMMENT"));
reviewDTO.setCreatedAt(rs.getTimestamp("CREATED_AT"));
reviewDTO.setModifiedAt(rs.getTimestamp("MODIFIED_AT"));
reviewDTO.setRootParentId(rs.getInt("ROOT_PARENT_ID"));
reviewDTO.setImmediateParentId(rs.getInt("IMMEDIATE_PARENT_ID"));
reviewDTO.setUsername(rs.getString("USERNAME"));
reviewDTO.setRating(rs.getInt("RATING"));
reviewDTOs.add(reviewDTO);
}
return reviewDTOs;
}
/** /**
* Cleans up the statement and resultset after executing the query * Cleans up the statement and resultset after executing the query
* *
@ -248,7 +277,7 @@ public class Util {
public static ApplicationManager getApplicationManager() { public static ApplicationManager getApplicationManager() {
if (applicationManager == null) { if (applicationManager == null) {
synchronized (Util.class) { synchronized (DAOUtil.class) {
if (applicationManager == null) { if (applicationManager == null) {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
applicationManager = applicationManager =
@ -272,7 +301,7 @@ public class Util {
try { try {
if (applicationStorageManager == null) { if (applicationStorageManager == null) {
synchronized (Util.class) { synchronized (DAOUtil.class) {
if (applicationStorageManager == null) { if (applicationStorageManager == null) {
applicationStorageManager = ApplicationManagementUtil applicationStorageManager = ApplicationManagementUtil
.getApplicationStorageManagerInstance(); .getApplicationStorageManagerInstance();
@ -299,7 +328,7 @@ public class Util {
*/ */
public static SubscriptionManager getSubscriptionManager() { public static SubscriptionManager getSubscriptionManager() {
if (subscriptionManager == null) { if (subscriptionManager == null) {
synchronized (Util.class) { synchronized (DAOUtil.class) {
if (subscriptionManager == null) { if (subscriptionManager == null) {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
subscriptionManager = subscriptionManager =
Loading…
Cancel
Save