fixing issue with certificate delete

4.x.x
inosh-perera 9 years ago
parent afbfaf4c1d
commit 9661502524

@ -17,6 +17,7 @@
*/
package org.wso2.carbon.certificate.mgt.core.service;
import com.sun.org.apache.xpath.internal.operations.Bool;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.bouncycastle.pkcs.PKCS10CertificationRequest;
@ -31,6 +32,7 @@ import org.wso2.carbon.certificate.mgt.core.impl.KeyStoreReader;
import org.wso2.carbon.certificate.mgt.core.util.ConfigurationUtil;
import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.common.TransactionManagementException;
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory;
import java.io.InputStream;
@ -165,11 +167,13 @@ public class CertificateManagementServiceImpl implements CertificateManagementSe
@Override
public boolean removeCertificate(String serialNumber) throws CertificateManagementDAOException {
try {
CertificateManagementDAOFactory.openConnection();
CertificateManagementDAOFactory.beginTransaction();
CertificateDAO certificateDAO = CertificateManagementDAOFactory.getCertificateDAO();
return certificateDAO.removeCertificate(serialNumber);
} catch (SQLException e) {
String errorMsg = "Error when opening connection";
Boolean status = certificateDAO.removeCertificate(serialNumber);
CertificateManagementDAOFactory.commitTransaction();
return status;
} catch (TransactionManagementException e) {
String errorMsg = "Error when deleting";
log.error(errorMsg, e);
throw new CertificateManagementDAOException(errorMsg, e);
} finally {

Loading…
Cancel
Save