From 0e598aad599b7bc329ac3225827b4e0f90549b6c Mon Sep 17 00:00:00 2001 From: prabathabey Date: Fri, 20 Mar 2015 13:49:37 +0530 Subject: [PATCH 1/3] Improving operation management implementation --- .../java/org/wso2/carbon/device/mgt/common/Feature.java | 9 +++++++++ .../mgt/common/operation/mgt/OperationManager.java | 2 ++ .../mgt/core/DeviceManagementServiceProviderImpl.java | 5 +++++ .../mgt/core/operation/mgt/OperationManagerImpl.java | 5 +++++ .../mgt/core/service/DeviceManagementServiceImpl.java | 5 +++++ 5 files changed, 26 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Feature.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Feature.java index 935539620a..050dff0bcb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Feature.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Feature.java @@ -22,6 +22,7 @@ import java.util.List; public class Feature { private int id; + private String code; private String name; private String description; private String deviceType; @@ -35,6 +36,14 @@ public class Feature { this.id = id; } + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + public String getName() { return name; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/OperationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/OperationManager.java index a804eaa514..51a7e0ee1e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/OperationManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/OperationManager.java @@ -56,4 +56,6 @@ public interface OperationManager { */ public List getPendingOperations(DeviceIdentifier deviceId) throws OperationManagementException; + public Operation getPendingOperation(DeviceIdentifier deviceId) throws OperationManagementException; + } \ No newline at end of file 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..4623d37a12 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 @@ -247,4 +247,9 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ return operationManager.getPendingOperations(deviceId); } + @Override + public Operation getPendingOperation(DeviceIdentifier deviceId) throws OperationManagementException { + return null; + } + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java index 398cd8f131..63f7b16200 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -85,6 +85,11 @@ public class OperationManagerImpl implements OperationManager { return null; } + @Override + public Operation getPendingOperation(DeviceIdentifier deviceId) throws OperationManagementException { + return null; + } + private OperationDAO lookupOperationDAO(Operation operation) { if (operation instanceof CommandOperation) { return commandOperationDAO; 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..40a1181548 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 @@ -127,4 +127,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getPendingOperations(deviceId); } + @Override + public Operation getPendingOperation(DeviceIdentifier deviceId) throws OperationManagementException { + return null; + } + } From 80908bac1eda1c3524f31a8b2733f08374eaf31e Mon Sep 17 00:00:00 2001 From: prabathabey Date: Fri, 20 Mar 2015 17:50:56 +0530 Subject: [PATCH 2/3] Adding feature manager related changes --- .../mgt/core/DeviceManagementServiceProviderImpl.java | 6 ++++-- .../device/mgt/core/service/DeviceManagementService.java | 2 ++ 2 files changed, 6 insertions(+), 2 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 3de82f76cc..eba43d395f 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 @@ -62,8 +62,10 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ } @Override - public FeatureManager getFeatureManager() { - return null; + public FeatureManager getFeatureManager(String type) { + DeviceManager dms = + this.getPluginRepository().getDeviceManagementProvider(type); + return dms.getFeatureManager(); } @Override 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 1f156f4f62..5cc4f1b2e5 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 @@ -38,4 +38,6 @@ public interface DeviceManagementService extends DeviceManager, LicenseManager, List getDeviceListOfUser(String username) throws DeviceManagementException; + + } From 8277a9a8187de07731ba16fe9c667b02331da3b7 Mon Sep 17 00:00:00 2001 From: Dulitha Wijewantha Date: Fri, 20 Mar 2015 18:04:04 +0530 Subject: [PATCH 3/3] * Added a method to get a single user --- .../device/mgt/user/core/UserManager.java | 1 + .../device/mgt/user/core/UserManagerImpl.java | 20 ++++++++++++++++--- .../core/service/UserManagementService.java | 5 +++++ 3 files changed, 23 insertions(+), 3 deletions(-) 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 index f73be18c56..8fa3e3b4c3 100644 --- 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 @@ -28,4 +28,5 @@ 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; + public User getUser(String username, 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 index 14740a1229..e5ec26aeae 100644 --- 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 @@ -20,12 +20,10 @@ 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 org.wso2.carbon.user.core.UserCoreConstants; @@ -148,8 +146,24 @@ public class UserManagerImpl implements UserManager { return usersList; } - private void setUserClaims(User newUser, Map claimMap) { + @Override public User getUser(String username, int tenantId) throws UserManagementException { + UserStoreManager userStoreManager; + User user; + try { + userStoreManager = DeviceMgtUserDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId) + .getUserStoreManager(); + user = new User(username); + setUserClaims(user, userStoreManager + .getUserClaimValues(username, DEFAULT_CLAIM_ARR, UserCoreConstants.DEFAULT_PROFILE)); + } catch (UserStoreException userStoreEx) { + String errorMsg = "User store error in fetching user " + username; + log.error(errorMsg, userStoreEx); + throw new UserManagementException(errorMsg, userStoreEx); + } + return user; + } + private void setUserClaims(User newUser, Map claimMap) { newUser.setRoleName(UserCoreConstants.ClaimTypeURIs.ROLE); newUser.setAccountStatus(claimMap.get(ACCOUNT_STATUS)); newUser.setChallengeQuestion(claimMap.get(CHALLENGE_QUESTION_URI)); 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 index 5e051f2640..6d2740d5db 100644 --- 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 @@ -43,4 +43,9 @@ public class UserManagementService implements UserManager{ public List getUsersForTenant(int tenantId) throws UserManagementException { return DeviceMgtUserDataHolder.getInstance().getUserManager().getUsersForTenant(tenantId); } + + @Override public User getUser(String username, int tenantId) throws UserManagementException { + return DeviceMgtUserDataHolder.getInstance().getUserManager().getUser(username, tenantId); + } + }