From a41c1421e995ed9e0eb610e75ed3023071d96a41 Mon Sep 17 00:00:00 2001 From: manoj Date: Wed, 18 Mar 2015 18:55:56 +0530 Subject: [PATCH 1/9] User list --- .../org.wso2.carbon.device.mgt.core/pom.xml | 3 ++- .../internal/DeviceManagementDataHolder.java | 10 ++++++++++ .../DeviceManagementServiceComponent.java | 3 ++- .../mgt/core/util/DeviceManagerUtil.java | 5 +++++ .../pom.xml | 2 +- .../pom.xml | 2 +- pom.xml | 20 ++++++++++++++++--- 7 files changed, 38 insertions(+), 7 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index 56f6fd79fa..9fd1737a82 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -71,7 +71,8 @@ org.wso2.carbon.registry.core.exceptions, org.wso2.carbon.registry.core.service, org.wso2.carbon.registry.core.session, - org.w3c.dom + org.w3c.dom, + org.wso2.carbon.email.verification.util !org.wso2.carbon.device.mgt.core.internal, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java index 21c9379bae..bc7a51db48 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java @@ -22,6 +22,7 @@ package org.wso2.carbon.device.mgt.core.internal; import org.wso2.carbon.device.mgt.core.DeviceManager; import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig; import org.wso2.carbon.device.mgt.core.license.mgt.LicenseManager; +import org.wso2.carbon.email.verification.util.EmailVerifcationSubscriber; import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.user.core.tenant.TenantManager; @@ -35,6 +36,15 @@ public class DeviceManagementDataHolder { private RegistryService registryService; private LicenseConfig licenseConfig; + public static EmailVerifcationSubscriber getEmailVerificationSubscriber() { + return emailVerificationSubscriber; + } + + public static void setEmailVerificationSubscriber(EmailVerifcationSubscriber emailVerificationSubscriber) { + DeviceManagementDataHolder.emailVerificationSubscriber = emailVerificationSubscriber; + } + + private static EmailVerifcationSubscriber emailVerificationSubscriber; private static DeviceManagementDataHolder thisInstance = new DeviceManagementDataHolder(); private DeviceManagementDataHolder() { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java index 979323200e..332eaaa3fa 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -40,6 +40,7 @@ import org.wso2.carbon.device.mgt.core.license.mgt.LicenseManager; import org.wso2.carbon.device.mgt.core.license.mgt.LicenseManagerImpl; import org.wso2.carbon.device.mgt.core.service.DeviceManagementService; import org.wso2.carbon.device.mgt.core.util.DeviceManagementSchemaInitializer; +import org.wso2.carbon.email.verification.util.EmailVerifcationSubscriber; import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.user.core.service.RealmService; @@ -227,7 +228,7 @@ public class DeviceManagementServiceComponent { */ protected void unsetRegistryService(RegistryService registryService) { if (log.isDebugEnabled()) { - log.debug("Unsetting Registry Service"); + log.debug("Un setting Registry Service"); } DeviceManagementDataHolder.getInstance().setRegistryService(null); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java index fd4a442164..7660a0124b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java @@ -39,6 +39,7 @@ import java.util.Hashtable; import java.util.List; import java.util.Map; + public final class DeviceManagerUtil { private static final Log log = LogFactory.getLog(DeviceManagerUtil.class); @@ -147,4 +148,8 @@ public final class DeviceManagerUtil { return propertiesMap; } + public static void sendEmail(){ + + } + } diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml index 41b5933cf7..cd603ae9c9 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml @@ -32,7 +32,7 @@ 0.9.2-SNAPSHOT WSO2 Carbon - Device Management Server Feature http://wso2.org - This feature contains the core bundles required for Back-end Devvice Management functionality + This feature contains the core bundles required for Back-end Device Management functionality diff --git a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml index d09ae350bb..9e0f8ba3bb 100644 --- a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml @@ -33,7 +33,7 @@ 0.9.2-SNAPSHOT WSO2 Carbon - Policy Management Server Feature http://wso2.org - This feature contains the core bundles required for Back-end Devvice Management functionality + This feature contains the core bundles required for Back-end Device Management functionality diff --git a/pom.xml b/pom.xml index 4c213f5c97..3814ec8daf 100644 --- a/pom.xml +++ b/pom.xml @@ -37,8 +37,10 @@ components/device-mgt components/policy-mgt + components/user-mgt features/device-mgt features/policy-mgt + features/user-mgt @@ -75,6 +77,21 @@ org.wso2.carbon.policy.information.point ${carbon.device.mgt.version} + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.user.core + ${carbon.device.mgt.version} + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.user.common + ${carbon.device.mgt.version} + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.user.common + ${carbon.device.mgt.version} + @@ -591,9 +608,6 @@ 7.0.52.wso2v5 7.0.34.wso2v2 - - 4.3.4 - 4.3.1 From d398b2929cb5a502508e4a5324c41ad2aede4d3f Mon Sep 17 00:00:00 2001 From: manoj Date: Wed, 18 Mar 2015 18:58:03 +0530 Subject: [PATCH 2/9] Users functionalities --- .../pom.xml | 60 ++++++++ .../carbon/device/mgt/user/common/Claims.java | 60 ++++++++ .../carbon/device/mgt/user/common/Role.java | 38 +++++ .../carbon/device/mgt/user/common/User.java | 61 ++++++++ .../user/common/UserManagementException.java | 56 ++++++++ .../pom.xml | 116 +++++++++++++++ .../device/mgt/user/core/UserManager.java | 31 ++++ .../device/mgt/user/core/UserManagerImpl.java | 133 ++++++++++++++++++ .../internal/DeviceMgtUserDataHolder.java | 66 +++++++++ .../DeviceMgtUserServiceComponent.java | 86 +++++++++++ .../core/service/UserManagementService.java | 46 ++++++ components/user-mgt/pom.xml | 61 ++++++++ .../pom.xml | 117 +++++++++++++++ .../src/main/resources/build.properties | 1 + .../src/main/resources/p2.inf | 0 features/user-mgt/pom.xml | 47 +++++++ 16 files changed, 979 insertions(+) create mode 100644 components/user-mgt/org.wso2.carbon.device.mgt.user.common/pom.xml create mode 100644 components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/Claims.java create mode 100644 components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/Role.java create mode 100644 components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/User.java create mode 100644 components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/UserManagementException.java create mode 100644 components/user-mgt/org.wso2.carbon.device.mgt.user.core/pom.xml create mode 100644 components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/UserManager.java create mode 100644 components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/UserManagerImpl.java create mode 100644 components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/internal/DeviceMgtUserDataHolder.java create mode 100644 components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/internal/DeviceMgtUserServiceComponent.java create mode 100644 components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/service/UserManagementService.java create mode 100644 components/user-mgt/pom.xml create mode 100644 features/user-mgt/org.wso2.carbon.devicemgt.user.server.feature/pom.xml create mode 100644 features/user-mgt/org.wso2.carbon.devicemgt.user.server.feature/src/main/resources/build.properties create mode 100644 features/user-mgt/org.wso2.carbon.devicemgt.user.server.feature/src/main/resources/p2.inf create mode 100644 features/user-mgt/pom.xml diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.common/pom.xml b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/pom.xml new file mode 100644 index 0000000000..25ee050fe3 --- /dev/null +++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/pom.xml @@ -0,0 +1,60 @@ + + + + + + user-mgt + org.wso2.carbon.devicemgt + 0.9.2-SNAPSHOT + ../pom.xml + + 4.0.0 + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.user.common + 0.9.2-SNAPSHOT + bundle + + + + org.apache.felix + maven-bundle-plugin + 1.4.0 + true + + + ${project.artifactId} + ${project.artifactId} + ${carbon.device.mgt.version} + Device Management User Common Bundle + + org.wso2.carbon.device.mgt.user.common.* + + + + + + + + \ No newline at end of file diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/Claims.java b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/Claims.java new file mode 100644 index 0000000000..b398522c45 --- /dev/null +++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/Claims.java @@ -0,0 +1,60 @@ +/* + * 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.user.common; + +public class Claims { + + private String dialectUrl; + private String description; + private String claimUrl; + private String value; + + public String getDialectUrl() { + return dialectUrl; + } + + public void setDialectUrl(String dialectUrl) { + this.dialectUrl = dialectUrl; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getClaimUrl() { + return claimUrl; + } + + public void setClaimUrl(String claimUrl) { + this.claimUrl = claimUrl; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/Role.java b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/Role.java new file mode 100644 index 0000000000..76ea260813 --- /dev/null +++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/Role.java @@ -0,0 +1,38 @@ +/* + * 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.user.common; + +public class Role { + + private String roleName; + + public Role(String roleName) { + this.roleName = roleName; + } + + public String getRoleName() { + return roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + +} diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/User.java b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/User.java new file mode 100644 index 0000000000..19e8682fb5 --- /dev/null +++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/User.java @@ -0,0 +1,61 @@ +/* + * 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.user.common; + +import java.util.ArrayList; + +public class User { + + private String userName; + private String roleName; + private ArrayList claimList; + + public User(String userName) { + this.userName = userName; + } + + public User(String userName, String roleName) { + this.userName = userName; + this.roleName = roleName; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getRoleName() { + return roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + public ArrayList getClaimList() { + return claimList; + } + + public void setClaimList(ArrayList claimList) { + this.claimList = claimList; + } +} diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/UserManagementException.java b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/UserManagementException.java new file mode 100644 index 0000000000..45989b1908 --- /dev/null +++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/src/main/java/org/wso2/carbon/device/mgt/user/common/UserManagementException.java @@ -0,0 +1,56 @@ +/* + * 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.user.common; + +public class UserManagementException extends Exception{ + + private static final long serialVersionUID = -312678248574816874L; + private String errorMessage; + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public UserManagementException(String msg, Exception nestedEx) { + super(msg, nestedEx); + setErrorMessage(msg); + } + + public UserManagementException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + public UserManagementException(String msg) { + super(msg); + setErrorMessage(msg); + } + + public UserManagementException() { + super(); + } + + public UserManagementException(Throwable cause) { + super(cause); + } +} diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.core/pom.xml b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/pom.xml new file mode 100644 index 0000000000..d7fdee7ade --- /dev/null +++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/pom.xml @@ -0,0 +1,116 @@ + + + + + user-mgt + org.wso2.carbon.devicemgt + 0.9.2-SNAPSHOT + ../pom.xml + + 4.0.0 + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.user.core + 0.9.2-SNAPSHOT + bundle + WSO2 Carbon - Device Management user core + WSO2 Carbon - Device Management user core + http://wso2.org + + + + + org.apache.felix + maven-scr-plugin + + + org.apache.felix + maven-bundle-plugin + 1.4.0 + true + + + ${project.artifactId} + ${project.artifactId} + ${carbon.device.mgt.version} + Device Management Core User Bundle + org.wso2.carbon.device.mgt.user.core.internal + + org.wso2.carbon.device.mgt.user.common.*, + org.wso2.carbon.user.core.*, + org.apache.commons.logging.*, + org.osgi.framework.*, + org.osgi.service.component.*, + org.wso2.carbon.user.api.* + + + !org.wso2.carbon.device.mgt.user.core.internal, + org.wso2.carbon.device.mgt.user.core.* + + + + + + + + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.user.common + + + org.wso2.carbon + org.wso2.carbon.user.core + + + org.wso2.carbon + org.wso2.carbon.logging + + + org.eclipse.osgi + org.eclipse.osgi + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.common + + + org.wso2.carbon + org.wso2.carbon.utils + + + org.wso2.carbon + org.wso2.carbon.core + + + org.wso2.carbon + org.wso2.carbon.user.core + + + org.wso2.carbon + org.wso2.carbon.user.api + + + org.wso2.carbon + org.wso2.carbon.base + + + \ No newline at end of file diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/UserManager.java b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/UserManager.java new file mode 100644 index 0000000000..f73be18c56 --- /dev/null +++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/UserManager.java @@ -0,0 +1,31 @@ +/* + * 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.user.core; + +import org.wso2.carbon.device.mgt.user.common.Role; +import org.wso2.carbon.device.mgt.user.common.User; +import org.wso2.carbon.device.mgt.user.common.UserManagementException; + +import java.util.List; + +public interface UserManager { + public List getUsersForTenantAndRole(int tenantId, String roleName) throws UserManagementException; + public List getRolesForTenant(int tenantId) throws UserManagementException; + public List getUsersForTenant(int tenantId) throws UserManagementException; +} diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/UserManagerImpl.java b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/UserManagerImpl.java new file mode 100644 index 0000000000..fc7a2d3210 --- /dev/null +++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/UserManagerImpl.java @@ -0,0 +1,133 @@ +/* + * 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.user.core; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.user.common.Claims; +import org.wso2.carbon.device.mgt.user.common.Role; +import org.wso2.carbon.device.mgt.user.common.User; +import org.wso2.carbon.device.mgt.user.common.UserManagementException; +import org.wso2.carbon.device.mgt.user.core.internal.DeviceMgtUserDataHolder; +import org.wso2.carbon.user.api.Claim; +import org.wso2.carbon.user.api.UserStoreException; +import org.wso2.carbon.user.api.UserStoreManager; + +import java.util.ArrayList; +import java.util.List; + +public class UserManagerImpl implements UserManager { + + private static Log log = LogFactory.getLog(UserManagerImpl.class); + + @Override + public List getUsersForTenantAndRole(int tenantId, String roleName) throws UserManagementException { + + UserStoreManager userStoreManager; + String[] userNames; + ArrayList usersList = new ArrayList(); + + try { + userStoreManager = DeviceMgtUserDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId) + .getUserStoreManager(); + + userNames = userStoreManager.getUserListOfRole(roleName); + User newUser; + for (String userName : userNames) { + newUser = new User(userName); + setUserClaims(newUser, userStoreManager.getUserClaimValues(userName, null)); + usersList.add(newUser); + } + } catch (UserStoreException userStoreEx) { + String errorMsg = "User store error in fetching user list for role and tenant tenant id:" + tenantId + + " role name:" + roleName; + log.error(errorMsg, userStoreEx); + throw new UserManagementException(errorMsg, userStoreEx); + } + return usersList; + } + + @Override + public List getRolesForTenant(int tenantId) throws UserManagementException { + + String[] roleNames; + ArrayList rolesList = new ArrayList(); + Role newRole; + try { + UserStoreManager userStoreManager = DeviceMgtUserDataHolder.getInstance().getRealmService() + .getTenantUserRealm(tenantId) + .getUserStoreManager(); + + roleNames = userStoreManager.getRoleNames(); + for (String roleName : roleNames) { + newRole = new Role(roleName); + rolesList.add(newRole); + } + + } catch (UserStoreException userStoreEx) { + String errorMsg = "User store error in fetching user list for role and tenant tenant id:" + tenantId; + log.error(errorMsg, userStoreEx); + throw new UserManagementException(errorMsg, userStoreEx); + } + return rolesList; + } + + @Override + public List getUsersForTenant(int tenantId) throws UserManagementException { + + UserStoreManager userStoreManager; + String[] userNames; + ArrayList usersList = new ArrayList(); + + try { + userStoreManager = DeviceMgtUserDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId) + .getUserStoreManager(); + + userNames = userStoreManager.listUsers("",-1); + User newUser; + for (String userName : userNames) { + newUser = new User(userName); + setUserClaims(newUser, userStoreManager.getUserClaimValues(userName, null)); + usersList.add(newUser); + } + } catch (UserStoreException userStoreEx) { + String errorMsg = "User store error in fetching user list for tenant id:" + tenantId; + log.error(errorMsg, userStoreEx); + throw new UserManagementException(errorMsg, userStoreEx); + } + + return usersList; + } + + private void setUserClaims(User newUser, Claim[] userClaimValues) { + + Claims userClaims; + ArrayList claimsList = new ArrayList(); + for (Claim claim : userClaimValues) { + userClaims = new Claims(); + userClaims.setClaimUrl(claim.getClaimUri()); + userClaims.setDescription(claim.getDescription()); + userClaims.setDialectUrl(claim.getDialectURI()); + userClaims.setValue(claim.getValue()); + claimsList.add(userClaims); + } + newUser.setClaimList(claimsList); + } + +} diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/internal/DeviceMgtUserDataHolder.java b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/internal/DeviceMgtUserDataHolder.java new file mode 100644 index 0000000000..70e31cb3a1 --- /dev/null +++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/internal/DeviceMgtUserDataHolder.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.user.core.internal; + +import org.wso2.carbon.device.mgt.user.core.UserManager; +import org.wso2.carbon.user.core.service.RealmService; +import org.wso2.carbon.user.core.tenant.TenantManager; + +public class DeviceMgtUserDataHolder { + + private RealmService realmService; + private TenantManager tenantManager; + private static DeviceMgtUserDataHolder thisInstance = new DeviceMgtUserDataHolder(); + private UserManager userManager; + + private DeviceMgtUserDataHolder() { + } + + public static DeviceMgtUserDataHolder getInstance() { + return thisInstance; + } + + public RealmService getRealmService() { + return realmService; + } + + private void setTenantManager(RealmService realmService) { + if (realmService == null) { + throw new IllegalStateException("Realm service is not initialized properly"); + } + this.tenantManager = realmService.getTenantManager(); + } + + public void setRealmService(RealmService realmService) { + this.realmService = realmService; + this.setTenantManager(realmService); + } + + public TenantManager getTenantManager() { + return tenantManager; + } + + public UserManager getUserManager() { + return userManager; + } + + public void setUserManager(UserManager userManager) { + this.userManager = userManager; + } +} diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/internal/DeviceMgtUserServiceComponent.java b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/internal/DeviceMgtUserServiceComponent.java new file mode 100644 index 0000000000..ceb7137a02 --- /dev/null +++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/internal/DeviceMgtUserServiceComponent.java @@ -0,0 +1,86 @@ +/* + * 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.user.core.internal; + + +import org.osgi.service.component.ComponentContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.framework.BundleContext; +import org.wso2.carbon.device.mgt.user.core.UserManager; +import org.wso2.carbon.device.mgt.user.core.UserManagerImpl; +import org.wso2.carbon.device.mgt.user.core.service.UserManagementService; +import org.wso2.carbon.user.core.service.RealmService; + + +/** + * @scr.component name="org.wso2.carbon.device.manager" immediate="true" + * @scr.reference name="user.realmservice.default" + * interface="org.wso2.carbon.user.core.service.RealmService" + * cardinality="1..1" + * policy="dynamic" + * bind="setRealmService" + * unbind="unsetRealmService" + */ +public class DeviceMgtUserServiceComponent { + + private static Log log = LogFactory.getLog(DeviceMgtUserServiceComponent.class); + + protected void activate(ComponentContext componentContext) { + try { + if (log.isDebugEnabled()) { + log.debug("Initializing user management core bundle"); + } + + UserManager userMgr = new UserManagerImpl(); + DeviceMgtUserDataHolder.getInstance().setUserManager(userMgr); + + if (log.isDebugEnabled()) { + log.debug("Registering OSGi service User Management Service"); + } + /* Registering User Management service */ + BundleContext bundleContext = componentContext.getBundleContext(); + bundleContext.registerService(UserManagementService.class.getName(), + new UserManagementService(), null); + if (log.isDebugEnabled()) { + log.debug("User management core bundle has been successfully initialized"); + } + } catch (Throwable e) { + String msg = "Error occurred while initializing user management core bundle"; + log.error(msg, e); + } + } + /** + * Sets Realm Service. + * + * @param realmService An instance of RealmService + */ + protected void setRealmService(RealmService realmService) { + DeviceMgtUserDataHolder.getInstance().setRealmService(realmService); + } + + /** + * Un sets Realm Service. + * + * @param realmService An instance of RealmService + */ + protected void unsetRealmService(RealmService realmService) { + DeviceMgtUserDataHolder.getInstance().setRealmService(null); + } + +} diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/service/UserManagementService.java b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/service/UserManagementService.java new file mode 100644 index 0000000000..5e051f2640 --- /dev/null +++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.core/src/main/java/org/wso2/carbon/device/mgt/user/core/service/UserManagementService.java @@ -0,0 +1,46 @@ +/* + * 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.user.core.service; + +import org.wso2.carbon.device.mgt.user.common.Role; +import org.wso2.carbon.device.mgt.user.common.User; +import org.wso2.carbon.device.mgt.user.common.UserManagementException; +import org.wso2.carbon.device.mgt.user.core.UserManager; +import org.wso2.carbon.device.mgt.user.core.internal.DeviceMgtUserDataHolder; + +import java.util.List; + +public class UserManagementService implements UserManager{ + + @Override + public List getUsersForTenantAndRole(int tenantId, String roleName) throws UserManagementException { + return DeviceMgtUserDataHolder.getInstance().getUserManager().getUsersForTenantAndRole(tenantId, roleName); + } + + @Override + public List getRolesForTenant(int tenantId) throws UserManagementException { + return DeviceMgtUserDataHolder.getInstance().getUserManager().getRolesForTenant(tenantId); + } + + @Override + public List getUsersForTenant(int tenantId) throws UserManagementException { + return DeviceMgtUserDataHolder.getInstance().getUserManager().getUsersForTenant(tenantId); + } +} diff --git a/components/user-mgt/pom.xml b/components/user-mgt/pom.xml new file mode 100644 index 0000000000..3c0e10a272 --- /dev/null +++ b/components/user-mgt/pom.xml @@ -0,0 +1,61 @@ + + + + + carbon-devicemgt + org.wso2.carbon.devicemgt + 0.9.2-SNAPSHOT + ../../pom.xml + + 4.0.0 + + org.wso2.carbon.devicemgt + user-mgt + pom + 0.9.2-SNAPSHOT + WSO2 Carbon - Device Management User Component + http://wso2.org + + + org.wso2.carbon.device.mgt.user.common + org.wso2.carbon.device.mgt.user.core + + + + + + + org.apache.felix + maven-scr-plugin + 1.7.2 + + + generate-scr-scrdescriptor + + scr + + + + + + + + \ No newline at end of file diff --git a/features/user-mgt/org.wso2.carbon.devicemgt.user.server.feature/pom.xml b/features/user-mgt/org.wso2.carbon.devicemgt.user.server.feature/pom.xml new file mode 100644 index 0000000000..ace0db9693 --- /dev/null +++ b/features/user-mgt/org.wso2.carbon.devicemgt.user.server.feature/pom.xml @@ -0,0 +1,117 @@ + + + + + + user-mgt-feature + org.wso2.carbon.devicemgt + 0.9.2-SNAPSHOT + ../pom.xml + + 4.0.0 + + org.wso2.carbon.devicemgt + org.wso2.carbon.devicemgt.user.server.feature + pom + 0.9.2-SNAPSHOT + WSO2 Carbon - User Management Server Feature + http://wso2.org + This feature contains the core bundles required for Back-end Device Management User + related functionality + + + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.user.core + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.user.common + + + + + + + maven-resources-plugin + 2.6 + + + copy-resources + generate-resources + + copy-resources + + + src/main/resources + + + resources + + build.properties + p2.inf + + + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.devicemgt.user.server + ../../../features/etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + org.eclipse.equinox.p2.type.group:false + + + + org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.user.core:${carbon.device.mgt.version} + + org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.user.common:${carbon.device.mgt.version} + + + + org.wso2.carbon.core.server:${carbon.kernel.version} + + + + + + + + \ No newline at end of file diff --git a/features/user-mgt/org.wso2.carbon.devicemgt.user.server.feature/src/main/resources/build.properties b/features/user-mgt/org.wso2.carbon.devicemgt.user.server.feature/src/main/resources/build.properties new file mode 100644 index 0000000000..9c86577d76 --- /dev/null +++ b/features/user-mgt/org.wso2.carbon.devicemgt.user.server.feature/src/main/resources/build.properties @@ -0,0 +1 @@ +custom = true diff --git a/features/user-mgt/org.wso2.carbon.devicemgt.user.server.feature/src/main/resources/p2.inf b/features/user-mgt/org.wso2.carbon.devicemgt.user.server.feature/src/main/resources/p2.inf new file mode 100644 index 0000000000..e69de29bb2 diff --git a/features/user-mgt/pom.xml b/features/user-mgt/pom.xml new file mode 100644 index 0000000000..1f916bd68a --- /dev/null +++ b/features/user-mgt/pom.xml @@ -0,0 +1,47 @@ + + + + + + org.wso2.carbon.devicemgt + carbon-devicemgt + 0.9.2-SNAPSHOT + ../../pom.xml + + 4.0.0 + + org.wso2.carbon.devicemgt + user-mgt-feature + 0.9.2-SNAPSHOT + + pom + WSO2 Carbon - User Management Feature + http://wso2.org + + + + org.wso2.carbon.devicemgt.user.server.feature + + + \ No newline at end of file From e7d165d3b9e81ef920d20cb33c542f5ddcd3c7f2 Mon Sep 17 00:00:00 2001 From: manoj Date: Wed, 18 Mar 2015 19:20:41 +0530 Subject: [PATCH 3/9] Email sending --- .../mgt/core/internal/DeviceManagementDataHolder.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java index 67c3ac1f5b..4ad6790ffd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java @@ -36,14 +36,6 @@ public class DeviceManagementDataHolder { private RegistryService registryService; private LicenseConfig licenseConfig; - public static EmailVerifcationSubscriber getEmailVerificationSubscriber() { - return emailVerificationSubscriber; - } - - public static void setEmailVerificationSubscriber(EmailVerifcationSubscriber emailVerificationSubscriber) { - DeviceManagementDataHolder.emailVerificationSubscriber = emailVerificationSubscriber; - } - private static EmailVerifcationSubscriber emailVerificationSubscriber; private static DeviceManagementDataHolder thisInstance = new DeviceManagementDataHolder(); From 58337a986df856c09159f6fb748993da4834e267 Mon Sep 17 00:00:00 2001 From: manoj Date: Wed, 18 Mar 2015 19:23:21 +0530 Subject: [PATCH 4/9] Email functionality --- .../mgt/core/internal/DeviceManagementDataHolder.java | 6 ++---- .../mgt/core/internal/DeviceManagementServiceComponent.java | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java index 4ad6790ffd..5a0f996583 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java @@ -19,10 +19,9 @@ package org.wso2.carbon.device.mgt.core.internal; -import org.wso2.carbon.device.mgt.core.service.DeviceManagementService; -import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig; -import org.wso2.carbon.email.verification.util.EmailVerifcationSubscriber; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; +import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementService; import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.user.core.tenant.TenantManager; @@ -36,7 +35,6 @@ public class DeviceManagementDataHolder { private RegistryService registryService; private LicenseConfig licenseConfig; - private static EmailVerifcationSubscriber emailVerificationSubscriber; private static DeviceManagementDataHolder thisInstance = new DeviceManagementDataHolder(); private DeviceManagementDataHolder() { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java index b451e2e868..180df8235d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -39,7 +39,6 @@ import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; import org.wso2.carbon.device.mgt.core.license.mgt.LicenseManagerImpl; import org.wso2.carbon.device.mgt.core.service.DeviceManagementServiceImpl; import org.wso2.carbon.device.mgt.core.util.DeviceManagementSchemaInitializer; -import org.wso2.carbon.email.verification.util.EmailVerifcationSubscriber; import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.user.core.service.RealmService; From 4600968d604009be55b6a689e25d0701b90c10e2 Mon Sep 17 00:00:00 2001 From: Dulitha Wijewantha Date: Thu, 19 Mar 2015 11:17:18 +0530 Subject: [PATCH 5/9] * Re-added the method to convert a Device Property list to a Map --- .../carbon/device/mgt/core/util/DeviceManagerUtil.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java index 110e46dacf..eb4b1daa40 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java @@ -132,5 +132,11 @@ public final class DeviceManagerUtil { deviceType + "'", e); } } - + public static Map convertDevicePropertiesToMap(List properties) { + Map propertiesMap = new HashMap(); + for (Device.Property prop : properties) { + propertiesMap.put(prop.getName(), prop.getValue()); + } + return propertiesMap; + } } From fc86ccd86dc92f574cbe7d03e4d55f3bc0202769 Mon Sep 17 00:00:00 2001 From: Dulitha Wijewantha Date: Fri, 20 Mar 2015 10:23:32 +0530 Subject: [PATCH 6/9] * Setup the datasource for the operation manager dao factory * Implemented the get all devices and get devices for user * Added support for tenant domain in get devices for user (This has to be added to all methods) --- .../DeviceManagementServiceProviderImpl.java | 55 +++++++++++- .../carbon/device/mgt/core/dao/DeviceDAO.java | 2 +- .../mgt/core/dao/impl/DeviceDAOImpl.java | 90 +++++++++++++++++-- .../DeviceManagementServiceComponent.java | 11 ++- .../dao/OperationManagementDAOFactory.java | 3 + .../core/service/DeviceManagementService.java | 2 + .../service/DeviceManagementServiceImpl.java | 7 +- .../mgt/core/util/DeviceManagerUtil.java | 5 ++ 8 files changed, 154 insertions(+), 21 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java index 7cabd1002b..d887fe3a98 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementServiceProviderImpl.java @@ -18,6 +18,7 @@ package org.wso2.carbon.device.mgt.core; 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.core.dao.DeviceDAO; @@ -25,8 +26,7 @@ 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.DeviceTypeDAO; 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.Status; +import org.wso2.carbon.device.mgt.core.dto.*; 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.core.license.mgt.LicenseManagerImpl; @@ -35,6 +35,7 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementExcept 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.service.DeviceManagementService; +import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import java.util.ArrayList; import java.util.List; @@ -128,7 +129,29 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ @Override public List getAllDevices() throws DeviceManagementException { - return null; + List convertedDevicesList = new ArrayList(); + try { + List devicesList = this.deviceDAO.getDevices(); + for (int x = 0; x < devicesList.size(); x++) { + org.wso2.carbon.device.mgt.core.dto.Device device = devicesList.get(x); + device.setDeviceType(deviceTypeDAO.getDeviceType(device.getDeviceTypeId())); + DeviceManager dms = + this.getPluginRepository().getDeviceManagementProvider(device.getDeviceType().getName()); + DeviceType deviceType = this.deviceTypeDAO.getDeviceType(device.getDeviceTypeId()); + Device convertedDevice = DeviceManagementDAOUtil.convertDevice(device, deviceType); + DeviceIdentifier deviceIdentifier = + DeviceManagementDAOUtil.createDeviceIdentifier(device, deviceType); + Device dmsDevice = dms.getDevice(deviceIdentifier); + if (dmsDevice != null) { + convertedDevice.setProperties(dmsDevice.getProperties()); + convertedDevice.setFeatures(dmsDevice.getFeatures()); + } + convertedDevicesList.add(convertedDevice); + } + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementException("Error occurred while obtaining devices all devices", e); + } + return convertedDevicesList; } @Override @@ -161,7 +184,31 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ @Override public List getDeviceListOfUser(String username) throws DeviceManagementException { - return null; + List devicesOfUser = new ArrayList(); + try { + int tenantId = DeviceManagerUtil.getTenantId(); + List devicesList = this.deviceDAO.getDeviceListOfUser(username, tenantId); + for (int x = 0; x < devicesList.size(); x++) { + org.wso2.carbon.device.mgt.core.dto.Device device = devicesList.get(x); + device.setDeviceType(deviceTypeDAO.getDeviceType(device.getDeviceTypeId())); + DeviceManager dms = + this.getPluginRepository().getDeviceManagementProvider(device.getDeviceType().getName()); + Device convertedDevice = DeviceManagementDAOUtil.convertDevice(device, device.getDeviceType()); + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setId(device.getDeviceIdentificationId()); + deviceIdentifier.setType(device.getDeviceType().getName()); + Device dmsDevice = dms.getDevice(deviceIdentifier); + if (dmsDevice != null) { + convertedDevice.setProperties(dmsDevice.getProperties()); + convertedDevice.setFeatures(dmsDevice.getFeatures()); + } + devicesOfUser.add(convertedDevice); + } + } catch (DeviceManagementDAOException e) { + throw new DeviceManagementException("Error occurred while obtaining devices for user " + + "'" + username + "'", e); + } + return devicesOfUser; } @Override diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java index 51ed642899..fb27efe523 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/DeviceDAO.java @@ -58,6 +58,6 @@ public interface DeviceDAO { * @return List of devices of the user. * @throws DeviceManagementDAOException */ - List getDeviceListOfUser(String username) throws DeviceManagementDAOException; + List getDeviceListOfUser(String username , int tenantId) throws DeviceManagementDAOException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java index 4f665ed90f..9300e49c1b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java @@ -107,7 +107,7 @@ public class DeviceDAOImpl implements DeviceDAO { conn = this.getConnection(); String sql = "SELECT d.ID, d.DESCRIPTION, d.NAME, d.DATE_OF_ENROLLMENT, d.DATE_OF_LAST_UPDATE, d.OWNERSHIP, d.STATUS, " + - "d.DEVICE_TYPE_ID, d.DEVICE_IDENTIFICATION, d.OWNER, d.TENANT_ID FROM DM_DEVICE d, DEVICE_TYPE dt WHERE " + + "d.DEVICE_TYPE_ID, d.DEVICE_IDENTIFICATION, d.OWNER, d.TENANT_ID FROM DM_DEVICE d, DM_DEVICE_TYPE dt WHERE " + "dt.NAME = ? AND d.DEVICE_IDENTIFICATION = ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, deviceIdentifier.getType()); @@ -140,7 +140,42 @@ public class DeviceDAOImpl implements DeviceDAO { @Override public List getDevices() throws DeviceManagementDAOException { - return null; + Connection conn = null; + PreparedStatement stmt = null; + ResultSet resultSet = null; + List devicesList = null; + try { + conn = this.getConnection(); + String selectDBQueryForType = "SELECT ID, DESCRIPTION, NAME, DATE_OF_ENROLLMENT, " + + "DATE_OF_LAST_UPDATE, OWNERSHIP, STATUS, DEVICE_TYPE_ID, " + + "DEVICE_IDENTIFICATION, OWNER, TENANT_ID FROM DM_DEVICE "; + stmt = conn.prepareStatement(selectDBQueryForType); + resultSet = stmt.executeQuery(); + devicesList = new ArrayList(); + while (resultSet.next()) { + Device device = new Device(); + device.setId(resultSet.getInt(1)); + device.setDescription(resultSet.getString(2)); + device.setName(resultSet.getString(3)); + device.setDateOfEnrollment(resultSet.getLong(4)); + device.setDateOfLastUpdate(resultSet.getLong(5)); + //TODO:- Ownership is not a enum in DeviceDAO + device.setOwnerShip(resultSet.getString(6)); + device.setStatus(Status.valueOf(resultSet.getString(7))); + device.setDeviceTypeId(resultSet.getInt(8)); + device.setDeviceIdentificationId(resultSet.getString(9)); + device.setOwnerId(resultSet.getString(10)); + device.setTenantId(resultSet.getInt(11)); + devicesList.add(device); + } + } catch (SQLException e) { + String msg = "Error occurred while listing all devices for type "; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } finally { + DeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet); + } + return devicesList; } @Override @@ -178,9 +213,7 @@ public class DeviceDAOImpl implements DeviceDAO { List devicesList = null; try { conn = this.getConnection(); - String selectDBQueryForType = "SELECT ID, DESCRIPTION, NAME, DATE_OF_ENROLLMENT, " + - "DATE_OF_LAST_UPDATE, OWNERSHIP, STATUS, DEVICE_TYPE_ID, " + - "DEVICE_IDENTIFICATION, OWNER, TENANT_ID FROM DM_DEVICE " + + String selectDBQueryForType = "SELECT ID, DESCRIPTION, NAME, DATE_OF_ENROLLMENT, DATE_OF_LAST_UPDATE, OWNERSHIP, STATUS, DEVICE_TYPE_ID, DEVICE_IDENTIFICATION, OWNER, TENANT_ID FROM DM_DEVICE " + "WHERE DM_DEVICE.DEVICE_TYPE_ID = ?"; stmt = conn.prepareStatement(selectDBQueryForType); stmt.setInt(1, type); @@ -212,9 +245,50 @@ public class DeviceDAOImpl implements DeviceDAO { return devicesList; } - @Override - public List getDeviceListOfUser(String username) throws DeviceManagementDAOException { - return null; + @Override public List getDeviceListOfUser(String username, int tenantId) throws DeviceManagementDAOException { + Connection conn = this.getConnection(); + PreparedStatement stmt = null; + List deviceList = new ArrayList(); + try { + stmt = conn.prepareStatement( + "SELECT DM_DEVICE_TYPE.ID, DM_DEVICE_TYPE.NAME, DM_DEVICE.ID, DM_DEVICE.DESCRIPTION, " + + "DM_DEVICE.NAME, DM_DEVICE.DATE_OF_ENROLLMENT, DM_DEVICE.DATE_OF_LAST_UPDATE, " + + "DM_DEVICE.OWNERSHIP, DM_DEVICE.STATUS, DM_DEVICE.DEVICE_TYPE_ID, " + + "DM_DEVICE.DEVICE_IDENTIFICATION, DM_DEVICE.OWNER, DM_DEVICE.TENANT_ID FROM " + + "DM_DEVICE, DM_DEVICE_TYPE WHERE DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID " + + "AND DM_DEVICE.OWNER =? AND DM_DEVICE.TENANT_ID =?"); + stmt.setString(1, username); + stmt.setInt(2, tenantId); + ResultSet resultSet = stmt.executeQuery(); + + while (resultSet.next()) { + Device device = new Device(); + DeviceType deviceType = new DeviceType(); + int id = resultSet.getInt(resultSet.getInt(1)); + deviceType.setId(id); + deviceType.setName(resultSet.getString(2)); + device.setId(resultSet.getInt(3)); + device.setDescription(resultSet.getString(4)); + device.setName(resultSet.getString(5)); + device.setDateOfEnrollment(resultSet.getLong(6)); + device.setDateOfLastUpdate(resultSet.getLong(7)); + //TODO:- Ownership is not a enum in DeviceDAO + device.setOwnerShip(resultSet.getString(8)); + device.setStatus(Status.valueOf(resultSet.getString(9))); + device.setDeviceTypeId(resultSet.getInt(10)); + device.setDeviceIdentificationId(resultSet.getString(11)); + device.setOwnerId(resultSet.getString(12)); + device.setTenantId(resultSet.getInt(13)); + deviceList.add(device); + } + } catch (SQLException e) { + String msg = "Error occurred while fetching the list of devices belongs to " + username; + log.error(msg, e); + throw new DeviceManagementDAOException(msg, e); + } finally { + DeviceManagementDAOUtil.cleanupResources(conn, stmt, null); + } + return deviceList; } private Connection getConnection() throws DeviceManagementDAOException { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java index 4d79e58694..93f640c8ee 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -22,21 +22,22 @@ import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; import org.wso2.carbon.device.mgt.common.DeviceManagementException; +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.spi.DeviceManager; import org.wso2.carbon.device.mgt.core.DeviceManagementConstants; import org.wso2.carbon.device.mgt.core.DeviceManagementRepository; import org.wso2.carbon.device.mgt.core.DeviceManagementServiceProviderImpl; -import org.wso2.carbon.device.mgt.core.service.DeviceManagementService; import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig; import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; -import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig; import org.wso2.carbon.device.mgt.core.config.license.LicenseConfigurationManager; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; -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.core.license.mgt.LicenseManagerImpl; +import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementServiceImpl; import org.wso2.carbon.device.mgt.core.util.DeviceManagementSchemaInitializer; import org.wso2.carbon.registry.core.service.RegistryService; @@ -94,6 +95,8 @@ public class DeviceManagementServiceComponent { DeviceManagementDataHolder.getInstance().setLicenseManager(licenseManager); DeviceManagementDataHolder.getInstance().setLicenseConfig(licenseConfig); + OperationManagementDAOFactory.init(dsConfig); + /* If -Dsetup option enabled then create device management database schema */ String setupOption = System.getProperty(DeviceManagementConstants.Common.PROPERTY_SETUP); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java index 8600b00e96..bae92c0ab9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java @@ -59,6 +59,9 @@ public class OperationManagementDAOFactory { public static void init(DataSource dtSource) { dataSource = dtSource; } + public static void init(DataSourceConfig config) { + dataSource = resolveDataSource(config); + } public static void beginTransaction() throws OperationManagementDAOException { try { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementService.java index b024829c55..0a44808da4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementService.java @@ -33,6 +33,8 @@ public interface DeviceManagementService extends DeviceManager, LicenseManager, List getAllDevices(String type) throws DeviceManagementException; + List getAllDevices() throws DeviceManagementException; + List getDeviceListOfUser(String username) throws DeviceManagementException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java index 6cbe38b6eb..b280c25dd5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java @@ -70,7 +70,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @Override public List getAllDevices() throws DeviceManagementException { - return null; + return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getAllDevices(); } @Override @@ -80,11 +80,10 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @Override public List getDeviceListOfUser(String username) throws DeviceManagementException{ - return null; + return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDeviceListOfUser(username); } - @Override - public org.wso2.carbon.device.mgt.common.Device getDevice(DeviceIdentifier deviceId) + @Override public org.wso2.carbon.device.mgt.common.Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException { return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceId); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java index eb4b1daa40..b476418352 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java @@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.core.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.dom.Document; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; @@ -139,4 +140,8 @@ public final class DeviceManagerUtil { } return propertiesMap; } + public static int getTenantId(){ + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + return ctx.getTenantId(); + } } From 34ad4a63a238e8c7a845c2f232292fbe03f6609b Mon Sep 17 00:00:00 2001 From: manoj Date: Fri, 20 Mar 2015 12:27:45 +0530 Subject: [PATCH 7/9] Email management --- .../org.wso2.carbon.device.mgt.core/pom.xml | 18 +++++ .../core/service/DeviceManagementService.java | 1 + .../service/DeviceManagementServiceImpl.java | 78 +++++++++---------- .../pom.xml | 35 ++++----- .../DeviceMgtUserServiceComponent.java | 2 +- .../pom.xml | 7 ++ 6 files changed, 82 insertions(+), 59 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index 7dde13ebe5..393d5aa2ed 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -54,6 +54,7 @@ org.wso2.carbon.device.mgt.core.internal org.apache.axis2.*;version="${axis2.osgi.version.range}", + org.apache.axiom.*; version="${axiom.osgi.version.range}", org.osgi.framework, org.osgi.service.component, org.apache.commons.logging, @@ -159,6 +160,23 @@ org.wso2.carbon.governance org.wso2.carbon.governance.api + + org.apache.axis2.transport + axis2-transport-mail + + + + org.apache.ws.commons.axiom + axiom-api + + + org.apache.ws.commons.axiom + axiom-impl + + + org.apache.ws.commons.axiom.wso2 + axiom + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementService.java index b024829c55..26ea5ef8fb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementService.java @@ -19,6 +19,7 @@ package org.wso2.carbon.device.mgt.core.service; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.EmailMessageProperties; import org.wso2.carbon.device.mgt.common.spi.DeviceManager; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java index c7b6937031..c1574b95fb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementServiceImpl.java @@ -39,34 +39,34 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } @Override - public boolean enrollDevice(Device device) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().enrollDevice(device); - } + public boolean enrollDevice(Device device) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().enrollDevice(device); + } - @Override - public boolean modifyEnrollment(Device device) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().modifyEnrollment(device); - } + @Override + public boolean modifyEnrollment(Device device) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().modifyEnrollment(device); + } - @Override - public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().disenrollDevice(deviceId); - } + @Override + public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().disenrollDevice(deviceId); + } - @Override - public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().isEnrolled(deviceId); - } + @Override + public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().isEnrolled(deviceId); + } - @Override - public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().isActive(deviceId); - } + @Override + public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().isActive(deviceId); + } - @Override - public boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().setActive(deviceId, status); - } + @Override + public boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().setActive(deviceId, status); + } @Override public List getAllDevices() throws DeviceManagementException { @@ -74,31 +74,31 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } @Override - public List getAllDevices(String type) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getAllDevices(type); - } + public List getAllDevices(String type) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getAllDevices(type); + } @Override - public List getDeviceListOfUser(String username) throws DeviceManagementException{ + public List getDeviceListOfUser(String username) throws DeviceManagementException { return null; } @Override - public org.wso2.carbon.device.mgt.common.Device getDevice(DeviceIdentifier deviceId) - throws DeviceManagementException { + public org.wso2.carbon.device.mgt.common.Device getDevice(DeviceIdentifier deviceId) + throws DeviceManagementException { return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevice(deviceId); - } + } - @Override - public boolean updateDeviceInfo(Device device) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().updateDeviceInfo(device); - } + @Override + public boolean updateDeviceInfo(Device device) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().updateDeviceInfo(device); + } - @Override - public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException { - return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().setOwnership(deviceId, + @Override + public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException { + return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().setOwnership(deviceId, ownershipType); - } + } @Override public License getLicense(String deviceType, String languageCode) throws LicenseManagementException { @@ -113,7 +113,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @Override public boolean addOperation(Operation operation, - List devices) throws OperationManagementException { + List devices) throws OperationManagementException { return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().addOperation(operation, devices); } diff --git a/components/user-mgt/org.wso2.carbon.device.mgt.user.common/pom.xml b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/pom.xml index 25ee050fe3..1bd80d2e0c 100644 --- a/components/user-mgt/org.wso2.carbon.device.mgt.user.common/pom.xml +++ b/components/user-mgt/org.wso2.carbon.device.mgt.user.common/pom.xml @@ -1,24 +1,21 @@ +~ 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. +--> org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.common + + org.wso2.carbon.commons + org.wso2.carbon.email.verification + @@ -98,6 +102,9 @@ org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.common:${carbon.device.mgt.version} + + org.wso2.carbon.commons:org.wso2.carbon.email.verification + org.wso2.carbon.core.server:${carbon.kernel.version} From ec6734a1d989b1db957dca944727dca8fd4bf458 Mon Sep 17 00:00:00 2001 From: manoj Date: Fri, 20 Mar 2015 12:28:18 +0530 Subject: [PATCH 8/9] Email management --- pom.xml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/pom.xml b/pom.xml index 71ebab3f97..149573171c 100644 --- a/pom.xml +++ b/pom.xml @@ -386,8 +386,36 @@ ${tomcat.jdbc.pooling.version} + + org.apache.axis2.transport + axis2-transport-mail + ${axis2-transports.version} + + + + org.apache.ws.commons.axiom + axiom-api + ${axiom.version} + + + org.apache.ws.commons.axiom + axiom-impl + ${axiom.version} + + + org.apache.ws.commons.axiom.wso2 + axiom + ${axiom.wso2.version} + + + + org.wso2.carbon.commons + org.wso2.carbon.email.verification + ${carbon.commons.version} + + @@ -622,9 +650,15 @@ 4.3.0 + + 1.1.0-wso2v10 + 1.2.11-wso2v5 + [1.2.11.wso2v5, 1.3.0) + 1.2.11.wso2v5 0.9.2-SNAPSHOT + 4.3.6 From b2d8f3f7f5728175042b18867f022cfcf6eef4fd Mon Sep 17 00:00:00 2001 From: manoj Date: Fri, 20 Mar 2015 12:28:50 +0530 Subject: [PATCH 9/9] Email Management --- .../mgt/common/EmailMessageProperties.java | 68 ++++++++++ .../mgt/core/EmailServiceProviderImpl.java | 124 ++++++++++++++++++ .../core/internal/EmailServiceComponent.java | 83 ++++++++++++ .../core/internal/EmailServiceDataHolder.java | 58 ++++++++ .../device/mgt/core/service/EmailService.java | 26 ++++ .../mgt/core/service/EmailServiceImpl.java | 31 +++++ 6 files changed, 390 insertions(+) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/EmailMessageProperties.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/EmailServiceProviderImpl.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/EmailServiceComponent.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/EmailServiceDataHolder.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/EmailService.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/EmailServiceImpl.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/EmailMessageProperties.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/EmailMessageProperties.java new file mode 100644 index 0000000000..d4c9380333 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/EmailMessageProperties.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2014, 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.common; + + +public class EmailMessageProperties { + + private String messageBody; + private String[] mailTo; + private String[] ccList; + private String[] bccList; + private String subject; + + public String getMessageBody() { + return messageBody; + } + + public void setMessageBody(String messageBody) { + this.messageBody = messageBody; + } + + public String[] getMailTo() { + return mailTo; + } + + public void setMailTo(String[] mailTo) { + this.mailTo = mailTo; + } + + public String[] getCcList() { + return ccList; + } + + public void setCcList(String[] ccList) { + this.ccList = ccList; + } + + public String[] getBccList() { + return bccList; + } + + public void setBccList(String[] bccList) { + this.bccList = bccList; + } + + public String getSubject() { + return subject; + } + + public void setSubject(String subject) { + this.subject = subject; + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/EmailServiceProviderImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/EmailServiceProviderImpl.java new file mode 100644 index 0000000000..a52706753c --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/EmailServiceProviderImpl.java @@ -0,0 +1,124 @@ +/* + * 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; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axis2.AxisFault; +import org.apache.axis2.Constants; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.client.Options; +import org.apache.axis2.client.ServiceClient; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.transport.base.BaseConstants; +import org.apache.axis2.transport.mail.MailConstants; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.EmailMessageProperties; +import org.wso2.carbon.device.mgt.core.internal.EmailServiceDataHolder; +import org.wso2.carbon.device.mgt.core.service.EmailService; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +public class EmailServiceProviderImpl implements EmailService { + + private static ThreadPoolExecutor threadPoolExecutor; + private static final int MIN_THREAD = 8; + private static final int MAX_THREAD = 100; + private static final long DEFAULT_KEEP_ALIVE_TIME = 20; + private static final String EMAIL_URI_SCHEME = "mailto:"; + + private static Log log = LogFactory.getLog(EmailServiceProviderImpl.class); + + public EmailServiceProviderImpl() { + init(); + } + + private void init() { + if (threadPoolExecutor == null) { + threadPoolExecutor = new ThreadPoolExecutor(MIN_THREAD, MAX_THREAD, DEFAULT_KEEP_ALIVE_TIME, + TimeUnit.SECONDS, new LinkedBlockingQueue(1000)); + } + } + + @Override + public void sendEmail(EmailMessageProperties emailMessageProperties) throws DeviceManagementException { + for(String toAddr:emailMessageProperties.getMailTo()) { + threadPoolExecutor + .submit(new EmailSender(toAddr, emailMessageProperties.getSubject(), + emailMessageProperties.getMessageBody())); + } + } + + class EmailSender implements Runnable { + + String to; + String subject; + String body; + + EmailSender(String to, String subject, String body) { + this.to = to; + this.subject = subject; + this.body = body; + } + + public void run() { + Map headerMap = new HashMap(); + headerMap.put(MailConstants.MAIL_HEADER_SUBJECT, subject); + OMElement payload = OMAbstractFactory.getOMFactory().createOMElement( + BaseConstants.DEFAULT_TEXT_WRAPPER, null); + payload.setText(body); + try { + ServiceClient serviceClient; + ConfigurationContext configContext = EmailServiceDataHolder.getInstance() + .getConfigurationContextService().getClientConfigContext(); + //Set configuration service client if available, else create new service client + if (configContext != null) { + serviceClient = new ServiceClient(configContext, null); + } else { + serviceClient = new ServiceClient(); + } + Options options = new Options(); + options.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE); + options.setProperty(MessageContext.TRANSPORT_HEADERS, headerMap); + options.setProperty(MailConstants.TRANSPORT_MAIL_FORMAT, + MailConstants.TRANSPORT_FORMAT_TEXT); + options.setTo(new EndpointReference(EMAIL_URI_SCHEME + to)); + serviceClient.setOptions(options); + serviceClient.fireAndForget(payload); + log.debug("Sending confirmation mail to " + to); + } catch (AxisFault e) { + String msg = "Error in delivering the message, " + + "subject: " + subject + ", to: " + to + "."; + log.error(msg); + } catch (Throwable t) { + String msg = "Error in delivering the message, " + + "subject: " + subject + ", to: " + to + "."; + log.error(msg); + log.error(t); + } + } + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/EmailServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/EmailServiceComponent.java new file mode 100644 index 0000000000..3e100d50e9 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/EmailServiceComponent.java @@ -0,0 +1,83 @@ +/* + * 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.internal; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.framework.BundleContext; +import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.device.mgt.core.DeviceManagementRepository; +import org.wso2.carbon.device.mgt.core.EmailServiceProviderImpl; +import org.wso2.carbon.device.mgt.core.service.EmailService; +import org.wso2.carbon.device.mgt.core.service.EmailServiceImpl; +import org.wso2.carbon.utils.ConfigurationContextService; + +/** + * @scr.component component.name="org.wso2.carbon.device.emailmanager" immediate="true" + * @scr.reference name="configurationcontext.service" + * interface="org.wso2.carbon.utils.ConfigurationContextService" cardinality="1..1" + * policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService" + */ +public class EmailServiceComponent { + + private static Log log = LogFactory.getLog(EmailServiceComponent.class); + + /** + * initialize the email service here service here. + * + * @param context + */ + protected void activate(ComponentContext context) { + try { + if (log.isDebugEnabled()) { + log.debug("Initializing email service bundle"); + } + + /* Initializing Email Service Configurations */ + + EmailService emailServiceProvider = new EmailServiceProviderImpl(); + EmailServiceDataHolder.getInstance().setEmailServiceProvider(emailServiceProvider); ; + + this.registerServices(context); + + if (log.isDebugEnabled()) { + log.debug("Email management core bundle has been successfully initialized"); + } + } catch (Throwable e) { + String msg = "Error occurred while initializing device management core bundle"; + log.error(msg, e); + } + } + protected void setConfigurationContextService(ConfigurationContextService configurationContextService) { + EmailServiceDataHolder.getInstance().setConfigurationContextService(configurationContextService); + } + protected void unsetConfigurationContextService(ConfigurationContextService configurationContextService) { + EmailServiceDataHolder.getInstance().setConfigurationContextService(null); + } + + private void registerServices(ComponentContext componentContext) { + if (log.isDebugEnabled()) { + log.debug("Registering OSGi service Email Service Impl"); + } + /* Registering Email Service */ + BundleContext bundleContext = componentContext.getBundleContext(); + bundleContext.registerService(EmailService.class.getName(), + new EmailServiceImpl(), null); + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/EmailServiceDataHolder.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/EmailServiceDataHolder.java new file mode 100644 index 0000000000..0093ff6bdb --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/EmailServiceDataHolder.java @@ -0,0 +1,58 @@ +/* + * 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.internal; + +import org.wso2.carbon.device.mgt.core.service.EmailService; +import org.wso2.carbon.utils.ConfigurationContextService; + +public class EmailServiceDataHolder { + + private static EmailServiceDataHolder thisInstance = new EmailServiceDataHolder(); + private ConfigurationContextService configurationContextService; + private EmailService emailServiceProvider; + + public static EmailServiceDataHolder getThisInstance() { + return thisInstance; + } + + public static void setThisInstance(EmailServiceDataHolder thisInstance) { + EmailServiceDataHolder.thisInstance = thisInstance; + } + + private EmailServiceDataHolder() { + } + + public static EmailServiceDataHolder getInstance() { + return thisInstance; + } + + public ConfigurationContextService getConfigurationContextService() { + return configurationContextService; + } + + public void setConfigurationContextService(ConfigurationContextService configurationContextService) { + this.configurationContextService = configurationContextService; + } + public EmailService getEmailServiceProvider() { + return emailServiceProvider; + } + + public void setEmailServiceProvider(EmailService emailServiceProvider) { + this.emailServiceProvider = emailServiceProvider; + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/EmailService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/EmailService.java new file mode 100644 index 0000000000..d53ddca970 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/EmailService.java @@ -0,0 +1,26 @@ +/* + * 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.service; + +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.EmailMessageProperties; + +public interface EmailService { + + public void sendEmail(EmailMessageProperties emailMessageProperties) throws DeviceManagementException; +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/EmailServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/EmailServiceImpl.java new file mode 100644 index 0000000000..807c511659 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/EmailServiceImpl.java @@ -0,0 +1,31 @@ +/* + * 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.service; + +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.EmailMessageProperties; +import org.wso2.carbon.device.mgt.core.internal.EmailServiceDataHolder; + +public class EmailServiceImpl implements EmailService{ + + @Override + public void sendEmail(EmailMessageProperties emailMessageProperties) throws DeviceManagementException { + EmailServiceDataHolder.getInstance().getEmailServiceProvider().sendEmail(emailMessageProperties); + } +}