You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2014/10/10 09:08:11 UTC
git commit: Changes to error logging and HTTP status codes for user
management
Repository: stratos
Updated Branches:
refs/heads/tenant-isolation-feature 90df36726 -> 2fa11c819 (forced update)
Changes to error logging and HTTP status codes for user management
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/2fa11c81
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/2fa11c81
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/2fa11c81
Branch: refs/heads/tenant-isolation-feature
Commit: 2fa11c819b88d506ec34ea88a7ed3b291d9a1f47
Parents: 8ab15cb
Author: lasinducharith <la...@gmail.com>
Authored: Fri Oct 10 12:16:13 2014 +0530
Committer: lasinducharith <la...@gmail.com>
Committed: Fri Oct 10 12:36:57 2014 +0530
----------------------------------------------------------------------
.../manager/listener/TenantUserRoleCreator.java | 9 +-
.../manager/user/mgt/StratosUserManager.java | 124 +++++++++----------
.../mgt/exception/UserManagementException.java | 28 -----
.../mgt/exception/UserManagerException.java | 39 ++++++
.../stratos/manager/utils/UserRoleCreator.java | 38 +++---
.../rest/endpoint/services/StratosAdmin.java | 39 +++---
6 files changed, 141 insertions(+), 136 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/2fa11c81/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/listener/TenantUserRoleCreator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/listener/TenantUserRoleCreator.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/listener/TenantUserRoleCreator.java
index a3b0532..7bf2f8e 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/listener/TenantUserRoleCreator.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/listener/TenantUserRoleCreator.java
@@ -25,7 +25,7 @@ import org.apache.stratos.common.beans.TenantInfoBean;
import org.apache.stratos.common.exception.StratosException;
import org.apache.stratos.common.listeners.TenantMgtListener;
import org.apache.stratos.manager.internal.DataHolder;
-import org.apache.stratos.manager.user.mgt.exception.UserManagementException;
+import org.apache.stratos.manager.user.mgt.exception.UserManagerException;
import org.apache.stratos.manager.utils.UserRoleCreator;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.user.api.UserStoreException;
@@ -57,14 +57,15 @@ public class TenantUserRoleCreator implements TenantMgtListener {
UserRealm userRealm = DataHolder.getRealmService().getTenantUserRealm(tenantInfo.getTenantId());
UserStoreManager userStoreManager = userRealm.getUserStoreManager();
//Call Util class to create the user role
+
UserRoleCreator.createTenantUserRole(userStoreManager);
} catch (UserStoreException e) {
- String msg = "Error while retrieving the user store for tenant : "+ tenantInfo.getTenantDomain();
+ String msg = "Error while retrieving the user store for tenant: "+ tenantInfo.getTenantDomain();
log.error(msg, e);
throw new StratosException(e.getMessage(), e);
- } catch (UserManagementException e) {
- String msg = "Error while creating the user role in tenant : "+ tenantInfo.getTenantDomain();
+ } catch (UserManagerException e) {
+ String msg = "Error while creating the user role in tenant: "+ tenantInfo.getTenantDomain();
log.error(msg, e);
throw new StratosException(e.getMessage(), e);
} finally {
http://git-wip-us.apache.org/repos/asf/stratos/blob/2fa11c81/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/mgt/StratosUserManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/mgt/StratosUserManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/mgt/StratosUserManager.java
index 9a01453..57588ab 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/mgt/StratosUserManager.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/mgt/StratosUserManager.java
@@ -23,7 +23,7 @@ package org.apache.stratos.manager.user.mgt;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.manager.user.mgt.beans.UserInfoBean;
-import org.apache.stratos.manager.user.mgt.exception.UserManagementException;
+import org.apache.stratos.manager.user.mgt.exception.UserManagerException;
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.user.api.UserStoreManager;
import org.wso2.carbon.user.core.UserCoreConstants;
@@ -46,55 +46,57 @@ public class StratosUserManager {
/**
* Add a user to the user-store of the particular tenant
*
- * @param userStoreManager UserStoreManager
- * @param userInfoBean UserInfoBean
- * @throws UserManagementException
+ * @param userStoreManager UserStoreManager
+ * @param userInfoBean UserInfoBean
+ * @throws UserManagerException
*/
public void addUser(UserStoreManager userStoreManager, UserInfoBean userInfoBean)
- throws UserManagementException {
-
- try {
-
- if (!userStoreManager.isExistingUser(userInfoBean.getUserName())) {
- if (log.isDebugEnabled()) {
- log.debug("Creating new User: " + userInfoBean.getUserName());
- }
+ throws UserManagerException {
- String[] roles = new String[1];
- roles[0] = userInfoBean.getRole();
- Map<String, String> claims = new HashMap<String, String>();
+ if (log.isDebugEnabled()) {
+ log.debug("Creating new User: " + userInfoBean.getUserName());
+ }
- //set firstname, lastname and email as user claims
- claims.put(UserCoreConstants.ClaimTypeURIs.EMAIL_ADDRESS, userInfoBean.getEmail());
- claims.put(UserCoreConstants.ClaimTypeURIs.GIVEN_NAME, userInfoBean.getFirstName());
- claims.put(UserCoreConstants.ClaimTypeURIs.SURNAME, userInfoBean.getLastName());
- userStoreManager.addUser(userInfoBean.getUserName(), userInfoBean.getCredential(), roles, claims, userInfoBean.getProfileName());
+ String[] roles = new String[1];
+ roles[0] = userInfoBean.getRole();
+ Map<String, String> claims = new HashMap<String, String>();
- }
+ //set firstname, lastname and email as user claims
+ claims.put(UserCoreConstants.ClaimTypeURIs.EMAIL_ADDRESS, userInfoBean.getEmail());
+ claims.put(UserCoreConstants.ClaimTypeURIs.GIVEN_NAME, userInfoBean.getFirstName());
+ claims.put(UserCoreConstants.ClaimTypeURIs.SURNAME, userInfoBean.getLastName());
+ try {
+ userStoreManager.addUser(userInfoBean.getUserName(), userInfoBean.getCredential(), roles, claims, userInfoBean.getProfileName());
} catch (UserStoreException e) {
- String msg = "Error in adding the user: "+ userInfoBean.getUserName();
+ String msg = "Error in adding user " + userInfoBean.getUserName() + " to User Store";
log.error(msg, e);
- throw new UserManagementException(msg, e);
+ throw new UserManagerException(msg, e);
}
+
}
/**
* Delete the user with the given username in the relevant tenant space
*
- * @param userStoreManager UserStoreManager
- * @param userName UserName
- * @throws UserManagementException
+ * @param userStoreManager UserStoreManager
+ * @param userName UserName
+ * @throws UserManagerException
*/
public void deleteUser(UserStoreManager userStoreManager, String userName)
- throws UserManagementException {
+ throws UserManagerException {
try {
- userStoreManager.deleteUser(userName);
+ if (userStoreManager.isExistingUser(userName)) {
+ userStoreManager.deleteUser(userName);
+ } else {
+ String msg = "Requested user " + userName + " does not exist";
+ throw new UserManagerException(msg);
+ }
} catch (UserStoreException e) {
- String msg = "Error in deleting the user: "+ userName;
+ String msg = "Error in deleting the user " + userName + " from User Store";
log.error(msg, e);
- throw new UserManagementException(msg, e);
+ throw new UserManagerException(msg, e);
}
}
@@ -102,17 +104,17 @@ public class StratosUserManager {
/**
* Updates the user info given the new UserInfoBean
*
- * @param userStoreManager UserStoreManager
- * @param userInfoBean UserInfoBean
- * @throws UserManagementException
+ * @param userStoreManager UserStoreManager
+ * @param userInfoBean UserInfoBean
+ * @throws UserManagerException
*/
public void updateUser(UserStoreManager userStoreManager, UserInfoBean userInfoBean)
- throws UserManagementException {
+ throws UserManagerException {
try {
if (userStoreManager.isExistingUser(userInfoBean.getUserName())) {
if (log.isDebugEnabled()) {
- log.debug("Updating User: " + userInfoBean.getUserName());
+ log.debug("Updating User " + userInfoBean.getUserName());
}
String[] newRoles = new String[1];
@@ -123,14 +125,15 @@ public class StratosUserManager {
userStoreManager.setUserClaimValue(userInfoBean.getUserName(), UserCoreConstants.ClaimTypeURIs.GIVEN_NAME, userInfoBean.getFirstName(), userInfoBean.getProfileName());
userStoreManager.setUserClaimValue(userInfoBean.getUserName(), UserCoreConstants.ClaimTypeURIs.SURNAME, userInfoBean.getLastName(), userInfoBean.getProfileName());
userStoreManager.updateCredentialByAdmin(userInfoBean.getUserName(), userInfoBean.getCredential());
-
+ } else {
+ String msg = "Requested user " + userInfoBean.getUserName() + " does not exist";
+ throw new UserManagerException(msg);
}
} catch (UserStoreException e) {
- String msg = "Error in updating the user: "+ userInfoBean.getUserName();
+ String msg = "Error in updating the user " + userInfoBean.getUserName() + " in User Store";
log.error(msg, e);
- throw new UserManagementException(msg, e);
+ throw new UserManagerException(msg, e);
}
-
}
/**
@@ -138,49 +141,47 @@ public class StratosUserManager {
*
* @param userStoreManager UserStoreManager
* @return List<UserInfoBean>
- * @throws UserManagementException
+ * @throws UserManagerException
*/
public List<UserInfoBean> getAllUsers(UserStoreManager userStoreManager)
- throws UserManagementException {
+ throws UserManagerException {
String[] users;
List<UserInfoBean> userList = new ArrayList<UserInfoBean>();
try {
users = userStoreManager.listUsers(GET_ALL_USERS_WILD_CARD, -1);
-
- //Iterate through the list of users and retrieve their roles
- for (String user : users) {
- UserInfoBean userInfoBean = new UserInfoBean();
- userInfoBean.setUserName(user);
- userInfoBean.setRole(getRefinedListOfRolesOfUser(userStoreManager, user)[0]);
- userList.add(userInfoBean);
- }
-
} catch (UserStoreException e) {
- String msg = "Error in listing users";
+ String msg = "Error in listing the users in User Store";
log.error(msg, e);
- throw new UserManagementException(msg, e);
+ throw new UserManagerException(msg, e);
+ }
+
+ //Iterate through the list of users and retrieve their roles
+ for (String user : users) {
+ UserInfoBean userInfoBean = new UserInfoBean();
+ userInfoBean.setUserName(user);
+ userInfoBean.setRole(getRefinedListOfRolesOfUser(userStoreManager, user)[0]);
+ userList.add(userInfoBean);
}
return userList;
}
/**
- * Get the List of userRoles except the everyone role
+ * Get the List of userRoles except the Internal/everyone role
*
* @param userStoreManager UserStoreManager
* @param username Username of the user
* @return String[]
- * @throws UserManagementException
+ * @throws UserManagerException
*/
private String[] getRefinedListOfRolesOfUser(UserStoreManager userStoreManager, String username)
- throws UserManagementException {
+ throws UserManagerException {
ArrayList<String> rolesWithoutEveryoneRole = new ArrayList<String>();
try {
-
String[] allUserRoles = userStoreManager.getRoleListOfUser(username);
for (String role : allUserRoles) {
@@ -188,14 +189,13 @@ public class StratosUserManager {
rolesWithoutEveryoneRole.add(role);
}
}
+ String[] rolesWithoutEveryoneRoleArray = new String[rolesWithoutEveryoneRole.size()];
+ return rolesWithoutEveryoneRole.toArray(rolesWithoutEveryoneRoleArray);
} catch (UserStoreException e) {
- log.error(e.getMessage(), e);
- throw new UserManagementException(e.getMessage(), e);
+ String msg = "Error in listing the roles of user " + username + " in User Store";
+ log.error(msg, e);
+ throw new UserManagerException(msg, e);
}
-
- String[] rolesWithoutEveryoneRoleArray = new String[rolesWithoutEveryoneRole.size()];
- return rolesWithoutEveryoneRole.toArray(rolesWithoutEveryoneRoleArray);
}
-
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/2fa11c81/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/mgt/exception/UserManagementException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/mgt/exception/UserManagementException.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/mgt/exception/UserManagementException.java
deleted file mode 100644
index ba75eac..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/mgt/exception/UserManagementException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF 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.apache.stratos.manager.user.mgt.exception;
-
-
-public class UserManagementException extends Exception {
-
- public UserManagementException(String message, Throwable cause) {
- super(message, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/2fa11c81/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/mgt/exception/UserManagerException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/mgt/exception/UserManagerException.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/mgt/exception/UserManagerException.java
new file mode 100644
index 0000000..0c98f73
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/mgt/exception/UserManagerException.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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.apache.stratos.manager.user.mgt.exception;
+
+public class UserManagerException extends Exception {
+
+ private final String message;
+
+ public UserManagerException(String message, Throwable cause) {
+ super(message, cause);
+ this.message = message;
+ }
+
+ public UserManagerException(String message) {
+ super(message);
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/2fa11c81/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/UserRoleCreator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/UserRoleCreator.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/UserRoleCreator.java
index d511b65..33bf28b 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/UserRoleCreator.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/UserRoleCreator.java
@@ -22,7 +22,7 @@ package org.apache.stratos.manager.utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.user.mgt.exception.UserManagementException;
+import org.apache.stratos.manager.user.mgt.exception.UserManagerException;
import org.wso2.carbon.user.api.Permission;
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.user.api.UserStoreManager;
@@ -35,40 +35,36 @@ public class UserRoleCreator {
/**
* Creating a Internal/user Role at Carbon Server Start-up
*/
- public static void createTenantUserRole(UserStoreManager manager) throws UserManagementException{
+ public static void createTenantUserRole(UserStoreManager manager) throws UserManagerException {
String userRole = "Internal/user";
- try {
+ try {
if (!manager.isExistingRole(userRole)) {
if (log.isDebugEnabled()) {
log.debug("Creating new role: " + userRole);
}
//Set permissions to the Internal/user role
- Permission[] tenantUserPermissions = new Permission[]{ new Permission(PermissionConstants.VIEW_AUTOSCALING_POLICY, UserMgtConstants.EXECUTE_ACTION),
- new Permission(PermissionConstants.VIEW_DEPLOYMENT_POLICY, UserMgtConstants.EXECUTE_ACTION),
- new Permission(PermissionConstants.VIEW_CARTRIDGE, UserMgtConstants.EXECUTE_ACTION),
- new Permission(PermissionConstants.VIEW_SERVICE, UserMgtConstants.EXECUTE_ACTION),
- new Permission(PermissionConstants.VIEW_SUBSCRIPTION, UserMgtConstants.EXECUTE_ACTION),
- new Permission(PermissionConstants.VIEW_DOMAIN, UserMgtConstants.EXECUTE_ACTION),
- new Permission(PermissionConstants.VIEW_CLUSTER, UserMgtConstants.EXECUTE_ACTION),
- new Permission(PermissionConstants.VIEW_INSTANCE, UserMgtConstants.EXECUTE_ACTION),
- new Permission(PermissionConstants.VIEW_KUBERNETES, UserMgtConstants.EXECUTE_ACTION),
- new Permission(PermissionConstants.ADD_GIT_SYNC, UserMgtConstants.EXECUTE_ACTION),
- new Permission(PermissionConstants.ADD_SUBSCRIPTION, UserMgtConstants.EXECUTE_ACTION),
- new Permission(PermissionConstants.ADD_DOMAIN, UserMgtConstants.EXECUTE_ACTION),
- new Permission(PermissionConstants.REST_LOGIN, UserMgtConstants.EXECUTE_ACTION),
+ Permission[] tenantUserPermissions = new Permission[]{new Permission(PermissionConstants.VIEW_AUTOSCALING_POLICY, UserMgtConstants.EXECUTE_ACTION),
+ new Permission(PermissionConstants.VIEW_DEPLOYMENT_POLICY, UserMgtConstants.EXECUTE_ACTION),
+ new Permission(PermissionConstants.VIEW_CARTRIDGE, UserMgtConstants.EXECUTE_ACTION),
+ new Permission(PermissionConstants.VIEW_SERVICE, UserMgtConstants.EXECUTE_ACTION),
+ new Permission(PermissionConstants.VIEW_SUBSCRIPTION, UserMgtConstants.EXECUTE_ACTION),
+ new Permission(PermissionConstants.VIEW_DOMAIN, UserMgtConstants.EXECUTE_ACTION),
+ new Permission(PermissionConstants.VIEW_CLUSTER, UserMgtConstants.EXECUTE_ACTION),
+ new Permission(PermissionConstants.VIEW_INSTANCE, UserMgtConstants.EXECUTE_ACTION),
+ new Permission(PermissionConstants.VIEW_KUBERNETES, UserMgtConstants.EXECUTE_ACTION),
+ new Permission(PermissionConstants.ADD_GIT_SYNC, UserMgtConstants.EXECUTE_ACTION),
+ new Permission(PermissionConstants.ADD_SUBSCRIPTION, UserMgtConstants.EXECUTE_ACTION),
+ new Permission(PermissionConstants.ADD_DOMAIN, UserMgtConstants.EXECUTE_ACTION),
+ new Permission(PermissionConstants.REST_LOGIN, UserMgtConstants.EXECUTE_ACTION),
};
String[] userList = new String[]{};
manager.addRole(userRole, userList, tenantUserPermissions);
}
-
} catch (UserStoreException e) {
- log.error("Error while creating the role: " + userRole + " - " +
- e.getMessage());
- throw new UserManagementException(e.getMessage(), e);
+ e.printStackTrace();
}
-
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/2fa11c81/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
index 2a6bd82..77f69c7 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java
@@ -33,7 +33,7 @@ import org.apache.stratos.manager.subscription.CartridgeSubscription;
import org.apache.stratos.manager.subscription.SubscriptionDomain;
import org.apache.stratos.manager.user.mgt.StratosUserManager;
import org.apache.stratos.manager.user.mgt.beans.UserInfoBean;
-import org.apache.stratos.manager.user.mgt.exception.UserManagementException;
+import org.apache.stratos.manager.user.mgt.exception.UserManagerException;
import org.apache.stratos.rest.endpoint.ServiceHolder;
import org.apache.stratos.rest.endpoint.Utils;
import org.apache.stratos.rest.endpoint.annotation.AuthorizationAction;
@@ -1163,9 +1163,8 @@ public class StratosAdmin extends AbstractAdmin {
try {
stratosUserManager.addUser(getTenantUserStoreManager(), userInfoBean);
- } catch (UserManagementException e) {
- log.error(e.getMessage(), e);
- throw new RestAPIException(e.getMessage(), e);
+ } catch (UserManagerException e) {
+ throw new RestAPIException(e.getMessage());
}
log.info("Successfully added an user with Username " + userInfoBean.getUserName());
URI url = uriInfo.getAbsolutePathBuilder().path(userInfoBean.getUserName()).build();
@@ -1184,9 +1183,8 @@ public class StratosAdmin extends AbstractAdmin {
try {
stratosUserManager.deleteUser(getTenantUserStoreManager(), userName);
- } catch (UserManagementException e) {
- log.error(e.getMessage(), e);
- throw new RestAPIException(e.getMessage(), e);
+ } catch (UserManagerException e) {
+ throw new RestAPIException(e.getMessage());
}
log.info("Successfully deleted an user with Username " + userName);
return Response.noContent().build();
@@ -1204,13 +1202,12 @@ public class StratosAdmin extends AbstractAdmin {
try {
stratosUserManager.updateUser(getTenantUserStoreManager(), userInfoBean);
- } catch (UserManagementException e) {
- log.error(e.getMessage(), e);
- throw new RestAPIException(e.getMessage(), e);
+ } catch (UserManagerException e) {
+ throw new RestAPIException(e.getMessage());
}
+
log.info("Successfully updated an user with Username " + userInfoBean.getUserName());
- URI url = uriInfo.getAbsolutePathBuilder().path(userInfoBean.getUserName()).build();
- return Response.created(url).build();
+ return Response.noContent().build();
}
@GET
@@ -1225,9 +1222,8 @@ public class StratosAdmin extends AbstractAdmin {
try {
userList = stratosUserManager.getAllUsers(getTenantUserStoreManager());
- } catch (UserManagementException e) {
- log.error(e.getMessage(), e);
- throw new RestAPIException(e.getMessage(), e);
+ } catch (UserManagerException e) {
+ throw new RestAPIException(e.getMessage());
}
return userList.toArray(new UserInfoBean[userList.size()]);
}
@@ -1236,21 +1232,22 @@ public class StratosAdmin extends AbstractAdmin {
* Get Tenant UserStoreManager
*
* @return UserStoreManager
- * @throws RestAPIException
+ * @throws UserManagerException
*/
- private static UserStoreManager getTenantUserStoreManager() throws RestAPIException {
+ private static UserStoreManager getTenantUserStoreManager() throws UserManagerException {
CarbonContext carbonContext = CarbonContext.getThreadLocalCarbonContext();
- UserRealm userRealm = null;
- UserStoreManager userStoreManager = null;
+ UserRealm userRealm;
+ UserStoreManager userStoreManager;
try {
userRealm = carbonContext.getUserRealm();
userStoreManager = userRealm.getUserStoreManager();
} catch (UserStoreException e) {
- log.error(e.getMessage(), e);
- throw new RestAPIException(e.getMessage(), e);
+ String msg = "Error in retrieving UserStore Manager";
+ log.error(msg, e);
+ throw new UserManagerException(msg, e);
}
return userStoreManager;