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 9e12d09cfe..96ef8378e1 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 @@ -75,6 +75,13 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ return null; } + @Override + public FeatureManager getFeatureManager(String type) { + DeviceManager dms = + this.getPluginRepository().getDeviceManagementProvider(type); + return dms.getFeatureManager(); + } + @Override public boolean enrollDevice(Device device) throws DeviceManagementException { DeviceManager dms = @@ -346,4 +353,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/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 1adea0a12a..c2306c5f14 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 @@ -20,6 +20,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.FeatureManager; 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; @@ -40,4 +41,6 @@ public interface DeviceManagementService extends DeviceManager, LicenseManager, void sendEnrollInvitation(String title, String userName, String emailAddress, String enrolUrl) throws DeviceManagementException; + FeatureManager getFeatureManager(String type) 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 b2c5013641..f40240f6c1 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 @@ -85,11 +85,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDeviceListOfUser(username); } - @Override - public void sendEnrollInvitation(String title, String userName, String emailAddress, String enrolUrl) - throws DeviceManagementException { - DeviceManagementDataHolder.getInstance().getDeviceManagementProvider() - .sendEnrollInvitation(title, userName, emailAddress, enrolUrl); + public FeatureManager getFeatureManager(String type) throws DeviceManagementException { + return null; } @Override @@ -136,4 +133,15 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { return DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getPendingOperations(deviceId); } + @Override + public Operation getPendingOperation(DeviceIdentifier deviceId) throws OperationManagementException { + return null; + } + + @Override + public void sendEnrollInvitation(String title, String userName, String emailAddress, String enrolUrl) + throws DeviceManagementException { + DeviceManagementDataHolder.getInstance().getDeviceManagementProvider() + .sendEnrollInvitation(title, userName, emailAddress, enrolUrl); + } } 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); + } + }