|
|
@ -30,13 +30,11 @@ import org.wso2.carbon.device.application.mgt.core.dao.CommentDAO;
|
|
|
|
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.ApplicationManagementDAOException;
|
|
|
|
|
|
|
|
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import java.sql.Timestamp;
|
|
|
|
import java.sql.Timestamp;
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.sql.Connection;
|
|
|
|
import java.sql.Connection;
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
import java.time.Instant;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
@ -122,11 +120,11 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Comment updateComment(int apAppCommentId, String updatedComment, String modifiedBy, Timestamp modifiedAt)
|
|
|
|
public Comment updateComment(int CommentId, String updatedComment, String modifiedBy, Timestamp modifiedAt)
|
|
|
|
throws CommentManagementException, DBConnectionException, SQLException {
|
|
|
|
throws CommentManagementException, DBConnectionException, SQLException {
|
|
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Request received in DAO Layer to update the comment with ID ("+apAppCommentId+")");
|
|
|
|
log.debug("Request received in DAO Layer to update the comment with ID ("+ CommentId +")");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Connection connection;
|
|
|
|
Connection connection;
|
|
|
@ -139,7 +137,7 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
|
|
|
|
statement = connection.prepareStatement(sql);
|
|
|
|
statement = connection.prepareStatement(sql);
|
|
|
|
statement.setString(1, updatedComment);
|
|
|
|
statement.setString(1, updatedComment);
|
|
|
|
statement.setString(2, modifiedBy);
|
|
|
|
statement.setString(2, modifiedBy);
|
|
|
|
statement.setInt(3, apAppCommentId);
|
|
|
|
statement.setInt(3, CommentId);
|
|
|
|
|
|
|
|
|
|
|
|
statement.executeUpdate();
|
|
|
|
statement.executeUpdate();
|
|
|
|
rs = statement.executeQuery();
|
|
|
|
rs = statement.executeQuery();
|
|
|
@ -147,15 +145,15 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
Util.cleanupResources(statement, rs);
|
|
|
|
Util.cleanupResources(statement, rs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return getComment(apAppCommentId);
|
|
|
|
return getComment(CommentId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Comment updateComment(String uuid, int apAppCommentID,String updatedComment, String modifiedBy, Timestamp
|
|
|
|
public Comment updateComment(String uuid, int CommentId,String updatedComment, String modifiedBy, Timestamp
|
|
|
|
modifiedAt) throws CommentManagementException, DBConnectionException, SQLException {
|
|
|
|
modifiedAt) throws CommentManagementException, DBConnectionException, SQLException {
|
|
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Request received in DAO Layer to update the comment with application ("+uuid+") and " +
|
|
|
|
log.debug("Request received in DAO Layer to update the comment with application ("+uuid+") and " +
|
|
|
|
"comment id ( "+apAppCommentID+")");
|
|
|
|
"comment id ( "+ CommentId +")");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Connection connection;
|
|
|
|
Connection connection;
|
|
|
@ -168,20 +166,20 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
|
|
|
|
statement = connection.prepareStatement(sql);
|
|
|
|
statement = connection.prepareStatement(sql);
|
|
|
|
statement.setString(1, updatedComment);
|
|
|
|
statement.setString(1, updatedComment);
|
|
|
|
statement.setString(2,modifiedBy);
|
|
|
|
statement.setString(2,modifiedBy);
|
|
|
|
statement.setInt(3,apAppCommentID);
|
|
|
|
statement.setInt(3, CommentId);
|
|
|
|
statement.executeUpdate();
|
|
|
|
statement.executeUpdate();
|
|
|
|
rs= statement.getResultSet();
|
|
|
|
rs= statement.getResultSet();
|
|
|
|
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
Util.cleanupResources(statement, rs);
|
|
|
|
Util.cleanupResources(statement, rs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return getComment(apAppCommentID);
|
|
|
|
return getComment(CommentId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Comment getComment(int apAppCommentId) throws CommentManagementException {
|
|
|
|
public Comment getComment(int CommentId) throws CommentManagementException {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Getting comment with the comment id(" + apAppCommentId + ") from the database");
|
|
|
|
log.debug("Getting comment with the comment id(" + CommentId + ") from the database");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Connection conn;
|
|
|
|
Connection conn;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
@ -193,7 +191,7 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
sql += "SELECT COMMENT_TEXT FROM AP_APP_COMMENT WHERE ID=?;";
|
|
|
|
sql += "SELECT COMMENT_TEXT FROM AP_APP_COMMENT WHERE ID=?;";
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setInt(1, apAppCommentId);
|
|
|
|
stmt.setInt(1, CommentId);
|
|
|
|
rs=stmt.executeQuery();
|
|
|
|
rs=stmt.executeQuery();
|
|
|
|
|
|
|
|
|
|
|
|
if (rs.next()) {
|
|
|
|
if (rs.next()) {
|
|
|
@ -212,7 +210,7 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new CommentManagementException("Error occurred while retrieving information of the comment "+apAppCommentId, e);
|
|
|
|
throw new CommentManagementException("Error occurred while retrieving information of the comment "+ CommentId, e);
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
log.error("DB Connection Exception occurs.", e);
|
|
|
|
log.error("DB Connection Exception occurs.", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
@ -721,7 +719,6 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
Util.cleanupResources(stmt, null);
|
|
|
|
Util.cleanupResources(stmt, null);
|
|
|
|
|
|
|
|
|
|
|
|
return commentCount;
|
|
|
|
return commentCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -747,7 +744,6 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
Util.cleanupResources(stmt, null);
|
|
|
|
Util.cleanupResources(stmt, null);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return commentCount;
|
|
|
|
return commentCount;
|
|
|
|
|
|
|
|
|
|
|
@ -860,7 +856,7 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void deleteComment(int apAppCommentId) throws CommentManagementException, DBConnectionException,
|
|
|
|
public void deleteComment(int CommentId) throws CommentManagementException, DBConnectionException,
|
|
|
|
SQLException {
|
|
|
|
SQLException {
|
|
|
|
|
|
|
|
|
|
|
|
Connection conn;
|
|
|
|
Connection conn;
|
|
|
@ -869,7 +865,7 @@ public class CommentDAOImpl extends AbstractDAOImpl implements CommentDAO {
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
String sql = "DELETE FROM AP_APP_COMMENT WHERE ID=?;";
|
|
|
|
String sql = "DELETE FROM AP_APP_COMMENT WHERE ID=?;";
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
stmt.setInt(1, apAppCommentId);
|
|
|
|
stmt.setInt(1, CommentId);
|
|
|
|
stmt.executeUpdate();
|
|
|
|
stmt.executeUpdate();
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
Util.cleanupResources(stmt, null);
|
|
|
|
Util.cleanupResources(stmt, null);
|
|
|
|