From fe4e857639a64a8134d9fce3a14d31c13cb2566c Mon Sep 17 00:00:00 2001 From: Yohan Avishke Date: Fri, 11 Oct 2019 10:00:54 +0530 Subject: [PATCH] Change exception codes of device stream events --- ...alyticsArtifactsManagementServiceImpl.java | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/AnalyticsArtifactsManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/AnalyticsArtifactsManagementServiceImpl.java index 443177d18a..ecad0b7bd5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/AnalyticsArtifactsManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/AnalyticsArtifactsManagementServiceImpl.java @@ -86,24 +86,27 @@ public class AnalyticsArtifactsManagementServiceImpl if (!isEdited) { eventStreamAdminServiceStub.addEventStreamDefinitionAsString(streamDefinition); } else { - // Find and edit stream if (eventStreamAdminServiceStub.getStreamDetailsForStreamId(id) != null) { eventStreamAdminServiceStub.editEventStreamDefinitionAsString(streamDefinition, id); } } return Response.ok().build(); } catch (AxisFault e) { - log.error("Failed to create event definitions for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to create event definitions for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (RemoteException e) { - log.error("Failed to connect with the remote services for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to connect with the remote services for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (JWTClientException e) { - log.error("Failed to generate jwt token for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to generate jwt token for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (UserStoreException e) { - log.error("Failed to connect with the user store for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to connect with the user store for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } finally { cleanup(eventStreamAdminServiceStub); } @@ -118,17 +121,21 @@ public class AnalyticsArtifactsManagementServiceImpl publishStream(stream); return Response.ok().build(); } catch (AxisFault e) { - log.error("Failed to create event definitions for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to create event definitions for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (RemoteException e) { - log.error("Failed to connect with the remote services for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to connect with the remote services for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (JWTClientException e) { - log.error("Failed to generate jwt token for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to generate jwt token for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (UserStoreException e) { - log.error("Failed to connect with the user store for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to connect with the user store for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } } @@ -351,7 +358,7 @@ public class AnalyticsArtifactsManagementServiceImpl /** * Set data to a stream dto and publish dto using a stub * - * @param stream Stream definition + * @param stream Stream definition * @throws RemoteException Exception that may occur during a remote method call * @throws UserStoreException Exception that may occur during JWT token generation * @throws JWTClientException Exception that may occur during connecting to client store