Adding validations to certificate deletion operation

merge-requests/7/head
prabathabey 9 years ago
parent fe22bfc125
commit 92cf44380e

@ -121,9 +121,13 @@ public class CertificateManagementAdminServiceImpl implements CertificateManagem
CertificateManagementService certificateService = DeviceMgtAPIUtils.getCertificateManagementService();
try {
certificateService.removeCertificate(serialNumber);
boolean status = certificateService.removeCertificate(serialNumber);
if (!status) {
Response.status(Response.Status.NOT_FOUND).entity("No certificate is found with the given " +
"serial number '" + serialNumber + "'");
}
return Response.status(Response.Status.OK).entity("Certificate that carries the serial number '" +
serialNumber + " has been removed").build();
serialNumber + "' has been removed").build();
} catch (CertificateManagementDAOException e) {
String msg = "Error occurred while converting PEM file to X509Certificate";
log.error(msg, e);

@ -252,10 +252,7 @@ public class GenericCertificateDAOImpl implements CertificateDAO {
stmt.setString(1, serialNumber);
stmt.setInt(2, tenantId);
if(stmt.executeUpdate() > 0) {
return true;
}
return false;
return stmt.executeUpdate() > 0;
} catch (SQLException e) {
String errorMsg =
"Unable to get the read the certificate with serial" + serialNumber;

@ -173,7 +173,7 @@ public class CertificateManagementServiceImpl implements CertificateManagementSe
try {
CertificateManagementDAOFactory.beginTransaction();
CertificateDAO certificateDAO = CertificateManagementDAOFactory.getCertificateDAO();
Boolean status = certificateDAO.removeCertificate(serialNumber);
boolean status = certificateDAO.removeCertificate(serialNumber);
CertificateManagementDAOFactory.commitTransaction();
return status;
} catch (TransactionManagementException e) {

Loading…
Cancel
Save