mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Wrap service level error messages from api level error messages
This commit is contained in:
parent
8489dec2b1
commit
8bebf2c126
@ -43,6 +43,10 @@ public class BadRequestException extends WebApplicationException {
|
|||||||
message = errorDTO.getMessage();
|
message = errorDTO.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BadRequestException(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,6 +39,10 @@ public class InvalidExecutionPlanException extends WebApplicationException {
|
|||||||
message = errorDTO.getMessage();
|
message = errorDTO.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public InvalidExecutionPlanException(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return message;
|
return message;
|
||||||
|
|||||||
@ -119,8 +119,9 @@ public class AnalyticsArtifactsManagementServiceImpl
|
|||||||
deployStream(stream);
|
deployStream(stream);
|
||||||
return Response.ok().build();
|
return Response.ok().build();
|
||||||
} catch (BadRequestException e) {
|
} catch (BadRequestException e) {
|
||||||
log.error(e.getMessage(), e);
|
String errMsg = "Failed to deploy stream due to invalid payload";
|
||||||
return e.getResponse();
|
log.error(errMsg, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build();
|
||||||
} catch (AxisFault e) {
|
} catch (AxisFault e) {
|
||||||
String errMsg = "Failed to create event definitions for tenant " + tenantDomain;
|
String errMsg = "Failed to create event definitions for tenant " + tenantDomain;
|
||||||
log.error(errMsg, e);
|
log.error(errMsg, e);
|
||||||
@ -191,8 +192,9 @@ public class AnalyticsArtifactsManagementServiceImpl
|
|||||||
deployReceiver(receiver, customMapping, adapterConfiguration);
|
deployReceiver(receiver, customMapping, adapterConfiguration);
|
||||||
return Response.ok().build();
|
return Response.ok().build();
|
||||||
} catch (BadRequestException e) {
|
} catch (BadRequestException e) {
|
||||||
log.error(e.getMessage(), e);
|
String errMsg = "Failed to deploy receiver due to invalid payload";
|
||||||
return e.getResponse();
|
log.error(errMsg, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build();
|
||||||
} catch (AxisFault e) {
|
} catch (AxisFault e) {
|
||||||
String errMsg = "Failed to create event definitions for tenantDomain: " + tenantDomain;
|
String errMsg = "Failed to create event definitions for tenantDomain: " + tenantDomain;
|
||||||
log.error(errMsg, e);
|
log.error(errMsg, e);
|
||||||
@ -263,8 +265,9 @@ public class AnalyticsArtifactsManagementServiceImpl
|
|||||||
deployPublisher(publisher, customMapping, adapterConfiguration);
|
deployPublisher(publisher, customMapping, adapterConfiguration);
|
||||||
return Response.ok().build();
|
return Response.ok().build();
|
||||||
} catch (BadRequestException e) {
|
} catch (BadRequestException e) {
|
||||||
log.error(e.getMessage(), e);
|
String errMsg = "Failed to deploy publisher due to invalid payload";
|
||||||
return e.getResponse();
|
log.error(errMsg, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build();
|
||||||
} catch (AxisFault e) {
|
} catch (AxisFault e) {
|
||||||
String errMsg = "Failed to create event definitions for tenantDomain: " + tenantDomain;
|
String errMsg = "Failed to create event definitions for tenantDomain: " + tenantDomain;
|
||||||
log.error(errMsg, e);
|
log.error(errMsg, e);
|
||||||
@ -295,8 +298,9 @@ public class AnalyticsArtifactsManagementServiceImpl
|
|||||||
deploySiddhiExecutionPlan(name, isEdited, plan.getDefinition());
|
deploySiddhiExecutionPlan(name, isEdited, plan.getDefinition());
|
||||||
return Response.ok().build();
|
return Response.ok().build();
|
||||||
} catch (InvalidExecutionPlanException e) {
|
} catch (InvalidExecutionPlanException e) {
|
||||||
log.error(e.getMessage(), e);
|
String errMsg = "Failed to deploy siddhi script due to invalid payload";
|
||||||
return e.getResponse();
|
log.error(errMsg, e);
|
||||||
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build();
|
||||||
} catch (AxisFault e) {
|
} catch (AxisFault e) {
|
||||||
String errMsg = "Failed to create event definitions for tenantDomain: " + tenantDomain;
|
String errMsg = "Failed to create event definitions for tenantDomain: " + tenantDomain;
|
||||||
log.error(errMsg, e);
|
log.error(errMsg, e);
|
||||||
@ -634,9 +638,7 @@ public class AnalyticsArtifactsManagementServiceImpl
|
|||||||
eventProcessorAdminServiceStub.editActiveExecutionPlan(plan, name);
|
eventProcessorAdminServiceStub.editActiveExecutionPlan(plan, name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ErrorDTO errorDTO = new ErrorDTO();
|
throw new InvalidExecutionPlanException(validationResponse);
|
||||||
errorDTO.setMessage(validationResponse);
|
|
||||||
throw new InvalidExecutionPlanException(errorDTO);
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
cleanup(eventProcessorAdminServiceStub);
|
cleanup(eventProcessorAdminServiceStub);
|
||||||
@ -655,9 +657,7 @@ public class AnalyticsArtifactsManagementServiceImpl
|
|||||||
String errMsg = String.format("Failed to validate Stream property attributes of %s:%s. " +
|
String errMsg = String.format("Failed to validate Stream property attributes of %s:%s. " +
|
||||||
"Stream mapping can't be null or empty",
|
"Stream mapping can't be null or empty",
|
||||||
stream.getName(), stream.getVersion());
|
stream.getName(), stream.getVersion());
|
||||||
ErrorDTO errorDTO = new ErrorDTO();
|
throw new BadRequestException(errMsg);
|
||||||
errorDTO.setMessage(errMsg);
|
|
||||||
throw new BadRequestException(errorDTO);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -670,9 +670,7 @@ public class AnalyticsArtifactsManagementServiceImpl
|
|||||||
throws BadRequestException {
|
throws BadRequestException {
|
||||||
if (adapterProperties == null) {
|
if (adapterProperties == null) {
|
||||||
String errMsg = "Failed to validate adapter attributes. Adapter attributes can't be null";
|
String errMsg = "Failed to validate adapter attributes. Adapter attributes can't be null";
|
||||||
ErrorDTO errorDTO = new ErrorDTO();
|
throw new BadRequestException(errMsg);
|
||||||
errorDTO.setMessage(errMsg);
|
|
||||||
throw new BadRequestException(errorDTO);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -692,9 +690,7 @@ public class AnalyticsArtifactsManagementServiceImpl
|
|||||||
if (adapterMappingConfiguration == null) {
|
if (adapterMappingConfiguration == null) {
|
||||||
String errMsg = "Failed to validate adapter mapping attributes. " +
|
String errMsg = "Failed to validate adapter mapping attributes. " +
|
||||||
"Adapter mapping configuration can't be null";
|
"Adapter mapping configuration can't be null";
|
||||||
ErrorDTO errorDTO = new ErrorDTO();
|
throw new BadRequestException(errMsg);
|
||||||
errorDTO.setMessage(errMsg);
|
|
||||||
throw new BadRequestException(errorDTO);
|
|
||||||
} else if (adapterMappingConfiguration.getMessageFormat() == null ||
|
} else if (adapterMappingConfiguration.getMessageFormat() == null ||
|
||||||
((adapterMappingConfiguration.getInputMappingString() == null)
|
((adapterMappingConfiguration.getInputMappingString() == null)
|
||||||
&& (adapterMappingConfiguration.getInputMappingProperties() == null ||
|
&& (adapterMappingConfiguration.getInputMappingProperties() == null ||
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user