|
|
|
@ -21,6 +21,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
|
import org.eclipse.wst.common.uriresolver.internal.util.URIEncoder;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.service.EmailMetaInfo;
|
|
|
|
@ -36,6 +37,7 @@ import org.wso2.carbon.user.api.UserStoreManager;
|
|
|
|
|
import javax.ws.rs.*;
|
|
|
|
|
import javax.ws.rs.core.MediaType;
|
|
|
|
|
import javax.ws.rs.core.Response;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.net.URI;
|
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
|
import java.security.SecureRandom;
|
|
|
|
@ -85,7 +87,8 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("User by username: " + userInfo.getUsername() + " was found.");
|
|
|
|
|
}
|
|
|
|
|
return Response.created(new URI(API_BASE_PATH + "/" + userInfo.getUsername())).entity(
|
|
|
|
|
return Response.created(new URI(API_BASE_PATH + "/" + URIEncoder.encode(userInfo.getUsername(), "UTF-8")))
|
|
|
|
|
.entity(
|
|
|
|
|
createdUserInfo).build();
|
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
|
String msg = "Error occurred while trying to add user '" + userInfo.getUsername() + "' to the " +
|
|
|
|
@ -99,6 +102,12 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
|
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
|
|
String msg = "Error occurred while encoding username in the URI for the newly created user " +
|
|
|
|
|
userInfo.getUsername();
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
return Response.serverError().entity(
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|