Fix on API response messages

error-response-improve
Thashmi-nil 2 years ago
parent 69ba879e78
commit b81f7c82f7

@ -1494,7 +1494,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) {
String msg = "Error occured when getting, either application tags or application categories";
String msg = "Error occurred when getting, either application tags or application categories";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} finally {
@ -1768,7 +1768,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException(msg, e);
} catch (LifeCycleManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
String msg = "Error occured while deleting life-cycle state data of application releases of the application"
String msg = "Error occurred while deleting life-cycle state data of application releases of the application"
+ " which has application ID: " + applicationDTO.getId();
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
@ -1885,7 +1885,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
String msg = "Error occurred while verifying whether application relase has an subscription or "
String msg = "Error occurred while verifying whether application release has an subscription or "
+ "not. Application release UUID: " + releaseUuid;
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
@ -1934,7 +1934,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
ConnectionManagerUtil.commitDBTransaction();
} catch (DBConnectionException e) {
String msg =
"Error occured when getting DB connection to update image artifacts of the application release "
"Error occurred when getting DB connection to update image artifacts of the application release "
+ "which has uuid " + uuid;
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
@ -1946,13 +1946,13 @@ public class ApplicationManagerImpl implements ApplicationManager {
} catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
String msg =
"Error occured while getting application release data for updating image artifacts of the application release uuid "
"Error occurred while getting application release data for updating image artifacts of the application release uuid "
+ uuid + ".";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (ResourceManagementException e) {
ConnectionManagerUtil.rollbackDBTransaction();
String msg = "Error occured while updating image artifacts of the application release uuid " + uuid + ".";
String msg = "Error occurred while updating image artifacts of the application release uuid " + uuid + ".";
log.error(msg, e);
throw new ApplicationManagementException(msg , e);
} finally {
@ -1981,7 +1981,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new BadRequestException(msg);
}
} catch (DeviceManagementException e) {
String msg = "Error occured while getting supported device types in IoTS";
String msg = "Error occurred while getting supported device types in IoTS";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
}
@ -2023,16 +2023,16 @@ public class ApplicationManagerImpl implements ApplicationManager {
ConnectionManagerUtil.commitDBTransaction();
} catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
String msg = "Error occured while getting/updating APPM DB for updating application Installer.";
String msg = "Error occurred while getting/updating APPM DB for updating application Installer.";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (TransactionManagementException e) {
String msg = "Error occured while starting the transaction to update application release artifact which has "
String msg = "Error occurred while starting the transaction to update application release artifact which has "
+ "application uuid " + releaseUuid + ".";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (DBConnectionException e) {
String msg = "Error occured when getting DB connection to update application release artifact of the "
String msg = "Error occurred when getting DB connection to update application release artifact of the "
+ "application release uuid " + releaseUuid + ".";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
@ -2043,7 +2043,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException(msg, e);
} catch (ResourceManagementException e) {
ConnectionManagerUtil.rollbackDBTransaction();
String msg = "Error occured when updating application installer.";
String msg = "Error occurred when updating application installer.";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} finally {
@ -2241,7 +2241,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
String msg = "Error occured when getting existing categories or when inserting new application categories.";
String msg = "Error occurred when getting existing categories or when inserting new application categories.";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} finally {
@ -2563,7 +2563,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
applicationDAO.deleteApplicationTag(tag.getId(), applicationDTO.getId(), tenantId);
ConnectionManagerUtil.commitDBTransaction();
} else {
String msg = "Tag " + tagName + " is not an application tag. Application ID: " + appId;
String msg = "Tag " + tagName + " is not an application tag. Application name: " + applicationDTO.getName();
log.error(msg);
throw new BadRequestException(msg);
}
@ -2771,7 +2771,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
.collect(Collectors.toList());
} else {
String msg = "Tag list is either null or empty. In order to add new tags for application which has "
+ "application ID: " + appId +", tag list should be a list of Stings. Therefore please "
+ "application name: " + applicationDTO.getName() +", tag list should be a list of Stings. Therefore please "
+ "verify the payload.";
log.error(msg);
throw new BadRequestException(msg);
@ -2877,11 +2877,17 @@ public class ApplicationManagerImpl implements ApplicationManager {
@Override
public void updateCategory(String oldCategoryName, String newCategoryName) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
if (StringUtils.isEmpty(oldCategoryName) || StringUtils.isEmpty(newCategoryName)) {
String msg = "Either old category name or new category name contains empty/null value. Hence please verify the "
+ "request.";
log.error(msg);
throw new BadRequestException(msg);
}
try {
ConnectionManagerUtil.beginDBTransaction();
CategoryDTO category = applicationDAO.getCategoryForCategoryName(oldCategoryName, tenantId);
if (category == null){
String msg = "Couldn't found a category for tag name " + oldCategoryName + ".";
String msg = "Couldn't found a category for category name " + oldCategoryName + ".";
log.error(msg);
throw new NotFoundException(msg);
}
@ -2893,7 +2899,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (TransactionManagementException e) {
String msg = "Database access error is occurred when updating categiry.";
String msg = "Database access error is occurred when updating category.";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) {
@ -3068,11 +3074,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
String msg = "Error occured when updating Ent Application release of UUID: " + releaseUuid;
String msg = "Error occurred when updating Ent Application release of UUID: " + releaseUuid;
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (ResourceManagementException e) {
String msg = "Error occured when updating application release artifact in the file system. Ent App release "
String msg = "Error occurred when updating application release artifact in the file system. Ent App release "
+ "UUID:" + releaseUuid;
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
@ -3137,11 +3143,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
String msg = "Error occured when updating public app release of UUID: " + releaseUuid;
String msg = "Error occurred when updating public app release of UUID: " + releaseUuid;
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (ResourceManagementException e) {
String msg = "Error occured when updating public app release artifact in the file system. Public app "
String msg = "Error occurred when updating public app release artifact in the file system. Public app "
+ "release UUID:" + releaseUuid;
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
@ -3202,11 +3208,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
String msg = "Error occured when updating web app release for web app Release UUID: " + releaseUuid;
String msg = "Error occurred when updating web app release for web app Release UUID: " + releaseUuid;
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (ResourceManagementException e) {
String msg = "Error occured when updating web app release artifact in the file system. Web app "
String msg = "Error occurred when updating web app release artifact in the file system. Web app "
+ "release UUID:" + releaseUuid;
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
@ -3327,11 +3333,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
String msg = "Error occured when updating Ent Application release of UUID: " + releaseUuid;
String msg = "Error occurred when updating Ent Application release of UUID: " + releaseUuid;
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (ResourceManagementException e) {
String msg = "Error occured when updating application release artifact in the file system. Ent App release "
String msg = "Error occurred when updating application release artifact in the file system. Ent App release "
+ "UUID:" + releaseUuid;
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
@ -3705,7 +3711,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new BadRequestException(msg);
}
if (StringUtils.isEmpty(webAppReleaseWrapper.getUrl())) {
String msg = "URL should't be null for the application release creating request for application type "
String msg = "URL shouldn't be null for the application release creating request for application type "
+ "WEB_CLIP";
log.error(msg);
throw new BadRequestException(msg);
@ -3885,11 +3891,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
}
ConnectionManagerUtil.commitDBTransaction();
} catch (ApplicationManagementDAOException e) {
String msg = "Error occured while updating app subscription status of the device.";
String msg = "Error occurred while updating app subscription status of the device.";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (DBConnectionException e) {
String msg = "Error occurred while obersving the database connection to update aoo subscription status of "
String msg = "Error occurred while observing the database connection to update aoo subscription status of "
+ "device.";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
@ -3916,11 +3922,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
}
ConnectionManagerUtil.commitDBTransaction();
} catch (ApplicationManagementDAOException e) {
String msg = "Error occured while updating app subscription status of the device.";
String msg = "Error occurred while updating app subscription status of the device.";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (DBConnectionException e) {
String msg = "Error occurred while obersving the database connection to update aoo subscription status of "
String msg = "Error occurred while observing the database connection to update aoo subscription status of "
+ "device.";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);

@ -89,11 +89,11 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
ApplicationList applications = applicationManager.getApplications(filter);
return Response.status(Response.Status.OK).entity(applications).build();
} catch (BadRequestException e) {
String msg = "Incompatible request payload is found. Please try with valid request payload.";
String msg = e.getMessage();
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (UnexpectedServerErrorException e) {
String msg = "Error Occured when getting supported device types by Entgra IoTS";
String msg = "Error occurred when getting supported device types by Entgra IoTS";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (ApplicationManagementException e) {
@ -173,7 +173,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
try {
return createApplication(applicationWrapper, isPublished);
} catch (BadRequestException e) {
String msg = "Found incompatible payload with ent. app creating request.";
String msg = "Found incompatible payload with ent. app creating request. Please try with valid request payload.";
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) {
@ -195,7 +195,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
try {
return createApplication(webAppWrapper, isPublished);
} catch (BadRequestException e) {
String msg = "Found incompatible payload with web app creating request.";
String msg = "Found incompatible payload with web app creating request. Please try with valid request payload.";
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) {
@ -217,7 +217,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
try {
return createApplication(publicAppWrapper, isPublished);
} catch (BadRequestException e) {
String msg = "Found incompatible payload with pub app creating request.";
String msg = "Found incompatible payload with pub app creating request. Please try with valid request payload.";
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) {
@ -239,7 +239,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
try {
return createApplication(customAppWrapper, isPublished);
} catch (BadRequestException e) {
String msg = "Found incompatible payload with custom app creating request.";
String msg = "Found incompatible payload with custom app creating request. Please try with valid request payload.";
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) {
@ -267,7 +267,11 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
ApplicationRelease release = applicationManager.createEntAppRelease(appId, entAppReleaseWrapper, isPublished);
return Response.status(Response.Status.CREATED).entity(release).build();
} catch (RequestValidatingException e) {
String msg = "Error occurred while validating binaryArtifact";
String msg = e.getMessage();
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (BadRequestException e){
String msg = e.getMessage();
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) {
@ -291,6 +295,10 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
applicationManager.validatePublicAppReleaseCreatingRequest(publicAppReleaseWrapper, deviceTypeName);
ApplicationRelease applicationRelease = applicationManager.createPubAppRelease(appId, publicAppReleaseWrapper, isPublished);
return Response.status(Response.Status.CREATED).entity(applicationRelease).build();
} catch (BadRequestException e) {
String msg = e.getMessage();
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) {
String msg = "Error occurred while creating application release for the application with the id " + appId;
log.error(msg, e);
@ -300,7 +308,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (RequestValidatingException e) {
String msg = "Invalid payload found in public app release create request";
String msg = e.getMessage();
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
}
@ -318,6 +326,10 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
applicationManager.validateWebAppReleaseCreatingRequest(webAppReleaseWrapper);
ApplicationRelease applicationRelease= applicationManager.createWebAppRelease(appId, webAppReleaseWrapper, isPublished);
return Response.status(Response.Status.CREATED).entity(applicationRelease).build();
} catch (BadRequestException e) {
String msg = e.getMessage();
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ResourceManagementException e) {
String msg = "Error occurred while uploading application release artifacts";
log.error(msg, e);
@ -327,7 +339,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (RequestValidatingException e) {
String msg = "Invalid payload found in web app release create request";
String msg = e.getMessage();
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
}
@ -346,8 +358,12 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
applicationManager.validateCustomAppReleaseCreatingRequest(customAppReleaseWrapper, deviceTypeName);
ApplicationRelease release = applicationManager.createCustomAppRelease(appId, customAppReleaseWrapper, isPublished);
return Response.status(Response.Status.CREATED).entity(release).build();
} catch (BadRequestException e) {
String msg = e.getMessage();
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (RequestValidatingException e) {
String msg = "Error occurred while validating binaryArtifact";
String msg = e.getMessage();
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ResourceManagementException e) {
@ -386,7 +402,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
}
return Response.status(Response.Status.OK).build();
} catch (BadRequestException e) {
String msg = "Found invalid device type to check application existence.";
String msg = e.getMessage();
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) {
@ -460,6 +476,10 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
String msg = "Found an invalid device type: " + deviceType + " with the request";
log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ForbiddenException e) {
String msg = e.getMessage();
log.error(msg, e);
return Response.status(Response.Status.FORBIDDEN).entity(msg).build();
} catch (ApplicationManagementException e) {
String msg = "Error occurred while updating the image artifacts of the application with the uuid "
+ applicationReleaseUuid;
@ -483,8 +503,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
log.error(msg, e);
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
} catch (BadRequestException e) {
String msg = "Error occurred while modifying the application. Found bad request payload for updating the "
+ "application";
String msg = e.getMessage();
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) {
@ -514,8 +533,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
}
return Response.status(Response.Status.OK).entity(applicationRelease).build();
} catch (BadRequestException e) {
String msg =
"Invalid request to update ent app release for application release UUID " + applicationUUID;
String msg = e.getMessage();
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (NotFoundException e) {
@ -555,7 +573,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
}
return Response.status(Response.Status.OK).entity(applicationRelease).build();
} catch (BadRequestException e) {
String msg = "Invalid request to update public app release for application release UUID " + applicationUUID;
String msg = e.getMessage();
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (NotFoundException e) {
@ -595,7 +613,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
}
return Response.status(Response.Status.OK).entity(applicationRelease).build();
} catch (BadRequestException e) {
String msg = "Invalid request to update web app release for web app release UUID " + applicationUUID;
String msg = e.getMessage();
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (NotFoundException e) {
@ -634,8 +652,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
}
return Response.status(Response.Status.OK).entity(applicationRelease).build();
} catch (BadRequestException e) {
String msg =
"Invalid request to update ent app release for application release UUID " + applicationUUID;
String msg = e.getMessage();
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (NotFoundException e) {
@ -685,7 +702,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
.changeLifecycleState(applicationUuid, lifecycleChanger);
return Response.status(Response.Status.CREATED).entity(applicationRelease).build();
} catch (BadRequestException e) {
String msg = "Request payload contains invalid data, hence verify the request payload.";
String msg = e.getMessage();
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).build();
} catch (ForbiddenException e) {
@ -847,6 +864,10 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
try {
List<String> applicationTags = applicationManager.addApplicationTags(appId, tagNames);
return Response.status(Response.Status.OK).entity(applicationTags).build();
} catch (BadRequestException e) {
String msg = e.getMessage();
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (NotFoundException e) {
String msg = e.getMessage();
log.error(msg, e);

@ -96,6 +96,7 @@ public class SPApplicationServiceImpl implements SPApplicationService {
} catch (NotFoundException e) {
String msg = "Identity server with the id " + id + " does not exist.";
log.error(msg, e);
// TODO : the correct way is to use the NOT_FOUND response here. In order to do it changes are needed for the UI code as well
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) {
String errMsg = "Error occurred while trying to merge identity server apps with existing apps";
@ -115,6 +116,7 @@ public class SPApplicationServiceImpl implements SPApplicationService {
} catch (NotFoundException e) {
String msg = "Identity server with the id " + id + " does not exist.";
log.error(msg, e);
// TODO : the correct way is to use the NOT_FOUND response here. In order to do it changes are needed for the UI code as well
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) {
String errMsg = "Error occurred while trying to merge identity server apps with existing apps";
@ -134,9 +136,10 @@ public class SPApplicationServiceImpl implements SPApplicationService {
} catch (NotFoundException e) {
String msg = "Identity server with the id " + id + " does not exist.";
log.error(msg, e);
// TODO : the correct way is to use the NOT_FOUND response here. In order to do it changes are needed for the UI code as well
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (BadRequestException e) {
String errMsg = "Identity server request payload is invalid";
String errMsg = e.getMessage();
log.error(errMsg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(errMsg).build();
} catch (ApplicationManagementException e) {
@ -156,8 +159,8 @@ public class SPApplicationServiceImpl implements SPApplicationService {
IdentityServerResponse identityServer = spAppManager.createIdentityServer(identityServerDTO);
return Response.status(Response.Status.CREATED).entity(identityServer).build();
} catch (BadRequestException e) {
String errMsg = "Identity server request payload is invalid";
log.error(errMsg, e);
String errMsg = e.getMessage();
log.error(errMsg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(errMsg).build();
} catch (ApplicationManagementException e) {
String errMsg = "Error occurred while trying to merge identity server apps with existing apps";
@ -232,6 +235,7 @@ public class SPApplicationServiceImpl implements SPApplicationService {
} catch (NotFoundException e) {
String errMsg = "No Identity server exist with the id: " + identityServerId;
log.error(errMsg, e);
// TODO : the correct way is to use the NOT_FOUND response here. In order to do it changes are needed for the UI code as well
return Response.status(Response.Status.BAD_REQUEST).entity(errMsg).build();
} catch (ApplicationManagementException e) {
String errMsg = "Error occurred while trying to merge identity server apps with existing apps";
@ -252,6 +256,7 @@ public class SPApplicationServiceImpl implements SPApplicationService {
} catch (NotFoundException e) {
String msg = "No identity server exist with the id " + identityServerId;
log.error(msg, e);
// TODO : the correct way is to use the NOT_FOUND response here. In order to do it changes are needed for the UI code as well
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (BadRequestException e) {
String msg = "Invalid appIds provided";
@ -277,6 +282,7 @@ public class SPApplicationServiceImpl implements SPApplicationService {
} catch (NotFoundException e) {
String msg = "No identity server exist with the id " + identityServerId;
log.error(msg, e);
// TODO : the correct way is to use the NOT_FOUND response here. In order to do it changes are needed for the UI code as well
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (BadRequestException e) {
String msg = "Invalid appIds provided";
@ -343,6 +349,7 @@ public class SPApplicationServiceImpl implements SPApplicationService {
} catch (NotFoundException e) {
String msg = "No identity server exist with the id " + identityServerId;
log.error(msg, e);
// TODO : the correct way is to use the NOT_FOUND response here. In order to do it changes are needed for the UI code as well
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (BadRequestException e) {
String msg = "Found incompatible payload with create service provider app request.";

@ -155,6 +155,10 @@ public class ApplicationManagementPublisherAdminAPIImpl implements ApplicationMa
applicationManager.updateCategory(oldCategoryName, newCategoryName);
return Response.status(Response.Status.OK)
.entity("Category is updated from " + oldCategoryName + " to " + newCategoryName).build();
} catch (BadRequestException e) {
String msg = e.getMessage();
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (NotFoundException e) {
String msg = e.getMessage();
log.error(msg, e);
@ -181,6 +185,10 @@ public class ApplicationManagementPublisherAdminAPIImpl implements ApplicationMa
String msg = e.getMessage();
log.error(msg, e);
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
} catch (ForbiddenException e) {
String msg = e.getMessage();
log.error(msg, e);
return Response.status(Response.Status.FORBIDDEN).entity(msg).build();
} catch (ApplicationManagementException e) {
String msg = "Error Occurred while deleting registered category.";
log.error(msg, e);

Loading…
Cancel
Save