|
|
@ -22,10 +22,8 @@ import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.wso2.carbon.device.mgt.common.*;
|
|
|
|
import org.wso2.carbon.device.mgt.common.*;
|
|
|
|
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.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.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.spi.DeviceManager;
|
|
|
|
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.DeviceConfigurationManager;
|
|
|
|
import org.wso2.carbon.device.mgt.core.config.email.NotificationMessages;
|
|
|
|
import org.wso2.carbon.device.mgt.core.config.email.NotificationMessages;
|
|
|
@ -37,9 +35,8 @@ import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.Status;
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.Status;
|
|
|
|
import org.wso2.carbon.device.mgt.core.email.EmailConstants;
|
|
|
|
import org.wso2.carbon.device.mgt.core.email.EmailConstants;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
|
|
|
|
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.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;
|
|
|
|
|
|
|
|
|
|
|
@ -54,8 +51,6 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
|
|
|
|
private DeviceDAO deviceDAO;
|
|
|
|
private DeviceDAO deviceDAO;
|
|
|
|
private DeviceTypeDAO deviceTypeDAO;
|
|
|
|
private DeviceTypeDAO deviceTypeDAO;
|
|
|
|
private DeviceManagementRepository pluginRepository;
|
|
|
|
private DeviceManagementRepository pluginRepository;
|
|
|
|
private OperationManager operationManager;
|
|
|
|
|
|
|
|
private LicenseManager licenseManager;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Log log = LogFactory.getLog(DeviceManagementServiceProviderImpl.class);
|
|
|
|
private static Log log = LogFactory.getLog(DeviceManagementServiceProviderImpl.class);
|
|
|
|
|
|
|
|
|
|
|
@ -63,15 +58,11 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
|
|
|
|
this.pluginRepository = pluginRepository;
|
|
|
|
this.pluginRepository = pluginRepository;
|
|
|
|
this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
|
|
|
|
this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
|
|
|
|
this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
|
|
|
|
this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
|
|
|
|
this.operationManager = new OperationManagerImpl();
|
|
|
|
|
|
|
|
this.licenseManager = new LicenseManagerImpl();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DeviceManagementServiceProviderImpl(){
|
|
|
|
public DeviceManagementServiceProviderImpl() {
|
|
|
|
this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
|
|
|
|
this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
|
|
|
|
this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
|
|
|
|
this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
|
|
|
|
this.operationManager = new OperationManagerImpl();
|
|
|
|
|
|
|
|
this.licenseManager = new LicenseManagerImpl();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -104,7 +95,7 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
throw new DeviceManagementException("Error occurred while obtaining the device for id " +
|
|
|
|
throw new DeviceManagementException("Error occurred while obtaining the device for id " +
|
|
|
|
"'" + deviceId.getId() + "' and type:"+deviceId.getType(), e);
|
|
|
|
"'" + deviceId.getId() + "' and type:" + deviceId.getType(), e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return convertedDevice;
|
|
|
|
return convertedDevice;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -256,7 +247,8 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void sendEnrolmentInvitation(EmailMessageProperties emailMessageProperties) throws DeviceManagementException {
|
|
|
|
public void sendEnrolmentInvitation(EmailMessageProperties emailMessageProperties)
|
|
|
|
|
|
|
|
throws DeviceManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
List<NotificationMessages> notificationMessages = DeviceConfigurationManager.getInstance()
|
|
|
|
List<NotificationMessages> notificationMessages = DeviceConfigurationManager.getInstance()
|
|
|
|
.getNotificationMessagesConfig().getNotificationMessagesList();
|
|
|
|
.getNotificationMessagesConfig().getNotificationMessagesList();
|
|
|
@ -267,9 +259,9 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
|
|
|
|
String url = "";
|
|
|
|
String url = "";
|
|
|
|
String subject = "";
|
|
|
|
String subject = "";
|
|
|
|
|
|
|
|
|
|
|
|
for(NotificationMessages notificationMessage : notificationMessages){
|
|
|
|
for (NotificationMessages notificationMessage : notificationMessages) {
|
|
|
|
if (DeviceManagementConstants.EmailNotifications.ENROL_NOTIFICATION_TYPE.
|
|
|
|
if (DeviceManagementConstants.EmailNotifications.ENROL_NOTIFICATION_TYPE.
|
|
|
|
equals(notificationMessage.getType())) {
|
|
|
|
equals(notificationMessage.getType())) {
|
|
|
|
messageHeader = notificationMessage.getHeader();
|
|
|
|
messageHeader = notificationMessage.getHeader();
|
|
|
|
messageBody = notificationMessage.getBody();
|
|
|
|
messageBody = notificationMessage.getBody();
|
|
|
|
messageFooter = notificationMessage.getFooter();
|
|
|
|
messageFooter = notificationMessage.getFooter();
|
|
|
@ -283,18 +275,18 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
messageHeader = messageHeader.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.FIRST_NAME + "\\}",
|
|
|
|
messageHeader = messageHeader.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.FIRST_NAME + "\\}",
|
|
|
|
URLEncoder.encode(emailMessageProperties.getFirstName(),
|
|
|
|
URLEncoder.encode(emailMessageProperties.getFirstName(),
|
|
|
|
EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME));
|
|
|
|
EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME));
|
|
|
|
messageBody = messageBody + System.getProperty("line.separator") + url.replaceAll("\\{"
|
|
|
|
messageBody = messageBody + System.getProperty("line.separator") + url.replaceAll("\\{"
|
|
|
|
+ EmailConstants.EnrolmentEmailConstants.DOWNLOAD_URL + "\\}",
|
|
|
|
+ EmailConstants.EnrolmentEmailConstants.DOWNLOAD_URL + "\\}",
|
|
|
|
URLDecoder.decode(emailMessageProperties.getEnrolmentUrl(),
|
|
|
|
URLDecoder.decode(emailMessageProperties.getEnrolmentUrl(),
|
|
|
|
EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME));
|
|
|
|
EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME));
|
|
|
|
|
|
|
|
|
|
|
|
messageBuilder.append(messageHeader).append(System.getProperty("line.separator"));
|
|
|
|
messageBuilder.append(messageHeader).append(System.getProperty("line.separator"));
|
|
|
|
messageBuilder.append(messageBody).append(System.getProperty("line.separator")).append(messageFooter);
|
|
|
|
messageBuilder.append(messageBody).append(System.getProperty("line.separator")).append(messageFooter);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
log.error("IO error in processing enrol email message "+emailMessageProperties);
|
|
|
|
log.error("IO error in processing enrol email message " + emailMessageProperties);
|
|
|
|
throw new DeviceManagementException("Error replacing tags in email template '" +
|
|
|
|
throw new DeviceManagementException("Error replacing tags in email template '" +
|
|
|
|
emailMessageProperties.getSubject() + "'", e);
|
|
|
|
emailMessageProperties.getSubject() + "'", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -314,9 +306,9 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
|
|
|
|
String url = "";
|
|
|
|
String url = "";
|
|
|
|
String subject = "";
|
|
|
|
String subject = "";
|
|
|
|
|
|
|
|
|
|
|
|
for(NotificationMessages notificationMessage : notificationMessages){
|
|
|
|
for (NotificationMessages notificationMessage : notificationMessages) {
|
|
|
|
if (DeviceManagementConstants.EmailNotifications.USER_REGISTRATION_NOTIFICATION_TYPE.
|
|
|
|
if (DeviceManagementConstants.EmailNotifications.USER_REGISTRATION_NOTIFICATION_TYPE.
|
|
|
|
equals(notificationMessage.getType())) {
|
|
|
|
equals(notificationMessage.getType())) {
|
|
|
|
messageHeader = notificationMessage.getHeader();
|
|
|
|
messageHeader = notificationMessage.getHeader();
|
|
|
|
messageBody = notificationMessage.getBody();
|
|
|
|
messageBody = notificationMessage.getBody();
|
|
|
|
messageFooter = notificationMessage.getFooter();
|
|
|
|
messageFooter = notificationMessage.getFooter();
|
|
|
@ -350,7 +342,7 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
|
|
|
|
messageBuilder.append(messageBody).append(System.getProperty("line.separator")).append(messageFooter);
|
|
|
|
messageBuilder.append(messageBody).append(System.getProperty("line.separator")).append(messageFooter);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
log.error("IO error in processing enrol email message "+emailMessageProperties);
|
|
|
|
log.error("IO error in processing enrol email message " + emailMessageProperties);
|
|
|
|
throw new DeviceManagementException("Error replacing tags in email template '" +
|
|
|
|
throw new DeviceManagementException("Error replacing tags in email template '" +
|
|
|
|
emailMessageProperties.getSubject() + "'", e);
|
|
|
|
emailMessageProperties.getSubject() + "'", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -402,12 +394,12 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public License getLicense(String deviceType, String languageCode) throws LicenseManagementException {
|
|
|
|
public License getLicense(String deviceType, String languageCode) throws LicenseManagementException {
|
|
|
|
return licenseManager.getLicense(deviceType, languageCode);
|
|
|
|
return DeviceManagementDataHolder.getInstance().getLicenseManager().getLicense(deviceType, languageCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean addLicense(String type, License license) throws LicenseManagementException {
|
|
|
|
public boolean addLicense(String type, License license) throws LicenseManagementException {
|
|
|
|
return licenseManager.addLicense(type, license);
|
|
|
|
return DeviceManagementDataHolder.getInstance().getLicenseManager().addLicense(type, license);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DeviceDAO getDeviceDAO() {
|
|
|
|
public DeviceDAO getDeviceDAO() {
|
|
|
@ -425,55 +417,58 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean addOperation(Operation operation, List<DeviceIdentifier> devices) throws
|
|
|
|
public boolean addOperation(Operation operation, List<DeviceIdentifier> devices) throws
|
|
|
|
OperationManagementException {
|
|
|
|
OperationManagementException {
|
|
|
|
return operationManager.addOperation(operation, devices);
|
|
|
|
return DeviceManagementDataHolder.getInstance().getOperationManager().addOperation(operation, devices);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<? extends Operation> getOperations(DeviceIdentifier deviceId) throws OperationManagementException {
|
|
|
|
public List<? extends Operation> getOperations(DeviceIdentifier deviceId) throws OperationManagementException {
|
|
|
|
return operationManager.getOperations(deviceId);
|
|
|
|
return DeviceManagementDataHolder.getInstance().getOperationManager().getOperations(deviceId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<? extends Operation> getPendingOperations(DeviceIdentifier deviceId) throws OperationManagementException {
|
|
|
|
public List<? extends Operation> getPendingOperations(DeviceIdentifier deviceId)
|
|
|
|
return operationManager.getPendingOperations(deviceId);
|
|
|
|
throws OperationManagementException {
|
|
|
|
|
|
|
|
return DeviceManagementDataHolder.getInstance().getOperationManager().getPendingOperations(deviceId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Operation getNextPendingOperation(DeviceIdentifier deviceId) throws OperationManagementException {
|
|
|
|
public Operation getNextPendingOperation(DeviceIdentifier deviceId) throws OperationManagementException {
|
|
|
|
return operationManager.getNextPendingOperation(deviceId);
|
|
|
|
return DeviceManagementDataHolder.getInstance().getOperationManager().getNextPendingOperation(deviceId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void updateOperation(int operationId, Operation.Status operationStatus)
|
|
|
|
public void updateOperation(int operationId, Operation.Status operationStatus)
|
|
|
|
throws OperationManagementException {
|
|
|
|
throws OperationManagementException {
|
|
|
|
operationManager.updateOperation(operationId, operationStatus);
|
|
|
|
DeviceManagementDataHolder.getInstance().getOperationManager().updateOperation(operationId, operationStatus);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void deleteOperation(int operationId) throws OperationManagementException {
|
|
|
|
public void deleteOperation(int operationId) throws OperationManagementException {
|
|
|
|
operationManager.deleteOperation(operationId);
|
|
|
|
DeviceManagementDataHolder.getInstance().getOperationManager().deleteOperation(operationId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Operation getOperationByDeviceAndOperationId(DeviceIdentifier deviceId, int operationId)
|
|
|
|
public Operation getOperationByDeviceAndOperationId(DeviceIdentifier deviceId, int operationId)
|
|
|
|
throws OperationManagementException {
|
|
|
|
throws OperationManagementException {
|
|
|
|
return operationManager.getOperationByDeviceAndOperationId(deviceId, operationId);
|
|
|
|
return DeviceManagementDataHolder.getInstance().getOperationManager().getOperationByDeviceAndOperationId(
|
|
|
|
|
|
|
|
deviceId, operationId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<? extends Operation> getOperationsByDeviceAndStatus(DeviceIdentifier identifier,
|
|
|
|
public List<? extends Operation> getOperationsByDeviceAndStatus(DeviceIdentifier identifier,
|
|
|
|
Operation.Status status) throws OperationManagementException, DeviceManagementException {
|
|
|
|
Operation.Status status) throws OperationManagementException, DeviceManagementException {
|
|
|
|
return operationManager.getOperationsByDeviceAndStatus(identifier, status);
|
|
|
|
return DeviceManagementDataHolder.getInstance().getOperationManager().getOperationsByDeviceAndStatus(identifier,
|
|
|
|
|
|
|
|
status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Operation getOperation(int operationId) throws OperationManagementException {
|
|
|
|
public Operation getOperation(int operationId) throws OperationManagementException {
|
|
|
|
return operationManager.getOperation(operationId);
|
|
|
|
return DeviceManagementDataHolder.getInstance().getOperationManager().getOperation(operationId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<? extends Operation> getOperationsForStatus(Operation.Status status)
|
|
|
|
public List<? extends Operation> getOperationsForStatus(Operation.Status status)
|
|
|
|
throws OperationManagementException {
|
|
|
|
throws OperationManagementException {
|
|
|
|
return operationManager.getOperationsForStatus(status);
|
|
|
|
return DeviceManagementDataHolder.getInstance().getOperationManager().getOperationsForStatus(status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|