From 9d3b2ebf42e9f7e00db65819496cdc921c418176 Mon Sep 17 00:00:00 2001 From: Nirothipan Date: Wed, 30 Aug 2017 16:20:32 +0530 Subject: [PATCH] fixes for product-iots #504 --- .../mgt/jaxrs/service/impl/UserManagementServiceImpl.java | 5 +++++ .../core/service/DeviceManagementProviderServiceImpl.java | 2 +- .../devicemgt/app/pages/cdmf.page.users/public/js/listing.js | 5 +++-- .../email/sender/core/service/EmailSenderServiceImpl.java | 5 +++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java index e134a40a17..c45588b20c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java @@ -562,7 +562,12 @@ public class UserManagementServiceImpl implements UserManagementService { } } catch (DeviceManagementException e) { String msg = "Error occurred while inviting user to enrol their device"; + if (e.getMessage() != null) { + msg = e.getMessage(); + } log.error(msg, e); + return Response.serverError().entity( + new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); } catch (UserStoreException e) { String msg = "Error occurred while getting claim values to invite user"; log.error(msg, e); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 1e09960283..2f414e8f7b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -629,7 +629,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv metaInfo.getRecipients()).build(); DeviceManagementDataHolder.getInstance().getEmailSenderService().sendEmail(ctx); } catch (EmailSendingFailedException ex) { - throw new DeviceManagementException("Error occurred while sending enrollment invitation", ex); + throw new DeviceManagementException("Error occurred while sending enrollment invitation." + ex.getMessage(), ex); } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js index c943c53f2d..452c09f012 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js @@ -89,10 +89,11 @@ $("a#invite-user-link").click(function () { modalDialog.hide(); }); }, - function () { + function (data) { + var msg = JSON.parse(data.responseText); modalDialog.header(' Unexpected Error !'); - modalDialog.content('An unexpected error occurred. Try again later.'); + modalDialog.content(msg.message); modalDialog.footer('
Ok
'); $("a#invite-user-error-link").click(function () { diff --git a/components/email-sender/org.wso2.carbon.email.sender.core/src/main/java/org/wso2/carbon/email/sender/core/service/EmailSenderServiceImpl.java b/components/email-sender/org.wso2.carbon.email.sender.core/src/main/java/org/wso2/carbon/email/sender/core/service/EmailSenderServiceImpl.java index ba21fd81fd..8e129a7ed1 100644 --- a/components/email-sender/org.wso2.carbon.email.sender.core/src/main/java/org/wso2/carbon/email/sender/core/service/EmailSenderServiceImpl.java +++ b/components/email-sender/org.wso2.carbon.email.sender.core/src/main/java/org/wso2/carbon/email/sender/core/service/EmailSenderServiceImpl.java @@ -65,8 +65,13 @@ public class EmailSenderServiceImpl implements EmailSenderService { for (String recipient : emailCtx.getRecipients()) { ContentProviderInfo info = emailCtx.getContentProviderInfo(); EmailData emailData; + String transportSenderName = "mailto"; try { emailData = contentProvider.getContent(info.getTemplate(), info.getParams()); + if(EmailSenderDataHolder.getInstance().getConfigurationContextService() + .getServerConfigContext().getAxisConfiguration().getTransportOut(transportSenderName) == null){ + throw new EmailSendingFailedException("Email transport is not configured."); + } } catch (ContentProcessingInterruptedException e) { throw new EmailSendingFailedException("Error occurred while retrieving email content to be " + "sent for recipient '" + recipient + "'", e);