mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Email functionality
This commit is contained in:
parent
78959f0cfb
commit
7c0ca194a1
@ -71,4 +71,10 @@ public final class DeviceManagementConstants {
|
|||||||
public static final String LICENSE_REGISTRY_KEY = "license";
|
public static final String LICENSE_REGISTRY_KEY = "license";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final class NotificationProperties {
|
||||||
|
private NotificationProperties() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
public static final String NOTIFICATION_CONFIG_FILE = "notification-messages.xml";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,22 +18,24 @@
|
|||||||
package org.wso2.carbon.device.mgt.core;
|
package org.wso2.carbon.device.mgt.core;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.common.*;
|
import org.wso2.carbon.device.mgt.common.*;
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
|
||||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManager;
|
|
||||||
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
||||||
|
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager;
|
||||||
|
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.OperationManager;
|
||||||
|
import org.wso2.carbon.device.mgt.common.spi.DeviceManager;
|
||||||
|
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
|
||||||
|
import org.wso2.carbon.device.mgt.core.config.EnrolmentNotifications;
|
||||||
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;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
|
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
|
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
||||||
import org.wso2.carbon.device.mgt.core.dto.*;
|
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
||||||
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
|
import org.wso2.carbon.device.mgt.core.dto.Status;
|
||||||
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager;
|
|
||||||
import org.wso2.carbon.device.mgt.core.internal.EmailServiceDataHolder;
|
import org.wso2.carbon.device.mgt.core.internal.EmailServiceDataHolder;
|
||||||
import org.wso2.carbon.device.mgt.core.license.mgt.LicenseManagerImpl;
|
import org.wso2.carbon.device.mgt.core.license.mgt.LicenseManagerImpl;
|
||||||
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.OperationManager;
|
|
||||||
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
|
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementService;
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementService;
|
||||||
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
|
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
|
||||||
@ -188,7 +190,8 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
|
|||||||
List<Device> devicesOfUser = new ArrayList<Device>();
|
List<Device> devicesOfUser = new ArrayList<Device>();
|
||||||
try {
|
try {
|
||||||
int tenantId = DeviceManagerUtil.getTenantId();
|
int tenantId = DeviceManagerUtil.getTenantId();
|
||||||
List<org.wso2.carbon.device.mgt.core.dto.Device> devicesList = this.deviceDAO.getDeviceListOfUser(username, tenantId);
|
List<org.wso2.carbon.device.mgt.core.dto.Device> devicesList = this.deviceDAO
|
||||||
|
.getDeviceListOfUser(username, tenantId);
|
||||||
for (int x = 0; x < devicesList.size(); x++) {
|
for (int x = 0; x < devicesList.size(); x++) {
|
||||||
org.wso2.carbon.device.mgt.core.dto.Device device = devicesList.get(x);
|
org.wso2.carbon.device.mgt.core.dto.Device device = devicesList.get(x);
|
||||||
device.setDeviceType(deviceTypeDAO.getDeviceType(device.getDeviceTypeId()));
|
device.setDeviceType(deviceTypeDAO.getDeviceType(device.getDeviceTypeId()));
|
||||||
@ -207,7 +210,7 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
|
|||||||
}
|
}
|
||||||
} catch (DeviceManagementDAOException e) {
|
} catch (DeviceManagementDAOException e) {
|
||||||
throw new DeviceManagementException("Error occurred while obtaining devices for user " +
|
throw new DeviceManagementException("Error occurred while obtaining devices for user " +
|
||||||
"'" + username + "'", e);
|
"'" + username + "'", e);
|
||||||
}
|
}
|
||||||
return devicesOfUser;
|
return devicesOfUser;
|
||||||
}
|
}
|
||||||
@ -215,8 +218,14 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
|
|||||||
@Override
|
@Override
|
||||||
public void sendEnrollInvitation(String emailAddress) throws DeviceManagementException {
|
public void sendEnrollInvitation(String emailAddress) throws DeviceManagementException {
|
||||||
EmailMessageProperties emailMessageProperties = new EmailMessageProperties();
|
EmailMessageProperties emailMessageProperties = new EmailMessageProperties();
|
||||||
emailMessageProperties.setSubject("");
|
EnrolmentNotifications enrolmentNotifications = DeviceConfigurationManager.getInstance()
|
||||||
// EmailServiceDataHolder.getInstance().getEmailServiceProvider().sendEmail();
|
.getNotificationMessagesConfig()
|
||||||
|
.getEnrolmentNotifications();
|
||||||
|
|
||||||
|
emailMessageProperties.setMailTo(new String[]{emailAddress});
|
||||||
|
emailMessageProperties.setSubject(enrolmentNotifications.getSubject());
|
||||||
|
emailMessageProperties.setMessageBody(enrolmentNotifications.getMessage());
|
||||||
|
EmailServiceDataHolder.getInstance().getEmailServiceProvider().sendEmail(emailMessageProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -288,7 +297,7 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addOperation(Operation operation,
|
public boolean addOperation(Operation operation,
|
||||||
List<DeviceIdentifier> devices) throws OperationManagementException {
|
List<DeviceIdentifier> devices) throws OperationManagementException {
|
||||||
return operationManager.addOperation(operation, devices);
|
return operationManager.addOperation(operation, devices);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,7 @@ import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
|
|||||||
import org.wso2.carbon.utils.CarbonUtils;
|
import org.wso2.carbon.utils.CarbonUtils;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBContext;
|
import javax.xml.bind.JAXBContext;
|
||||||
|
import javax.xml.bind.JAXBException;
|
||||||
import javax.xml.bind.Unmarshaller;
|
import javax.xml.bind.Unmarshaller;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@ -33,42 +34,64 @@ import java.io.File;
|
|||||||
*/
|
*/
|
||||||
public class DeviceConfigurationManager {
|
public class DeviceConfigurationManager {
|
||||||
|
|
||||||
private DeviceManagementConfig currentDeviceConfig;
|
private DeviceManagementConfig currentDeviceConfig;
|
||||||
private static DeviceConfigurationManager deviceConfigManager;
|
private NotificationMessagesConfig notificationMessagesConfig;
|
||||||
|
private static DeviceConfigurationManager deviceConfigManager;
|
||||||
|
|
||||||
private static final String deviceMgtConfigXMLPath =
|
private static final String deviceMgtConfigXMLPath =
|
||||||
CarbonUtils.getCarbonConfigDirPath() + File.separator +
|
CarbonUtils.getCarbonConfigDirPath() + File.separator +
|
||||||
DeviceManagementConstants.DataSourceProperties.DEVICE_CONFIG_XML_NAME;
|
DeviceManagementConstants.DataSourceProperties.DEVICE_CONFIG_XML_NAME;
|
||||||
|
private static final String notificationMessagesConfigXMLPath =
|
||||||
|
CarbonUtils.getCarbonConfigDirPath() + File.separator +
|
||||||
|
DeviceManagementConstants.NotificationProperties.NOTIFICATION_CONFIG_FILE;
|
||||||
|
|
||||||
public static DeviceConfigurationManager getInstance() {
|
public static DeviceConfigurationManager getInstance() {
|
||||||
if (deviceConfigManager == null) {
|
if (deviceConfigManager == null) {
|
||||||
synchronized (DeviceConfigurationManager.class) {
|
synchronized (DeviceConfigurationManager.class) {
|
||||||
if (deviceConfigManager == null) {
|
if (deviceConfigManager == null) {
|
||||||
deviceConfigManager = new DeviceConfigurationManager();
|
deviceConfigManager = new DeviceConfigurationManager();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return deviceConfigManager;
|
return deviceConfigManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void initConfig() throws DeviceManagementException {
|
public synchronized void initConfig() throws DeviceManagementException {
|
||||||
|
|
||||||
//catch generic exception.if any exception occurs wrap and throw DeviceManagementException
|
//catch generic exception.if any exception occurs wrap and throw DeviceManagementException
|
||||||
try {
|
try {
|
||||||
File deviceMgtConfig = new File(deviceMgtConfigXMLPath);
|
File deviceMgtConfig = new File(deviceMgtConfigXMLPath);
|
||||||
Document doc = DeviceManagerUtil.convertToDocument(deviceMgtConfig);
|
Document doc = DeviceManagerUtil.convertToDocument(deviceMgtConfig);
|
||||||
|
|
||||||
/* Un-marshaling Device Management configuration */
|
/* Un-marshaling Device Management configuration */
|
||||||
JAXBContext cdmContext = JAXBContext.newInstance(DeviceManagementConfig.class);
|
JAXBContext cdmContext = JAXBContext.newInstance(DeviceManagementConfig.class);
|
||||||
Unmarshaller unmarshaller = cdmContext.createUnmarshaller();
|
Unmarshaller unmarshaller = cdmContext.createUnmarshaller();
|
||||||
this.currentDeviceConfig = (DeviceManagementConfig) unmarshaller.unmarshal(doc);
|
this.currentDeviceConfig = (DeviceManagementConfig) unmarshaller.unmarshal(doc);
|
||||||
} catch (Exception e) {
|
} catch (JAXBException jaxbEx) {
|
||||||
throw new DeviceManagementException("Error occurred while initializing RSS config", e);
|
throw new DeviceManagementException("Error occurred while initializing Data Source config", jaxbEx);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public DeviceManagementConfig getDeviceManagementConfig() {
|
try {
|
||||||
return currentDeviceConfig;
|
File notificationConfig = new File(notificationMessagesConfigXMLPath);
|
||||||
}
|
Document doc = DeviceManagerUtil.convertToDocument(notificationConfig);
|
||||||
|
|
||||||
|
/* Un-marshaling Notifications Management configuration */
|
||||||
|
JAXBContext notificationContext = JAXBContext.newInstance(NotificationMessagesConfig.class);
|
||||||
|
Unmarshaller unmarshaller = notificationContext.createUnmarshaller();
|
||||||
|
this.notificationMessagesConfig = (NotificationMessagesConfig) unmarshaller.unmarshal(doc);
|
||||||
|
}catch(JAXBException jaxbEx){
|
||||||
|
throw new DeviceManagementException("Error occurred while initializing Notification settings config",
|
||||||
|
jaxbEx);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceManagementConfig getDeviceManagementConfig() {
|
||||||
|
return currentDeviceConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotificationMessagesConfig getNotificationMessagesConfig() {
|
||||||
|
return notificationMessagesConfig;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
instructions.configure = \
|
instructions.configure = \
|
||||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/conf/cdm-config.xml,target:${installFolder}/../../conf/cdm-config.xml,overwrite:true);\
|
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/conf/cdm-config.xml,target:${installFolder}/../../conf/cdm-config.xml,overwrite:true);\
|
||||||
|
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/conf/notification-messages.xml,target:${installFolder}/../../conf/notification-messages.xml,overwrite:true);\
|
||||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/conf/license-config.xml,target:${installFolder}/../../conf/etc/license-config.xml,overwrite:true);\
|
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/conf/license-config.xml,target:${installFolder}/../../conf/etc/license-config.xml,overwrite:true);\
|
||||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/dbscripts/cdm,target:${installFolder}/../../../dbscripts/cdm,overwrite:true);\
|
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/dbscripts/cdm,target:${installFolder}/../../../dbscripts/cdm,overwrite:true);\
|
||||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/rxts/license.rxt,target:${installFolder}/../../../repository/resources/rxts/license.rxt,overwrite:true);\
|
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/rxts/license.rxt,target:${installFolder}/../../../repository/resources/rxts/license.rxt,overwrite:true);\
|
||||||
Loading…
Reference in New Issue
Block a user