From 3e51415a64984bd6cdc469098b1b823f122cb48f Mon Sep 17 00:00:00 2001 From: manoj Date: Mon, 23 Mar 2015 20:52:28 +0530 Subject: [PATCH] Refactor Email functionality --- ... => DeviceManagementConfigRepository.java} | 13 +++- .../config/email/EmailConfigurations.java | 66 ++++++++++++++++++ .../{ => email}/EnrolmentNotifications.java | 4 +- .../NotificationMessagesConfig.java | 2 +- .../device/mgt/core/email/EmailConstants.java | 29 ++++++++ .../mgt/core/email/sender/EmailConfig.java | 67 ------------------- 6 files changed, 111 insertions(+), 70 deletions(-) rename components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/{DeviceManagementRepository.java => DeviceManagementConfigRepository.java} (72%) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/email/EmailConfigurations.java rename components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/{ => email}/EnrolmentNotifications.java (97%) rename components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/{ => email}/NotificationMessagesConfig.java (95%) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailConstants.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/sender/EmailConfig.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementRepository.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfigRepository.java similarity index 72% rename from components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementRepository.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfigRepository.java index 3547c4f333..640f8ec2b7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementRepository.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfigRepository.java @@ -18,6 +18,8 @@ package org.wso2.carbon.device.mgt.core.config; import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; +import org.wso2.carbon.device.mgt.core.config.email.EmailConfigurations; + import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -25,9 +27,10 @@ import javax.xml.bind.annotation.XmlRootElement; * Class for holding management repository data. */ @XmlRootElement(name = "ManagementRepository") -public class DeviceManagementRepository { +public class DeviceManagementConfigRepository { private DataSourceConfig dataSourceConfig; + private EmailConfigurations emailConfigurations; @XmlElement(name = "DataSourceConfiguration", required = true) public DataSourceConfig getDataSourceConfig() { @@ -37,5 +40,13 @@ public class DeviceManagementRepository { public void setDataSourceConfig(DataSourceConfig dataSourceConfig) { this.dataSourceConfig = dataSourceConfig; } + + @XmlElement(name = "EmailClientConfiguration", required = true) + public EmailConfigurations getEmailConfigurations() { + return emailConfigurations; + } + public void setEmailConfigurations(EmailConfigurations emailConfigurations) { + this.emailConfigurations = emailConfigurations; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/email/EmailConfigurations.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/email/EmailConfigurations.java new file mode 100644 index 0000000000..ee0393ebc3 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/email/EmailConfigurations.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.core.config.email; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "EmailClientConfiguration") +public class EmailConfigurations { + + private int minNumOfThread; + private int maxNumOfThread; + private int keepAliveTime; + private int threadQueueCapacity; + + @XmlElement(name = "minimumThread", required = true) + public int getMinNumOfThread() { + return minNumOfThread; + } + + public void setMinNumOfThread(int minNumOfThread) { + this.minNumOfThread = minNumOfThread; + } + @XmlElement(name = "maximumThread", required = true) + public int getMaxNumOfThread() { + return maxNumOfThread; + } + + public void setMaxNumOfThread(int maxNumOfThread) { + this.maxNumOfThread = maxNumOfThread; + } + + @XmlElement(name = "maximumThread", required = true) + public int getKeepAliveTime() { + return keepAliveTime; + } + + @XmlElement(name = "keepAliveTime", required = true) + public void setKeepAliveTime(int keepAliveTime) { + this.keepAliveTime = keepAliveTime; + } + @XmlElement(name = "ThreadQueueCapacity", required = true) + public int getThreadQueueCapacity() { + return threadQueueCapacity; + } + + public void setThreadQueueCapacity(int threadQueueCapacity) { + this.threadQueueCapacity = threadQueueCapacity; + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/EnrolmentNotifications.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/email/EnrolmentNotifications.java similarity index 97% rename from components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/EnrolmentNotifications.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/email/EnrolmentNotifications.java index 9eb832690d..5f8e4ee8b2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/EnrolmentNotifications.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/email/EnrolmentNotifications.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.core.config; +package org.wso2.carbon.device.mgt.core.config.email; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -56,6 +56,7 @@ public class EnrolmentNotifications { public void setFooter(String footer) { this.footer = footer; } + @XmlElement(name = "Subject", required = true) public String getSubject() { return subject; @@ -64,6 +65,7 @@ public class EnrolmentNotifications { public void setSubject(String subject) { this.subject = subject; } + @XmlElement(name = "Url", required = true) public String getUrl() { return url; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/NotificationMessagesConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/email/NotificationMessagesConfig.java similarity index 95% rename from components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/NotificationMessagesConfig.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/email/NotificationMessagesConfig.java index 0cd4b67c53..9a681b3b76 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/NotificationMessagesConfig.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/email/NotificationMessagesConfig.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.core.config; +package org.wso2.carbon.device.mgt.core.config.email; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailConstants.java new file mode 100644 index 0000000000..2e9babdbdb --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailConstants.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.carbon.device.mgt.core.email; + +public final class EmailConstants { + + public static final class EnrolmentEmailConstants { + public static final String TITLE = "title"; + public static final String USERNAME = "user-name"; + public static final String DOwN_LOAD_URL = "downloadUrl"; + public static final String ENCODED_SCHEME = "UTF-8"; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/sender/EmailConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/sender/EmailConfig.java deleted file mode 100644 index 3351cad16f..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/sender/EmailConfig.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.wso2.carbon.device.mgt.core.email.sender; - -public class EmailConfig { - - private String subject; - private String firstName; - private String address; - private String enrollmentUrl; - - public EmailConfig(String subject, String firstName, String address, String enrollmentUrl) { - this.subject = subject; - this.firstName = firstName; - this.address = address; - this.enrollmentUrl = enrollmentUrl; - } - - public String getSubject() { - return subject; - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - public String getEnrollmentUrl() { - return enrollmentUrl; - } - - public void setEnrollmentUrl(String enrollmentUrl) { - this.enrollmentUrl = enrollmentUrl; - } - -}