revert-70aa11f8
hasuniea 9 years ago
commit 17c6cf6498

@ -16,7 +16,6 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.certificate.mgt.core.config; package org.wso2.carbon.certificate.mgt.core.config;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;

@ -16,7 +16,6 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.certificate.mgt.core.config; package org.wso2.carbon.certificate.mgt.core.config;
import org.wso2.carbon.certificate.mgt.core.config.datasource.DataSourceConfig; import org.wso2.carbon.certificate.mgt.core.config.datasource.DataSourceConfig;

@ -38,9 +38,3 @@ public class DataSourceConfig {
this.jndiLookupDefinition = jndiLookupDefinition; this.jndiLookupDefinition = jndiLookupDefinition;
} }
} }
// CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE (
// ID INTEGER auto_increment NOT NULL,
// SERIAL_NUMBER VARCHAR(500) DEFAULT NULL,
// CERTIFICATE BLOB DEFAULT NULL,
// PRIMARY KEY (ID)
// );

@ -29,6 +29,7 @@ public interface CertificateDAO {
/** /**
* This can be used to store a certificate in the database, where it will be stored against the serial number * This can be used to store a certificate in the database, where it will be stored against the serial number
* of the certificate. * of the certificate.
*
* @param byteArrayInputStream Holds the certificate. * @param byteArrayInputStream Holds the certificate.
* @param serialNumber Serial number of the certificate. * @param serialNumber Serial number of the certificate.
* @throws CertificateManagementDAOException * @throws CertificateManagementDAOException
@ -38,6 +39,7 @@ public interface CertificateDAO {
/** /**
* Usage is to obtain a certificate stored in the database by providing the serial number. * Usage is to obtain a certificate stored in the database by providing the serial number.
*
* @param serialNumber Serial number of the certificate. * @param serialNumber Serial number of the certificate.
* @return representation of the certificate. * @return representation of the certificate.
* @throws CertificateManagementDAOException * @throws CertificateManagementDAOException

@ -16,7 +16,6 @@
* under the License. * under the License.
*/ */
package org.wso2.carbon.certificate.mgt.core.dao; package org.wso2.carbon.certificate.mgt.core.dao;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;

@ -39,7 +39,8 @@ public class CertificateManagementServiceImpl implements CertificateManagementSe
private static KeyStoreReader keyStoreReader; private static KeyStoreReader keyStoreReader;
private static CertificateGenerator certificateGenerator; private static CertificateGenerator certificateGenerator;
private CertificateManagementServiceImpl() {} private CertificateManagementServiceImpl() {
}
public static CertificateManagementServiceImpl getInstance() { public static CertificateManagementServiceImpl getInstance() {

@ -28,7 +28,6 @@ import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorization
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants; import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.core.dao.DeviceDAO; import org.wso2.carbon.device.mgt.core.dao.DeviceDAO;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;

@ -1282,6 +1282,11 @@ public class PolicyDAOImpl implements PolicyDAO {
stmt.setInt(1, policyId); stmt.setInt(1, policyId);
stmt.executeUpdate(); stmt.executeUpdate();
String deleteComplianceStatus ="DELETE FROM DM_POLICY_COMPLIANCE_STATUS WHERE POLICY_ID =?";
stmt = conn.prepareStatement(deleteComplianceStatus);
stmt.setInt(1, policyId);
stmt.executeUpdate();
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Policy (" + policyId + ") related configs deleted from database."); log.debug("Policy (" + policyId + ") related configs deleted from database.");
} }

@ -41,6 +41,7 @@ import org.wso2.carbon.policy.mgt.core.util.PolicyManagementConstants;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint { public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
@ -123,36 +124,49 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
try { try {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
TaskService taskService = PolicyManagementDataHolder.getInstance().getTaskService(); TaskService taskService = PolicyManagementDataHolder.getInstance().getTaskService();
taskService.registerTaskType(PolicyManagementConstants.DELEGATION_TASK_TYPE);
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Policy delegations task is started for the tenant id " + tenantId); log.debug("Policy delegations task is started for the tenant id " + tenantId);
} }
TaskManager taskManager = taskService.getTaskManager(PolicyManagementConstants.DELEGATION_TASK_TYPE); TaskManager taskManager = taskService.getTaskManager(PolicyManagementConstants.DELEGATION_TASK_TYPE);
TaskInfo.TriggerInfo triggerInfo = new TaskInfo.TriggerInfo(); TaskInfo.TriggerInfo triggerInfo = new TaskInfo.TriggerInfo();
triggerInfo.setRepeatCount(0); triggerInfo.setRepeatCount(0);
Map<String, String> properties = new HashMap<>(); Map<String, String> properties = new HashMap<>();
properties.put(PolicyManagementConstants.TENANT_ID, String.valueOf(tenantId)); properties.put(PolicyManagementConstants.TENANT_ID, String.valueOf(tenantId));
String taskName = PolicyManagementConstants.DELEGATION_TASK_NAME + "_" + String.valueOf(tenantId); String taskName = PolicyManagementConstants.DELEGATION_TASK_NAME + "_" + String.valueOf(tenantId);
if (!taskManager.isTaskScheduled(taskName)) { Set<String> registeredTaskTypes = taskService.getRegisteredTaskTypes();
//Check whether the TaskType is already registered. If not we'll register it here.
if (!registeredTaskTypes.contains(PolicyManagementConstants.DELEGATION_TASK_TYPE)) {
taskService.registerTaskType(PolicyManagementConstants.DELEGATION_TASK_TYPE);
TaskInfo registeredTaskInfo = null;
// getTask method will throw a TaskException if the task is not registered. Hence we'll handle the
// exception and register the task.
try {
registeredTaskInfo = taskManager.getTask(taskName);
} catch (TaskException e) {
// No need of any specific logic to handle this exception as it is thrown if the task is not registered.
} finally {
// If registeredTaskInfo is null that means there's no registered delegation-task.
if (registeredTaskInfo == null) {
TaskInfo taskInfo = new TaskInfo(taskName, PolicyManagementConstants.DELEGATION_TASK_CLAZZ, TaskInfo taskInfo = new TaskInfo(taskName, PolicyManagementConstants.DELEGATION_TASK_CLAZZ,
properties, triggerInfo); properties, triggerInfo);
taskManager.registerTask(taskInfo); taskManager.registerTask(taskInfo);
taskManager.rescheduleTask(taskInfo.getName()); taskManager.scheduleTask(taskInfo.getName());
}
}
} else {
if (!taskManager.isTaskScheduled(taskName)) {
TaskInfo taskInfo = new TaskInfo(taskName, PolicyManagementConstants.DELEGATION_TASK_CLAZZ,
properties, triggerInfo);
taskManager.scheduleTask(taskInfo.getName());
} else { } else {
throw new PolicyManagementException("There is a task already running for policy changes. Please try " + throw new PolicyManagementException("There is a task already running for policy changes. Please try " +
"to apply " + "to apply " +
"changes after few minutes."); "changes after few minutes.");
} }
}
} catch (TaskException e) { } catch (TaskException e) {
String msg = "Error occurred while creating the policy delegation task for tenant " + String msg = "Error occurred while creating the policy delegation task for tenant " +
PrivilegedCarbonContext. PrivilegedCarbonContext.

Loading…
Cancel
Save