Compare commits

Invalid templates have been ignored

1 invalid template(s) found pull_request_template.md: frontmatter must start with a separator line

...

25 Commits

Author SHA1 Message Date
Thashmi-nil e1fa0656d2 Fix on API response messages in device-mgt
2 years ago
Thashmi-nil 581d81d332 Fix on API response messages in publisher
2 years ago
Thashmi-nil 5e335cc561 Fix on API response messages
2 years ago
Lasantha Dharmakeerthi 8d036da061 Improve OTP mgt service functionalities
2 years ago
Dharmakeerthi Lasantha 01aaa44e89 improve OTP mgt service functionalities
2 years ago
Ravindu Madhubhashana e28c71d4ae Added validation for app name length when creating an app
2 years ago
Lasantha Dharmakeerthi c03e1359d3 Add download URL generating method
2 years ago
Dharmakeerthi Lasantha d55ea733e7 Add download URL generating method
2 years ago
Oshani Silva a93f534e06 Improve billing feature
2 years ago
Lasantha Dharmakeerthi ad111a3999 Revert direct app publishing merge conflict
2 years ago
navodzoysa b25fb4e6ad Revert direct app publishing merge conflict
2 years ago
builder 1b2bddb167 [maven-release-plugin] prepare for next development iteration
2 years ago
builder fb4e20490a [maven-release-plugin] prepare release v5.0.15
2 years ago
Pahansith Gunathilake 5be19f28fd Merge pull request 'Fix direct app publishing issue on publisher' (#31) from shamalka1/device-mgt-core:publisher-fix into master
2 years ago
Pahansith Gunathilake d5b2d8ac3b Merge branch 'master' into publisher-fix
2 years ago
Sanjana Rajapakshe 05f7a61af0 Fix incorrect date type issue
2 years ago
Thashmi-nil ac07aa84bb fix incorrect date type issue in all scripts
2 years ago
Lasantha Dharmakeerthi f71d8fe054 Fix incorrect query param when directly publishing an app
2 years ago
Thashmi-nil b42c856b9b fix incorrect date type issue
2 years ago
navodzoysa 472d34dc09 Fix incorrect query param when directly publishing an app
2 years ago
Lasantha Dharmakeerthi 61d7c13f68 Fix ownership validation issue
2 years ago
Thilina Sandaruwan 1bea33b259 fixed ownership validation issue
2 years ago
Inosh Perara 25d3428355 Merge pull request 'fixed the validation issue' (#37) from ThilinaPremachandra/device-mgt-core:error-msg-device-status into master
2 years ago
Thilina Sandaruwan e4bc9f87f8 fixed the validation issue
2 years ago
shamalka 4e567a0a4f Fix app publishing issue on publisher
2 years ago

@ -497,7 +497,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
.getReleaseByPackages(Collections.singletonList(packageName), tenantId); .getReleaseByPackages(Collections.singletonList(packageName), tenantId);
if (!exitingPubAppReleases.isEmpty()){ if (!exitingPubAppReleases.isEmpty()){
String msg = "Public app release exists for package name " + packageName String msg = "Public app release exists for package name " + packageName
+ ". Hence you can't add new public app for package name " + ". Hence you cannot add new public app for package name "
+ packageName; + packageName;
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
@ -669,7 +669,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
String extension = windowsInstallerName.substring(windowsInstallerName.lastIndexOf(".") + 1); String extension = windowsInstallerName.substring(windowsInstallerName.lastIndexOf(".") + 1);
if (!extension.equalsIgnoreCase(Constants.MSI) && if (!extension.equalsIgnoreCase(Constants.MSI) &&
!extension.equalsIgnoreCase(Constants.APPX)) { !extension.equalsIgnoreCase(Constants.APPX)) {
String msg = "Application Type doesn't match with supporting application types of " + String msg = "Application Type does not match with supporting application types of " +
deviceType + "platform which are APPX and MSI"; deviceType + "platform which are APPX and MSI";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
@ -771,7 +771,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
try { try {
ConnectionManagerUtil.getDBConnection(); ConnectionManagerUtil.getDBConnection();
if (this.applicationReleaseDAO.verifyReleaseExistenceByHash(md5OfApp, tenantId)) { if (this.applicationReleaseDAO.verifyReleaseExistenceByHash(md5OfApp, tenantId)) {
String msg = "Same binary file is in the server. Hence you can't add same file into the " String msg = "Same binary file is in the server. Hence you cannot add same file into the "
+ "server. Device Type: " + deviceType + " and package name: " + packageName; + "server. Device Type: " + deviceType + " and package name: " + packageName;
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
@ -1175,7 +1175,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
if (!hasUserRole(filteringUnrestrictedRoles, userName)) { if (!hasUserRole(filteringUnrestrictedRoles, userName)) {
String msg = String msg =
"At least one filtering role is not assigned for the user: " + userName + ". Hence user " + userName "At least one filtering role is not assigned for the user: " + userName + ". Hence user " + userName
+ " Can't filter applications by giving these unrestricted role list"; + " Cannot filter applications by giving these unrestricted role list";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
@ -1382,7 +1382,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
ConnectionManagerUtil.openDBConnection(); ConnectionManagerUtil.openDBConnection();
ApplicationDTO applicationDTO = this.applicationDAO.getApplication(applicationId, tenantId); ApplicationDTO applicationDTO = this.applicationDAO.getApplication(applicationId, tenantId);
if (applicationDTO == null) { if (applicationDTO == null) {
String msg = "Couldn't find application for the application Id: " + applicationId; String msg = "Could not find application for the application Id: " + applicationId;
log.error(msg); log.error(msg);
throw new NotFoundException(msg); throw new NotFoundException(msg);
} }
@ -1494,7 +1494,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
log.error(msg, e); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException 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); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} finally { } finally {
@ -1768,7 +1768,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (LifeCycleManagementDAOException e) { } catch (LifeCycleManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction(); 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(); + " which has application ID: " + applicationDTO.getId();
log.error(msg, e); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
@ -1885,7 +1885,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) { } catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction(); 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; + "not. Application release UUID: " + releaseUuid;
log.error(msg, e); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
@ -1934,7 +1934,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
ConnectionManagerUtil.commitDBTransaction(); ConnectionManagerUtil.commitDBTransaction();
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
String msg = 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; + "which has uuid " + uuid;
log.error(msg, e); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
@ -1946,13 +1946,13 @@ public class ApplicationManagerImpl implements ApplicationManager {
} catch (ApplicationManagementDAOException e) { } catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction(); ConnectionManagerUtil.rollbackDBTransaction();
String msg = 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 + "."; + uuid + ".";
log.error(msg, e); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (ResourceManagementException e) { } catch (ResourceManagementException e) {
ConnectionManagerUtil.rollbackDBTransaction(); 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); log.error(msg, e);
throw new ApplicationManagementException(msg , e); throw new ApplicationManagementException(msg , e);
} finally { } finally {
@ -1981,7 +1981,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
} catch (DeviceManagementException e) { } 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); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} }
@ -2023,16 +2023,16 @@ public class ApplicationManagerImpl implements ApplicationManager {
ConnectionManagerUtil.commitDBTransaction(); ConnectionManagerUtil.commitDBTransaction();
} catch (ApplicationManagementDAOException e) { } catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction(); 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); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (TransactionManagementException 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 + "."; + "application uuid " + releaseUuid + ".";
log.error(msg, e); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (DBConnectionException 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 + "."; + "application release uuid " + releaseUuid + ".";
log.error(msg, e); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
@ -2043,7 +2043,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (ResourceManagementException e) { } catch (ResourceManagementException e) {
ConnectionManagerUtil.rollbackDBTransaction(); ConnectionManagerUtil.rollbackDBTransaction();
String msg = "Error occured when updating application installer."; String msg = "Error occurred when updating application installer.";
log.error(msg, e); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} finally { } finally {
@ -2241,7 +2241,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) { } catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction(); 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); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} finally { } finally {
@ -2259,7 +2259,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
if (!deviceTypeName.equals(Constants.ALL)) { if (!deviceTypeName.equals(Constants.ALL)) {
DeviceType deviceType = deviceManagementProviderService.getDeviceType(deviceTypeName); DeviceType deviceType = deviceManagementProviderService.getDeviceType(deviceTypeName);
if (deviceType == null) { if (deviceType == null) {
String msg = "Device type doesn't exist. Hence check the application name existence with valid " String msg = "Device type does not exist. Hence check the application name existence with valid "
+ "device type name."; + "device type name.";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
@ -2310,7 +2310,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
.isExistingAppName(applicationUpdateWrapper.getName().trim(), applicationDTO.getDeviceTypeId(), .isExistingAppName(applicationUpdateWrapper.getName().trim(), applicationDTO.getDeviceTypeId(),
tenantId)) { tenantId)) {
String msg = "Already an application registered with same name " + applicationUpdateWrapper.getName() String msg = "Already an application registered with same name " + applicationUpdateWrapper.getName()
+ ". Hence you can't update the application name from " + applicationDTO.getName() + " to " + ". Hence you cannot update the application name from " + applicationDTO.getName() + " to "
+ applicationUpdateWrapper.getName(); + applicationUpdateWrapper.getName();
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
@ -2563,7 +2563,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
applicationDAO.deleteApplicationTag(tag.getId(), applicationDTO.getId(), tenantId); applicationDAO.deleteApplicationTag(tag.getId(), applicationDTO.getId(), tenantId);
ConnectionManagerUtil.commitDBTransaction(); ConnectionManagerUtil.commitDBTransaction();
} else { } 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); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
@ -2667,7 +2667,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
ConnectionManagerUtil.beginDBTransaction(); ConnectionManagerUtil.beginDBTransaction();
if (applicationDAO.getTagForTagName(newTagName, tenantId) != null){ if (applicationDAO.getTagForTagName(newTagName, tenantId) != null){
String msg = String msg =
"You are trying to modify tag name into existing tag. Therefore you can't modify tag name from " "You are trying to modify tag name into existing tag. Therefore you cannot modify tag name from "
+ oldTagName + " to new tag name " + newTagName; + oldTagName + " to new tag name " + newTagName;
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
@ -2771,7 +2771,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
.collect(Collectors.toList()); .collect(Collectors.toList());
} else { } else {
String msg = "Tag list is either null or empty. In order to add new tags for application which has " 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."; + "verify the payload.";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
@ -2877,11 +2877,17 @@ public class ApplicationManagerImpl implements ApplicationManager {
@Override @Override
public void updateCategory(String oldCategoryName, String newCategoryName) throws ApplicationManagementException { public void updateCategory(String oldCategoryName, String newCategoryName) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); 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 { try {
ConnectionManagerUtil.beginDBTransaction(); ConnectionManagerUtil.beginDBTransaction();
CategoryDTO category = applicationDAO.getCategoryForCategoryName(oldCategoryName, tenantId); CategoryDTO category = applicationDAO.getCategoryForCategoryName(oldCategoryName, tenantId);
if (category == null){ 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); log.error(msg);
throw new NotFoundException(msg); throw new NotFoundException(msg);
} }
@ -2893,7 +2899,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
log.error(msg, e); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (TransactionManagementException 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); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) { } catch (ApplicationManagementDAOException e) {
@ -2923,7 +2929,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
*/ */
private void validateFilter(Filter filter) throws BadRequestException { private void validateFilter(Filter filter) throws BadRequestException {
if (filter == null) { if (filter == null) {
String msg = "Filter validation is failed, Filter shouldn't be null, hence please verify the request payload"; String msg = "Filter validation is failed, Filter should not be null, hence please verify the request payload";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
@ -3068,11 +3074,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) { } catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction(); 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); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (ResourceManagementException 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; + "UUID:" + releaseUuid;
log.error(msg, e); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
@ -3137,11 +3143,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) { } catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction(); 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); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (ResourceManagementException 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; + "release UUID:" + releaseUuid;
log.error(msg, e); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
@ -3202,11 +3208,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) { } catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction(); 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); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (ResourceManagementException 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; + "release UUID:" + releaseUuid;
log.error(msg, e); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
@ -3266,7 +3272,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
ConnectionManagerUtil.getDBConnection(); ConnectionManagerUtil.getDBConnection();
if (this.applicationReleaseDAO.verifyReleaseExistenceByHash(md5OfApp, tenantId)) { if (this.applicationReleaseDAO.verifyReleaseExistenceByHash(md5OfApp, tenantId)) {
String msg = String msg =
"Same binary file is in the server. Hence you can't add same file into the " "Same binary file is in the server. Hence you cannot add same file into the "
+ "server. Device Type: " + deviceTypeObj.getName() + "server. Device Type: " + deviceTypeObj.getName()
+ " and package name: " + applicationDTO.getApplicationReleaseDTOs() + " and package name: " + applicationDTO.getApplicationReleaseDTOs()
.get(0).getPackageName(); .get(0).getPackageName();
@ -3327,11 +3333,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) { } catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction(); 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); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (ResourceManagementException 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; + "UUID:" + releaseUuid;
log.error(msg, e); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
@ -3447,17 +3453,17 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
appCategories = applicationWrapper.getCategories(); appCategories = applicationWrapper.getCategories();
if (appCategories == null) { if (appCategories == null) {
String msg = "Application category can't be null."; String msg = "Application category cannot be null.";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
if (appCategories.isEmpty()) { if (appCategories.isEmpty()) {
String msg = "Application category can't be empty."; String msg = "Application category cannot be empty.";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
if (StringUtils.isEmpty(applicationWrapper.getDeviceType())) { if (StringUtils.isEmpty(applicationWrapper.getDeviceType())) {
String msg = "Device type can't be empty for the application."; String msg = "Device type cannot be empty for the application.";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
@ -3479,12 +3485,12 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
appCategories = webAppWrapper.getCategories(); appCategories = webAppWrapper.getCategories();
if (appCategories == null) { if (appCategories == null) {
String msg = "Web Clip category can't be null."; String msg = "Web Clip category cannot be null.";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
if (appCategories.isEmpty()) { if (appCategories.isEmpty()) {
String msg = "Web clip category can't be empty."; String msg = "Web clip category cannot be empty.";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
@ -3512,17 +3518,17 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
appCategories = publicAppWrapper.getCategories(); appCategories = publicAppWrapper.getCategories();
if (appCategories == null) { if (appCategories == null) {
String msg = "Application category can't be null."; String msg = "Application category cannot be null.";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
if (appCategories.isEmpty()) { if (appCategories.isEmpty()) {
String msg = "Application category can't be empty."; String msg = "Application category cannot be empty.";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
if (StringUtils.isEmpty(publicAppWrapper.getDeviceType())) { if (StringUtils.isEmpty(publicAppWrapper.getDeviceType())) {
String msg = "Device type can't be empty for the public application."; String msg = "Device type cannot be empty for the public application.";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
@ -3544,17 +3550,17 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
appCategories = customAppWrapper.getCategories(); appCategories = customAppWrapper.getCategories();
if (appCategories == null) { if (appCategories == null) {
String msg = "Application category can't be null."; String msg = "Application category cannot be null.";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
if (appCategories.isEmpty()) { if (appCategories.isEmpty()) {
String msg = "Application category can't be empty."; String msg = "Application category cannot be empty.";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
if (StringUtils.isEmpty(customAppWrapper.getDeviceType())) { if (StringUtils.isEmpty(customAppWrapper.getDeviceType())) {
String msg = "Device type can't be empty for the application."; String msg = "Device type cannot be empty for the application.";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
@ -3646,7 +3652,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
@Override @Override
public <T> void validateReleaseCreatingRequest(T param, String deviceType) throws ApplicationManagementException { public <T> void validateReleaseCreatingRequest(T param, String deviceType) throws ApplicationManagementException {
if (param == null) { if (param == null) {
String msg = "In order to validate release creating request param shouldn't be null."; String msg = "In order to validate release creating request param should not be null.";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
@ -3655,7 +3661,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
AtomicReference<EntAppReleaseWrapper> entAppReleaseWrapper = new AtomicReference<>( AtomicReference<EntAppReleaseWrapper> entAppReleaseWrapper = new AtomicReference<>(
(EntAppReleaseWrapper) param); (EntAppReleaseWrapper) param);
if (StringUtils.isEmpty(entAppReleaseWrapper.get().getSupportedOsVersions())) { if (StringUtils.isEmpty(entAppReleaseWrapper.get().getSupportedOsVersions())) {
String msg = "Supported OS Version shouldn't be null or empty."; String msg = "Supported OS Version should not be null or empty.";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
@ -3679,12 +3685,12 @@ public class ApplicationManagerImpl implements ApplicationManager {
WebAppReleaseWrapper webAppReleaseWrapper = (WebAppReleaseWrapper) param; WebAppReleaseWrapper webAppReleaseWrapper = (WebAppReleaseWrapper) param;
UrlValidator urlValidator = new UrlValidator(); UrlValidator urlValidator = new UrlValidator();
if (StringUtils.isEmpty(webAppReleaseWrapper.getVersion())) { if (StringUtils.isEmpty(webAppReleaseWrapper.getVersion())) {
String msg = "Version shouldn't be empty or null for the WEB CLIP release creating request."; String msg = "Version should not be empty or null for the WEB CLIP release creating request.";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
if (StringUtils.isEmpty(webAppReleaseWrapper.getUrl())) { if (StringUtils.isEmpty(webAppReleaseWrapper.getUrl())) {
String msg = "URL should't be null for the application release creating request for application type " String msg = "URL should not be null for the application release creating request for application type "
+ "WEB_CLIP"; + "WEB_CLIP";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
@ -3697,17 +3703,17 @@ public class ApplicationManagerImpl implements ApplicationManager {
} else if (param instanceof PublicAppReleaseWrapper) { } else if (param instanceof PublicAppReleaseWrapper) {
PublicAppReleaseWrapper publicAppReleaseWrapper = (PublicAppReleaseWrapper) param; PublicAppReleaseWrapper publicAppReleaseWrapper = (PublicAppReleaseWrapper) param;
if (StringUtils.isEmpty(publicAppReleaseWrapper.getSupportedOsVersions())) { if (StringUtils.isEmpty(publicAppReleaseWrapper.getSupportedOsVersions())) {
String msg = "Supported OS Version shouldn't be null or empty for public app release creating request."; String msg = "Supported OS Version should not be null or empty for public app release creating request.";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
if (StringUtils.isEmpty(publicAppReleaseWrapper.getVersion())) { if (StringUtils.isEmpty(publicAppReleaseWrapper.getVersion())) {
String msg = "Version shouldn't be empty or null for the Public App release creating request."; String msg = "Version should not be empty or null for the Public App release creating request.";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
if (StringUtils.isEmpty(publicAppReleaseWrapper.getPackageName())) { if (StringUtils.isEmpty(publicAppReleaseWrapper.getPackageName())) {
String msg = "Package name shouldn't be empty or null for the Public App release creating request."; String msg = "Package name should not be empty or null for the Public App release creating request.";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
@ -3721,12 +3727,12 @@ public class ApplicationManagerImpl implements ApplicationManager {
} else if (param instanceof CustomAppReleaseWrapper) { } else if (param instanceof CustomAppReleaseWrapper) {
CustomAppReleaseWrapper customAppReleaseWrapper = (CustomAppReleaseWrapper) param; CustomAppReleaseWrapper customAppReleaseWrapper = (CustomAppReleaseWrapper) param;
if (StringUtils.isEmpty(customAppReleaseWrapper.getVersion())) { if (StringUtils.isEmpty(customAppReleaseWrapper.getVersion())) {
String msg = "Version shouldn't be empty or null for the custom App release creating request."; String msg = "Version should not be empty or null for the custom App release creating request.";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
if (StringUtils.isEmpty(customAppReleaseWrapper.getPackageName())) { if (StringUtils.isEmpty(customAppReleaseWrapper.getPackageName())) {
String msg = "Package name shouldn't be empty or null for the custom App release creating request."; String msg = "Package name should not be empty or null for the custom App release creating request.";
log.error(msg); log.error(msg);
throw new BadRequestException(msg); throw new BadRequestException(msg);
} }
@ -3864,11 +3870,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
ConnectionManagerUtil.commitDBTransaction(); ConnectionManagerUtil.commitDBTransaction();
} catch (ApplicationManagementDAOException e) { } 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); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (DBConnectionException 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."; + "device.";
log.error(msg, e); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
@ -3895,11 +3901,11 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
ConnectionManagerUtil.commitDBTransaction(); ConnectionManagerUtil.commitDBTransaction();
} catch (ApplicationManagementDAOException e) { } 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); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (DBConnectionException 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."; + "device.";
log.error(msg, e); log.error(msg, e);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);

@ -393,11 +393,11 @@ public class ReviewManagerImpl implements ReviewManager {
} }
return getReviewTree(this.reviewDAO.getAllReleaseReviews(releaseDTO.getId(), request, tenantId)); return getReviewTree(this.reviewDAO.getAllReleaseReviews(releaseDTO.getId(), request, tenantId));
} catch (ReviewManagementDAOException e) { } catch (ReviewManagementDAOException e) {
String msg = "Error occured while getting all reviews for application uuid: " + uuid; String msg = "Error occurred while getting all reviews for application uuid: " + uuid;
log.error(msg, e); log.error(msg, e);
throw new ReviewManagementException(msg, e); throw new ReviewManagementException(msg, e);
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
String msg ="Error occured while getting the DB connection to get all reviews for application release which" String msg ="Error occurred while getting the DB connection to get all reviews for application release which"
+ " has UUID " + uuid; + " has UUID " + uuid;
log.error(msg, e); log.error(msg, e);
throw new ReviewManagementException(msg, e); throw new ReviewManagementException(msg, e);

@ -89,11 +89,11 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
ApplicationList applications = applicationManager.getApplications(filter); ApplicationList applications = applicationManager.getApplications(filter);
return Response.status(Response.Status.OK).entity(applications).build(); return Response.status(Response.Status.OK).entity(applications).build();
} catch (BadRequestException e) { } catch (BadRequestException e) {
String msg = "Incompatible request payload is found. Please try with valid request payload."; String msg = e.getMessage();
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (UnexpectedServerErrorException e) { } 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); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
@ -173,7 +173,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
try { try {
return createApplication(applicationWrapper, isPublished); return createApplication(applicationWrapper, isPublished);
} catch (BadRequestException e) { } 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); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
@ -181,7 +181,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (RequestValidatingException e) { } catch (RequestValidatingException e) {
String msg = "Couldn't find the required artifacts to create new ent. application with the request"; String msg = "Could not find the required artifacts to create new enterprise application with the request";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }
@ -195,7 +195,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
try { try {
return createApplication(webAppWrapper, isPublished); return createApplication(webAppWrapper, isPublished);
} catch (BadRequestException e) { } 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); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
@ -203,7 +203,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (RequestValidatingException e) { } catch (RequestValidatingException e) {
String msg = "Couldn't find the required artifacts to create new web application with the request"; String msg = "Could not find the required artifacts to create new web application with the request";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }
@ -217,7 +217,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
try { try {
return createApplication(publicAppWrapper, isPublished); return createApplication(publicAppWrapper, isPublished);
} catch (BadRequestException e) { } 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); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
@ -225,7 +225,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (RequestValidatingException e) { } catch (RequestValidatingException e) {
String msg = "Couldn't find the required artifacts to create new public application with the request"; String msg = "Could not find the required artifacts to create new public application with the request";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }
@ -239,7 +239,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
try { try {
return createApplication(customAppWrapper, isPublished); return createApplication(customAppWrapper, isPublished);
} catch (BadRequestException e) { } 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); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
@ -247,7 +247,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (RequestValidatingException e) { } catch (RequestValidatingException e) {
String msg = "Couldn't find the required artifacts to create new custom application with the request"; String msg = "Could not find the required artifacts to create new custom application with the request";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }
@ -267,7 +267,11 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
ApplicationRelease release = applicationManager.createEntAppRelease(appId, entAppReleaseWrapper, isPublished); ApplicationRelease release = applicationManager.createEntAppRelease(appId, entAppReleaseWrapper, isPublished);
return Response.status(Response.Status.CREATED).entity(release).build(); return Response.status(Response.Status.CREATED).entity(release).build();
} catch (RequestValidatingException e) { } 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); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
@ -291,6 +295,10 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
applicationManager.validatePublicAppReleaseCreatingRequest(publicAppReleaseWrapper, deviceTypeName); applicationManager.validatePublicAppReleaseCreatingRequest(publicAppReleaseWrapper, deviceTypeName);
ApplicationRelease applicationRelease = applicationManager.createPubAppRelease(appId, publicAppReleaseWrapper, isPublished); ApplicationRelease applicationRelease = applicationManager.createPubAppRelease(appId, publicAppReleaseWrapper, isPublished);
return Response.status(Response.Status.CREATED).entity(applicationRelease).build(); 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) { } catch (ApplicationManagementException e) {
String msg = "Error occurred while creating application release for the application with the id " + appId; String msg = "Error occurred while creating application release for the application with the id " + appId;
log.error(msg, e); log.error(msg, e);
@ -300,7 +308,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (RequestValidatingException e) { } catch (RequestValidatingException e) {
String msg = "Invalid payload found in public app release create request"; String msg = e.getMessage();
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }
@ -318,6 +326,10 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
applicationManager.validateWebAppReleaseCreatingRequest(webAppReleaseWrapper); applicationManager.validateWebAppReleaseCreatingRequest(webAppReleaseWrapper);
ApplicationRelease applicationRelease= applicationManager.createWebAppRelease(appId, webAppReleaseWrapper, isPublished); ApplicationRelease applicationRelease= applicationManager.createWebAppRelease(appId, webAppReleaseWrapper, isPublished);
return Response.status(Response.Status.CREATED).entity(applicationRelease).build(); 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) { } catch (ResourceManagementException e) {
String msg = "Error occurred while uploading application release artifacts"; String msg = "Error occurred while uploading application release artifacts";
log.error(msg, e); log.error(msg, e);
@ -327,7 +339,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (RequestValidatingException e) { } catch (RequestValidatingException e) {
String msg = "Invalid payload found in web app release create request"; String msg = e.getMessage();
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }
@ -346,8 +358,12 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
applicationManager.validateCustomAppReleaseCreatingRequest(customAppReleaseWrapper, deviceTypeName); applicationManager.validateCustomAppReleaseCreatingRequest(customAppReleaseWrapper, deviceTypeName);
ApplicationRelease release = applicationManager.createCustomAppRelease(appId, customAppReleaseWrapper, isPublished); ApplicationRelease release = applicationManager.createCustomAppRelease(appId, customAppReleaseWrapper, isPublished);
return Response.status(Response.Status.CREATED).entity(release).build(); 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) { } catch (RequestValidatingException e) {
String msg = "Error occurred while validating binaryArtifact"; String msg = e.getMessage();
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ResourceManagementException e) { } catch (ResourceManagementException e) {
@ -369,21 +385,24 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
@QueryParam("appName") String appName){ @QueryParam("appName") String appName){
try { try {
if (appName == null) { if (appName == null) {
String msg = "Invalid app name, appName query param cannot be empty/null."; String msg = "Invalid app name, application name cannot be empty/null.";
log.error(msg); log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).build(); return Response.status(Response.Status.BAD_REQUEST).build();
} }
ApplicationManager applicationManager = APIUtil.getApplicationManager(); ApplicationManager applicationManager = APIUtil.getApplicationManager();
if (applicationManager.isExistingAppName(appName, deviceType)) { if (applicationManager.isExistingAppName(appName, deviceType)) {
return Response.status(Response.Status.CONFLICT).build(); String msg = "Application name already exists";
return Response.status(Response.Status.CONFLICT).entity(msg).build();
} }
return Response.status(Response.Status.OK).build(); return Response.status(Response.Status.OK).build();
} catch (BadRequestException e) { } catch (BadRequestException e) {
log.error("Found invalid device type to check application existence.", e); String msg = e.getMessage();
return Response.status(Response.Status.BAD_REQUEST).build(); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
log.error("Internal Error occurred while checking the application existence.", e); String msg = "Internal Error occurred while checking the application existence.";
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} }
} }
@ -439,7 +458,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
+ applicationReleaseUuid).build(); + applicationReleaseUuid).build();
} catch (RequestValidatingException e) { } catch (RequestValidatingException e) {
String msg = String msg =
"Couldn't find the binary file with the request. Hence invoke the API with updating application" "Could not find the binary file with the request. Hence invoke the API with updating application"
+ " artifact"; + " artifact";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
@ -451,6 +470,10 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
String msg = "Found an invalid device type: " + deviceType + " with the request"; String msg = "Found an invalid device type: " + deviceType + " with the request";
log.error(msg); log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); 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) { } catch (ApplicationManagementException e) {
String msg = "Error occurred while updating the image artifacts of the application with the uuid " String msg = "Error occurred while updating the image artifacts of the application with the uuid "
+ applicationReleaseUuid; + applicationReleaseUuid;
@ -474,8 +497,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
} catch (BadRequestException e) { } catch (BadRequestException e) {
String msg = "Error occurred while modifying the application. Found bad request payload for updating the " String msg = e.getMessage();
+ "application";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
@ -505,8 +527,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
} }
return Response.status(Response.Status.OK).entity(applicationRelease).build(); return Response.status(Response.Status.OK).entity(applicationRelease).build();
} catch (BadRequestException e) { } catch (BadRequestException e) {
String msg = String msg = e.getMessage();
"Invalid request to update ent app release for application release UUID " + applicationUUID;
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (NotFoundException e) { } catch (NotFoundException e) {
@ -546,7 +567,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
} }
return Response.status(Response.Status.OK).entity(applicationRelease).build(); return Response.status(Response.Status.OK).entity(applicationRelease).build();
} catch (BadRequestException e) { } 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); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (NotFoundException e) { } catch (NotFoundException e) {
@ -586,7 +607,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
} }
return Response.status(Response.Status.OK).entity(applicationRelease).build(); return Response.status(Response.Status.OK).entity(applicationRelease).build();
} catch (BadRequestException e) { } 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); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (NotFoundException e) { } catch (NotFoundException e) {
@ -625,8 +646,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
} }
return Response.status(Response.Status.OK).entity(applicationRelease).build(); return Response.status(Response.Status.OK).entity(applicationRelease).build();
} catch (BadRequestException e) { } catch (BadRequestException e) {
String msg = String msg = e.getMessage();
"Invalid request to update ent app release for application release UUID " + applicationUUID;
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (NotFoundException e) { } catch (NotFoundException e) {
@ -676,7 +696,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
.changeLifecycleState(applicationUuid, lifecycleChanger); .changeLifecycleState(applicationUuid, lifecycleChanger);
return Response.status(Response.Status.CREATED).entity(applicationRelease).build(); return Response.status(Response.Status.CREATED).entity(applicationRelease).build();
} catch (BadRequestException e) { } catch (BadRequestException e) {
String msg = "Request payload contains invalid data, hence verify the request payload."; String msg = e.getMessage();
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).build(); return Response.status(Response.Status.BAD_REQUEST).build();
} catch (ForbiddenException e) { } catch (ForbiddenException e) {
@ -838,6 +858,10 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
try { try {
List<String> applicationTags = applicationManager.addApplicationTags(appId, tagNames); List<String> applicationTags = applicationManager.addApplicationTags(appId, tagNames);
return Response.status(Response.Status.OK).entity(applicationTags).build(); 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) { } catch (NotFoundException e) {
String msg = e.getMessage(); String msg = e.getMessage();
log.error(msg, e); log.error(msg, e);

@ -96,6 +96,7 @@ public class SPApplicationServiceImpl implements SPApplicationService {
} catch (NotFoundException e) { } catch (NotFoundException e) {
String msg = "Identity server with the id " + id + " does not exist."; String msg = "Identity server with the id " + id + " does not exist.";
log.error(msg, e); 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(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
String errMsg = "Error occurred while trying to merge identity server apps with existing apps"; 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) { } catch (NotFoundException e) {
String msg = "Identity server with the id " + id + " does not exist."; String msg = "Identity server with the id " + id + " does not exist.";
log.error(msg, e); 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(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
String errMsg = "Error occurred while trying to merge identity server apps with existing apps"; 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) { } catch (NotFoundException e) {
String msg = "Identity server with the id " + id + " does not exist."; String msg = "Identity server with the id " + id + " does not exist.";
log.error(msg, e); 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(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (BadRequestException e) { } catch (BadRequestException e) {
String errMsg = "Identity server request payload is invalid"; String errMsg = e.getMessage();
log.error(errMsg, e); log.error(errMsg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(errMsg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(errMsg).build();
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
@ -156,8 +159,8 @@ public class SPApplicationServiceImpl implements SPApplicationService {
IdentityServerResponse identityServer = spAppManager.createIdentityServer(identityServerDTO); IdentityServerResponse identityServer = spAppManager.createIdentityServer(identityServerDTO);
return Response.status(Response.Status.CREATED).entity(identityServer).build(); return Response.status(Response.Status.CREATED).entity(identityServer).build();
} catch (BadRequestException e) { } catch (BadRequestException e) {
String errMsg = "Identity server request payload is invalid"; String errMsg = e.getMessage();
log.error(errMsg, e); log.error(errMsg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(errMsg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(errMsg).build();
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
String errMsg = "Error occurred while trying to merge identity server apps with existing apps"; String errMsg = "Error occurred while trying to merge identity server apps with existing apps";
@ -179,7 +182,8 @@ public class SPApplicationServiceImpl implements SPApplicationService {
} }
SPApplicationManager spAppManager = APIUtil.getSPApplicationManager(); SPApplicationManager spAppManager = APIUtil.getSPApplicationManager();
if (spAppManager.isIdentityServerNameExist(identityServerName)) { if (spAppManager.isIdentityServerNameExist(identityServerName)) {
return Response.status(Response.Status.CONFLICT).build(); String msg = "Identity server name already exists";
return Response.status(Response.Status.CONFLICT).entity(msg).build();
} }
return Response.status(Response.Status.OK).build(); return Response.status(Response.Status.OK).build();
} catch (BadRequestException e) { } catch (BadRequestException e) {
@ -206,7 +210,8 @@ public class SPApplicationServiceImpl implements SPApplicationService {
} }
SPApplicationManager spAppManager = APIUtil.getSPApplicationManager(); SPApplicationManager spAppManager = APIUtil.getSPApplicationManager();
if (spAppManager.isIdentityServerUrlExist(identityServerUrl)) { if (spAppManager.isIdentityServerUrlExist(identityServerUrl)) {
return Response.status(Response.Status.CONFLICT).build(); String msg = "Identity server Url already exists";
return Response.status(Response.Status.CONFLICT).entity(msg).build();
} }
return Response.status(Response.Status.OK).build(); return Response.status(Response.Status.OK).build();
} catch (BadRequestException e) { } catch (BadRequestException e) {
@ -232,6 +237,7 @@ public class SPApplicationServiceImpl implements SPApplicationService {
} catch (NotFoundException e) { } catch (NotFoundException e) {
String errMsg = "No Identity server exist with the id: " + identityServerId; String errMsg = "No Identity server exist with the id: " + identityServerId;
log.error(errMsg, e); 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(); return Response.status(Response.Status.BAD_REQUEST).entity(errMsg).build();
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {
String errMsg = "Error occurred while trying to merge identity server apps with existing apps"; String errMsg = "Error occurred while trying to merge identity server apps with existing apps";
@ -252,6 +258,7 @@ public class SPApplicationServiceImpl implements SPApplicationService {
} catch (NotFoundException e) { } catch (NotFoundException e) {
String msg = "No identity server exist with the id " + identityServerId; String msg = "No identity server exist with the id " + identityServerId;
log.error(msg, e); 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(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (BadRequestException e) { } catch (BadRequestException e) {
String msg = "Invalid appIds provided"; String msg = "Invalid appIds provided";
@ -277,6 +284,7 @@ public class SPApplicationServiceImpl implements SPApplicationService {
} catch (NotFoundException e) { } catch (NotFoundException e) {
String msg = "No identity server exist with the id " + identityServerId; String msg = "No identity server exist with the id " + identityServerId;
log.error(msg, e); 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(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (BadRequestException e) { } catch (BadRequestException e) {
String msg = "Invalid appIds provided"; String msg = "Invalid appIds provided";
@ -343,6 +351,7 @@ public class SPApplicationServiceImpl implements SPApplicationService {
} catch (NotFoundException e) { } catch (NotFoundException e) {
String msg = "No identity server exist with the id " + identityServerId; String msg = "No identity server exist with the id " + identityServerId;
log.error(msg, e); 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(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (BadRequestException e) { } catch (BadRequestException e) {
String msg = "Found incompatible payload with create service provider app request."; String msg = "Found incompatible payload with create service provider app request.";

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

@ -84,7 +84,7 @@ public class ReviewManagementPublisherAdminAPIImpl implements ReviewManagementPu
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
} catch (ReviewManagementException | ApplicationManagementException e) { } catch (ReviewManagementException | ApplicationManagementException e) {
String msg = "Error occured while getting review data for application release UUID: " + uuid; String msg = "Error occurred while getting review data for application release UUID: " + uuid;
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} }
@ -105,7 +105,7 @@ public class ReviewManagementPublisherAdminAPIImpl implements ReviewManagementPu
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
} catch (ReviewManagementException | ApplicationManagementException e) { } catch (ReviewManagementException | ApplicationManagementException e) {
String msg = "Error occured while getting review data for application release UUID: " + uuid; String msg = "Error occurred while getting review data for application release UUID: " + uuid;
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} }

@ -91,9 +91,7 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig
if (properties == null || properties.isEmpty()) { if (properties == null || properties.isEmpty()) {
String msg = "Devices configuration retrieval criteria cannot be null or empty."; String msg = "Devices configuration retrieval criteria cannot be null or empty.";
log.error(msg); log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).entity( return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()
).build();
} }
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
@ -113,18 +111,15 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} catch (DeviceNotFoundException e) { } catch (DeviceNotFoundException e) {
log.warn(e.getMessage()); log.warn(e.getMessage());
return Response.status(Response.Status.BAD_REQUEST).entity( return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();
new ErrorResponse.ErrorResponseBuilder().setMessage(e.getMessage()).build()).build();
} catch (AmbiguousConfigurationException e) { } catch (AmbiguousConfigurationException e) {
String msg = "Configurations are ambiguous. " + e.getMessage(); String msg = "Configurations are ambiguous. " + e.getMessage();
log.warn(msg); log.warn(msg);
return Response.status(Response.Status.BAD_REQUEST).entity( return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} catch (JsonParseException | JsonMappingException e) { } catch (JsonParseException | JsonMappingException e) {
String msg = "Malformed device property structure"; String msg = "Malformed device property structure";
log.error(msg.concat(" ").concat(properties), e); log.error(msg.concat(" ").concat(properties), e);
return Response.status(Response.Status.BAD_REQUEST).entity( return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} catch (IOException e) { } catch (IOException e) {
String msg = "Error occurred while parsing query param JSON data."; String msg = "Error occurred while parsing query param JSON data.";
log.error(msg.concat(" ").concat(properties), e); log.error(msg.concat(" ").concat(properties), e);
@ -150,8 +145,7 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig
if (devicesTransferred.isEmpty()) { if (devicesTransferred.isEmpty()) {
String msg = "Devices are not enrolled to super tenant"; String msg = "Devices are not enrolled to super tenant";
log.warn(msg); log.warn(msg);
return Response.status(Response.Status.BAD_REQUEST).entity( return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} else { } else {
return Response.status(Response.Status.OK).entity(devicesTransferred).build(); return Response.status(Response.Status.OK).entity(devicesTransferred).build();
} }
@ -163,8 +157,7 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} catch (DeviceNotFoundException e) { } catch (DeviceNotFoundException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
return Response.status(Response.Status.BAD_REQUEST).entity( return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();
new ErrorResponse.ErrorResponseBuilder().setMessage(e.getMessage()).build()).build();
} }
} }

@ -74,9 +74,9 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
dmService = DeviceMgtAPIUtils.getDeviceManagementService(); dmService = DeviceMgtAPIUtils.getDeviceManagementService();
activity = dmService.getOperationByActivityId(id); activity = dmService.getOperationByActivityId(id);
if (activity == null) { if (activity == null) {
return Response.status(404).entity( String msg = "No activity can be " +
new ErrorResponse.ErrorResponseBuilder().setMessage("No activity can be " + "found upon the provided activity id '" + id + "'";
"found upon the provided activity id '" + id + "'").build()).build(); return Response.status(404).entity(msg).build();
} }
return Response.status(Response.Status.OK).entity(activity).build(); return Response.status(Response.Status.OK).entity(activity).build();
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
@ -98,10 +98,9 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
List<String> idList; List<String> idList;
idList = activityIdList.getIdList(); idList = activityIdList.getIdList();
if (idList == null || idList.isEmpty()) { if (idList == null || idList.isEmpty()) {
String msg = "Activity Ids shouldn't be empty"; String msg = "Activities should not be empty";
log.error(msg); log.error(msg);
return Response.status(400).entity( return Response.status(400).entity(msg).build();
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} }
Response validationFailedResponse = validateAdminPermission(); Response validationFailedResponse = validateAdminPermission();
if (validationFailedResponse == null) { if (validationFailedResponse == null) {
@ -125,8 +124,7 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
} else { } else {
String msg = "No activity found with the given IDs."; String msg = "No activity found with the given IDs.";
log.error(msg); log.error(msg);
return Response.status(404).entity( return Response.status(404).entity(msg).build();
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} }
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String msg = "ErrorResponse occurred while fetching the activity list for the supplied ids."; String msg = "ErrorResponse occurred while fetching the activity list for the supplied ids.";
@ -162,9 +160,9 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
dmService = DeviceMgtAPIUtils.getDeviceManagementService(); dmService = DeviceMgtAPIUtils.getDeviceManagementService();
activity = dmService.getOperationByActivityIdAndDevice(id, deviceIdentifier); activity = dmService.getOperationByActivityIdAndDevice(id, deviceIdentifier);
if (activity == null) { if (activity == null) {
return Response.status(404).entity( String msg = "No activity can be " +
new ErrorResponse.ErrorResponseBuilder().setMessage("No activity can be " + "found upon the provided activity id '" + id + "'";
"found upon the provided activity id '" + id + "'").build()).build(); return Response.status(404).entity(msg).build();
} }
return Response.status(Response.Status.OK).entity(activity).build(); return Response.status(Response.Status.OK).entity(activity).build();
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
@ -247,9 +245,8 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
try { try {
ifSinceDate = format.parse(ifModifiedSince); ifSinceDate = format.parse(ifModifiedSince);
} catch (ParseException e) { } catch (ParseException e) {
return Response.status(400).entity( String msg = "Invalid date string is provided in [If-Modified-Since] header.";
new ErrorResponse.ErrorResponseBuilder().setMessage( return Response.status(400).entity(msg).build();
"Invalid date string is provided in 'If-Modified-Since' header").build()).build();
} }
ifModifiedSinceTimestamp = ifSinceDate.getTime(); ifModifiedSinceTimestamp = ifSinceDate.getTime();
timestamp = ifModifiedSinceTimestamp / 1000; timestamp = ifModifiedSinceTimestamp / 1000;
@ -259,9 +256,8 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
try { try {
sinceDate = format.parse(since); sinceDate = format.parse(since);
} catch (ParseException e) { } catch (ParseException e) {
return Response.status(400).entity( String msg = "Invalid date string is provided in [since] filter.";
new ErrorResponse.ErrorResponseBuilder().setMessage( return Response.status(400).entity(msg).build();
"Invalid date string is provided in 'since' filter").build()).build();
} }
sinceTimestamp = sinceDate.getTime(); sinceTimestamp = sinceDate.getTime();
timestamp = sinceTimestamp / 1000; timestamp = sinceTimestamp / 1000;

@ -199,10 +199,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
@QueryParam("limit") int limit) { @QueryParam("limit") int limit) {
try { try {
if (!StringUtils.isEmpty(name) && !StringUtils.isEmpty(role)) { if (!StringUtils.isEmpty(name) && !StringUtils.isEmpty(role)) {
return Response.status(Response.Status.BAD_REQUEST).entity( String msg = "Request contains both name and role parameters. Only one is allowed at once.";
new ErrorResponse.ErrorResponseBuilder().setMessage("Request contains both name and role " + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
"parameters. Only one is allowed " +
"at once.").build()).build();
} }
// RequestValidationUtil.validateSelectionCriteria(type, user, roleName, ownership, status); // RequestValidationUtil.validateSelectionCriteria(type, user, roleName, ownership, status);
RequestValidationUtil.validatePaginationParameters(offset, limit); RequestValidationUtil.validatePaginationParameters(offset, limit);
@ -291,9 +289,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
try { try {
sinceDate = format.parse(ifModifiedSince); sinceDate = format.parse(ifModifiedSince);
} catch (ParseException e) { } catch (ParseException e) {
return Response.status(Response.Status.BAD_REQUEST).entity( String msg = "Invalid date string is provided in [If-Modified-Since] header";
new ErrorResponse.ErrorResponseBuilder().setMessage("Invalid date " + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
"string is provided in 'If-Modified-Since' header").build()).build();
} }
request.setSince(sinceDate); request.setSince(sinceDate);
if (requireDeviceInfo) { if (requireDeviceInfo) {
@ -312,9 +309,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
try { try {
sinceDate = format.parse(since); sinceDate = format.parse(since);
} catch (ParseException e) { } catch (ParseException e) {
return Response.status(Response.Status.BAD_REQUEST).entity( String msg = "Invalid date string is provided in [since] filter";
new ErrorResponse.ErrorResponseBuilder().setMessage("Invalid date " + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
"string is provided in 'since' filter").build()).build();
} }
request.setSince(sinceDate); request.setSince(sinceDate);
if (requireDeviceInfo) { if (requireDeviceInfo) {
@ -646,6 +642,10 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
String msg = "Error occurred while retrieving role list of user '" + authorizedUser + "'"; String msg = "Error occurred while retrieving role list of user '" + authorizedUser + "'";
log.error(msg); log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}catch (BadRequestException e){
String msg = "Error occurred while validating the device group.";
log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }
PaginationResult result = dms.getAllDevices(request, false); PaginationResult result = dms.getAllDevices(request, false);
@ -662,7 +662,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
} }
return Response.status(Response.Status.OK).entity(devices).build(); return Response.status(Response.Status.OK).entity(devices).build();
} catch (BadRequestException e) { } catch (BadRequestException e) {
String msg = "Invalid type, use either 'path' or 'full'"; String msg = "Invalid type, use either [path] or [full]";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (UnAuthorizedException e) { } catch (UnAuthorizedException e) {
@ -696,12 +696,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
boolean response = deviceManagementProviderService.disenrollDevice(deviceIdentifier); boolean response = deviceManagementProviderService.disenrollDevice(deviceIdentifier);
return Response.status(Response.Status.OK).entity(response).build(); return Response.status(Response.Status.OK).entity(response).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String msg = "Error encountered while deleting device of type : " + deviceType + " and " + String msg = "Error encountered while deleting requested device of type : " + deviceType ;
"ID : " + deviceId;
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity( return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()
).build();
} }
} }
@ -719,11 +716,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
return Response.status(Response.Status.CREATED).entity(response).build(); return Response.status(Response.Status.CREATED).entity(response).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
log.error("Error encountered while updating device of type : " + deviceType + " and " + String msg = "Error encountered while updating requested device of type : " + deviceType ;
"ID : " + deviceId); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity( return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
new ErrorResponse.ErrorResponseBuilder().setMessage("Error while updating " +
"device of type " + deviceType + " and ID : " + deviceId).build()).build();
} }
} }
@ -764,10 +759,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
sinceDate = format.parse(ifModifiedSince); sinceDate = format.parse(ifModifiedSince);
deviceData.setLastModifiedDate(sinceDate); deviceData.setLastModifiedDate(sinceDate);
} catch (ParseException e) { } catch (ParseException e) {
String msg = "Invalid date string is provided in 'If-Modified-Since' header"; String msg = "Invalid date string is provided in [If-Modified-Since] header";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity( return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} }
} }
@ -794,9 +788,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
return Response.status(Response.Status.NOT_MODIFIED).entity("No device is modified " + return Response.status(Response.Status.NOT_MODIFIED).entity("No device is modified " +
"after the timestamp provided in 'If-Modified-Since' header").build(); "after the timestamp provided in 'If-Modified-Since' header").build();
} }
return Response.status(Response.Status.NOT_FOUND).entity( String msg = "Requested device of type " + type + " does not exist";
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatus.SC_NOT_FOUND).setMessage("Requested device of type '" + return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
type + "', which carries id '" + id + "' does not exist").build()).build();
} }
return Response.status(Response.Status.OK).entity(device).build(); return Response.status(Response.Status.OK).entity(device).build();
} }
@ -817,7 +810,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
dms); dms);
return Response.status(Response.Status.OK).entity(snapshotWrapper).build(); return Response.status(Response.Status.OK).entity(snapshotWrapper).build();
} catch (BadRequestException e) { } catch (BadRequestException e) {
String msg = "Invalid type, use either 'path' or 'full'"; String msg = "Invalid type, use either [path] or [full]";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (UnAuthorizedException e) { } catch (UnAuthorizedException e) {
@ -863,12 +856,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
try { try {
sinceDate = format.parse(ifModifiedSince); sinceDate = format.parse(ifModifiedSince);
} catch (ParseException e) { } catch (ParseException e) {
String message = "Error occurred while parse the since date.Invalid date string is provided in " + String message = "Invalid date string is provided in [If-Modified-Since] header";
"'If-Modified-Since' header";
log.error(message, e); log.error(message, e);
return Response.status(Response.Status.BAD_REQUEST).entity( return Response.status(Response.Status.BAD_REQUEST).entity(message).build();
new ErrorResponse.ErrorResponseBuilder().setMessage("Invalid date " +
"string is provided in 'If-Modified-Since' header").build()).build();
} }
} }
if (sinceDate != null) { if (sinceDate != null) {
@ -877,16 +867,15 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
String message = "No device is modified after the timestamp provided in 'If-Modified-Since' header"; String message = "No device is modified after the timestamp provided in 'If-Modified-Since' header";
log.error(message); log.error(message);
return Response.status(Response.Status.NOT_MODIFIED).entity("No device is modified " + return Response.status(Response.Status.NOT_MODIFIED).entity("No device is modified " +
"after the timestamp provided in 'If-Modified-Since' header").build(); "after the timestamp provided in [If-Modified-Since] header").build();
} }
} else { } else {
device = dms.getDevice(id, requireDeviceInfo); device = dms.getDevice(id, requireDeviceInfo);
} }
if (device == null) { if (device == null) {
String message = "Device does not exist with id '" + id + "'"; String message = "Device does not exist";
log.error(message); log.error(message);
return Response.status(Response.Status.NOT_FOUND).entity( return Response.status(Response.Status.NOT_FOUND).entity(message).build();
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage(message).build()).build();
} }
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(id, device.getType()); DeviceIdentifier deviceIdentifier = new DeviceIdentifier(id, device.getType());
// check whether the user is authorized // check whether the user is authorized
@ -918,7 +907,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
DeviceManagementProviderService deviceManagementProviderService = DeviceManagementProviderService deviceManagementProviderService =
DeviceMgtAPIUtils.getDeviceManagementService(); DeviceMgtAPIUtils.getDeviceManagementService();
if (deviceIds == null || deviceIds.isEmpty()) { if (deviceIds == null || deviceIds.isEmpty()) {
String msg = "Required values of device identifiers are not set.."; String msg = "Required values of device identifiers are not set.";
log.error(msg); log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).build(); return Response.status(Response.Status.BAD_REQUEST).build();
} }
@ -1000,9 +989,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
try { try {
fm = dms.getFeatureManager(type); fm = dms.getFeatureManager(type);
} catch (DeviceTypeNotFoundException e) { } catch (DeviceTypeNotFoundException e) {
return Response.status(Response.Status.NOT_FOUND).entity( String msg = "No device type found with name : " + type ;
new ErrorResponse.ErrorResponseBuilder() return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
.setMessage("No device type found with name '" + type + "'").build()).build();
} }
if (fm != null) { if (fm != null) {
features = fm.getFeatures(); features = fm.getFeatures();
@ -1224,8 +1212,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
return Response.serverError().entity( return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} catch (InputValidationException e) { } catch (InputValidationException e) {
String msg = "Error occurred while fetching the operations for the '" + type + "' device, which " + String msg = "Error occurred while fetching the operations for the type : " + type + " device";
"carries the id '" + id + "'";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
@ -1234,7 +1221,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (DeviceTypeNotFoundException e) { } catch (DeviceTypeNotFoundException e) {
String msg = "No device type found with name '" + type + "'"; String msg = "No device type found with name : " + type ;
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
} }
@ -1344,11 +1331,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
boolean response = deviceManagementProviderService.changeDeviceStatus(deviceIdentifier, newsStatus); boolean response = deviceManagementProviderService.changeDeviceStatus(deviceIdentifier, newsStatus);
return Response.status(Response.Status.OK).entity(response).build(); return Response.status(Response.Status.OK).entity(response).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String msg = "Error occurred while changing device status of type : " + type + " and " + String msg = "Error occurred while changing device status of device type : " + type ;
"device id : " + id;
log.error(msg); log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).entity( return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} }
} }
@ -1376,11 +1361,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
List<DeviceStatus> deviceStatusHistory = deviceManagementProviderService.getDeviceStatusHistory(persistedDevice); List<DeviceStatus> deviceStatusHistory = deviceManagementProviderService.getDeviceStatusHistory(persistedDevice);
return Response.status(Response.Status.OK).entity(deviceStatusHistory).build(); return Response.status(Response.Status.OK).entity(deviceStatusHistory).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String msg = "Error occurred while retreiving device status history for device of type : " + type + " and " + String msg = "Error occurred while retrieving device status history for device of type : " + type ;
"device id : " + id;
log.error(msg); log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).entity( return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} }
} }
@ -1408,11 +1391,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
List<DeviceStatus> deviceStatusHistory = deviceManagementProviderService.getDeviceCurrentEnrolmentStatusHistory(persistedDevice); List<DeviceStatus> deviceStatusHistory = deviceManagementProviderService.getDeviceCurrentEnrolmentStatusHistory(persistedDevice);
return Response.status(Response.Status.OK).entity(deviceStatusHistory).build(); return Response.status(Response.Status.OK).entity(deviceStatusHistory).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String msg = "Error occurred while retreiving device status history for device of type : " + type + " and " + String msg = "Error occurred while retrieving device status history for device of type : " + type;
"device id : " + id;
log.error(msg); log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).entity( return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} }
} }
@ -1489,7 +1470,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving deivce management service instance"; String errorMessage = "Issue in retrieving device management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build(); new ErrorResponse.ErrorResponseBuilder().setMessage(errorMessage).build()).build();
@ -1689,7 +1670,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
DeviceType deviceTypeObj = DeviceManagerUtil.getDeviceType( DeviceType deviceTypeObj = DeviceManagerUtil.getDeviceType(
deviceType, tenantId); deviceType, tenantId);
if (deviceTypeObj == null) { if (deviceTypeObj == null) {
String msg = "Error, device of type: " + deviceType + " does not exist"; String msg = "Device of type: " + deviceType + " does not exist";
log.error(msg); log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }

@ -141,16 +141,15 @@ public class DeviceTypeManagementServiceImpl implements DeviceTypeManagementServ
DeviceManagementProviderService dms; DeviceManagementProviderService dms;
try { try {
if (StringUtils.isEmpty(type)) { if (StringUtils.isEmpty(type)) {
return Response.status(Response.Status.BAD_REQUEST).entity( String msg = "Type cannot be empty.";
new ErrorResponse.ErrorResponseBuilder().setMessage("Type cannot be empty.").build()).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }
dms = DeviceMgtAPIUtils.getDeviceManagementService(); dms = DeviceMgtAPIUtils.getDeviceManagementService();
FeatureManager fm = dms.getFeatureManager(type); FeatureManager fm = dms.getFeatureManager(type);
if (fm == null) { if (fm == null) {
return Response.status(Response.Status.NOT_FOUND).entity( String msg = "No feature manager is registered with the given type : " + type ;
new ErrorResponse.ErrorResponseBuilder().setMessage("No feature manager is " + return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
"registered with the given type '" + type + "'").build()).build();
} }
if (StringUtils.isEmpty(hidden)) { if (StringUtils.isEmpty(hidden)) {
@ -165,11 +164,9 @@ public class DeviceTypeManagementServiceImpl implements DeviceTypeManagementServ
return Response.serverError().entity( return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} catch (DeviceTypeNotFoundException e) { } catch (DeviceTypeNotFoundException e) {
String msg = "No device type found with name '" + type + "'"; String msg = "No device type found with name : " + type ;
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.NOT_FOUND).entity( return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
new ErrorResponse.ErrorResponseBuilder()
.setMessage(msg).build()).build();
} }
return Response.status(Response.Status.OK).entity(features).build(); return Response.status(Response.Status.OK).entity(features).build();
} }

@ -63,6 +63,7 @@ import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.beans.EventAction; import org.wso2.carbon.device.mgt.jaxrs.beans.EventAction;
import org.wso2.carbon.device.mgt.jaxrs.beans.GeofenceWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.GeofenceWrapper;
import org.wso2.carbon.device.mgt.jaxrs.exception.BadRequestException;
import org.wso2.carbon.device.mgt.jaxrs.service.api.GeoLocationBasedService; import org.wso2.carbon.device.mgt.jaxrs.service.api.GeoLocationBasedService;
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.InputValidationException; import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.InputValidationException;
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil; import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
@ -107,8 +108,9 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
@QueryParam("from") long from, @QueryParam("to") long to) { @QueryParam("from") long from, @QueryParam("to") long to) {
try { try {
if (!DeviceManagerUtil.isPublishLocationResponseEnabled()) { if (!DeviceManagerUtil.isPublishLocationResponseEnabled()) {
String msg = "Unable to retrieve Geo Device stats. Geo Data publishing does not enabled.";
return Response.status(Response.Status.BAD_REQUEST.getStatusCode()) return Response.status(Response.Status.BAD_REQUEST.getStatusCode())
.entity("Unable to retrive Geo Device stats. Geo Data publishing does not enabled.").build(); .entity(msg).build();
} }
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(e.getMessage()).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(e.getMessage()).build();
@ -277,7 +279,8 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Device not found: " + identifier.toString()); log.debug("Device not found: " + identifier.toString());
} }
return Response.status(Response.Status.NOT_FOUND.getStatusCode()).build(); String msg = "Device not found.";
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
} }
GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService(); GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService();
@ -288,12 +291,11 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
log.error(error, e); log.error(error, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build();
} catch (AlertAlreadyExistException e) { } catch (AlertAlreadyExistException e) {
String error = "A geo alert with this name already exists."; String error = "A geo alert with this name already exists. Try with another name.";
log.error(error, e); log.error(error, e);
return Response.status(Response.Status.BAD_REQUEST).entity(error).build(); return Response.status(Response.Status.BAD_REQUEST).entity(error).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String error = "Error occurred while retrieving the device enrollment info of " + String error = "Error occurred while retrieving the device enrollment info of requested "+ deviceType + " device.";
deviceType + " with id: " + deviceId;
log.error(error, e); log.error(error, e);
return Response.status(Response.Status.BAD_REQUEST).entity(error).build(); return Response.status(Response.Status.BAD_REQUEST).entity(error).build();
} }
@ -314,7 +316,7 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
log.error(error, e); log.error(error, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build();
} catch (AlertAlreadyExistException e) { } catch (AlertAlreadyExistException e) {
String error = "A geo alert with this name already exists."; String error = "A geo alert with this name already exists. Try with another name.";
log.error(error, e); log.error(error, e);
return Response.status(Response.Status.BAD_REQUEST).entity(error).build(); return Response.status(Response.Status.BAD_REQUEST).entity(error).build();
} }
@ -344,23 +346,23 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Device not found: " + identifier.toString()); log.debug("Device not found: " + identifier.toString());
} }
return Response.status(Response.Status.NOT_FOUND.getStatusCode()).build(); String msg = "Device not found.";
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
} }
GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService(); GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService();
geoService.updateGeoAlert(alert, identifier, alertType, device.getEnrolmentInfo().getOwner()); geoService.updateGeoAlert(alert, identifier, alertType, device.getEnrolmentInfo().getOwner());
return Response.ok().build(); return Response.ok().build();
} catch (DeviceAccessAuthorizationException | GeoLocationBasedServiceException e) { } catch (DeviceAccessAuthorizationException | GeoLocationBasedServiceException e) {
String error = "Error occurred while creating the geo alert for " + deviceType + " with id: " + deviceId; String error = "Error occurred while updating the geo alert for " + deviceType + " with id: " + deviceId;
log.error(error, e); log.error(error, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build();
} catch (AlertAlreadyExistException e) { } catch (AlertAlreadyExistException e) {
String error = "A geo alert with this name already exists."; String error = "A geo alert with this name already exists. Try with another name.";
log.error(error, e); log.error(error, e);
return Response.status(Response.Status.BAD_REQUEST).entity(error).build(); return Response.status(Response.Status.BAD_REQUEST).entity(error).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String error = "Error occurred while retrieving the device enrollment info of " + String error = "Error occurred while retrieving the device enrollment info of requested " + deviceType + " device.";
deviceType + " with id: " + deviceId;
log.error(error, e); log.error(error, e);
return Response.status(Response.Status.BAD_REQUEST).entity(error).build(); return Response.status(Response.Status.BAD_REQUEST).entity(error).build();
} }
@ -380,7 +382,7 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
log.error(error, e); log.error(error, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build();
} catch (AlertAlreadyExistException e) { } catch (AlertAlreadyExistException e) {
String error = "A geo alert with this name already exists."; String error = "A geo alert with this name already exists. Try with another name.";
log.error(error, e); log.error(error, e);
return Response.status(Response.Status.BAD_REQUEST).entity(error).build(); return Response.status(Response.Status.BAD_REQUEST).entity(error).build();
} }
@ -410,7 +412,8 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Device not found: " + identifier.toString()); log.debug("Device not found: " + identifier.toString());
} }
return Response.status(Response.Status.NOT_FOUND.getStatusCode()).build(); String msg = "Device not found.";
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
} }
GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService(); GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService();
@ -421,8 +424,7 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
log.error(error, e); log.error(error, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String error = "Error occurred while retrieving the device enrollment info of " + String error = "Error occurred while retrieving the device enrollment info of requested " +deviceType + " device";
deviceType + " with id: " + deviceId;
log.error(error, e); log.error(error, e);
return Response.status(Response.Status.BAD_REQUEST).entity(error).build(); return Response.status(Response.Status.BAD_REQUEST).entity(error).build();
} }
@ -467,7 +469,8 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Device not found: " + identifier.toString()); log.debug("Device not found: " + identifier.toString());
} }
return Response.status(Response.Status.NOT_FOUND.getStatusCode()).build(); String msg = "Device not found.";
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
} }
GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService(); GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService();
@ -497,8 +500,7 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
log.error(error, e); log.error(error, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String error = "Error occurred while retrieving the device enrollment info of " + String error = "Error occurred while retrieving the device enrollment info of requested " + deviceType + " device";
deviceType + " with id: " + deviceId;
log.error(error, e); log.error(error, e);
return Response.status(Response.Status.BAD_REQUEST).entity(error).build(); return Response.status(Response.Status.BAD_REQUEST).entity(error).build();
} }
@ -687,9 +689,9 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
public Response createGeofence(GeofenceWrapper geofenceWrapper) { public Response createGeofence(GeofenceWrapper geofenceWrapper) {
RequestValidationUtil.validateGeofenceData(geofenceWrapper);
RequestValidationUtil.validateEventConfigurationData(geofenceWrapper.getEventConfig());
try { try {
RequestValidationUtil.validateGeofenceData(geofenceWrapper);
RequestValidationUtil.validateEventConfigurationData(geofenceWrapper.getEventConfig());
GeofenceData geofenceData = mapRequestGeofenceData(geofenceWrapper); GeofenceData geofenceData = mapRequestGeofenceData(geofenceWrapper);
GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService(); GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService();
if (!geoService.createGeofence(geofenceData)) { if (!geoService.createGeofence(geofenceData)) {
@ -699,6 +701,8 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} }
return Response.status(Response.Status.CREATED).entity("Geo Fence record created successfully").build(); return Response.status(Response.Status.CREATED).entity("Geo Fence record created successfully").build();
} catch (BadRequestException e){
return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();
} catch (GeoLocationBasedServiceException e) { } catch (GeoLocationBasedServiceException e) {
String msg = "Failed to create geofence"; String msg = "Failed to create geofence";
log.error(msg, e); log.error(msg, e);
@ -895,9 +899,9 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
public Response updateGeofence(GeofenceWrapper geofenceWrapper, public Response updateGeofence(GeofenceWrapper geofenceWrapper,
@PathParam("fenceId") int fenceId, @PathParam("fenceId") int fenceId,
@QueryParam("eventIds") int[] eventIds) { @QueryParam("eventIds") int[] eventIds) {
RequestValidationUtil.validateGeofenceData(geofenceWrapper);
RequestValidationUtil.validateEventConfigurationData(geofenceWrapper.getEventConfig());
try { try {
RequestValidationUtil.validateGeofenceData(geofenceWrapper);
RequestValidationUtil.validateEventConfigurationData(geofenceWrapper.getEventConfig());
GeofenceData geofenceData = mapRequestGeofenceData(geofenceWrapper); GeofenceData geofenceData = mapRequestGeofenceData(geofenceWrapper);
GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService(); GeoLocationProviderService geoService = DeviceMgtAPIUtils.getGeoService();
if (!geoService.updateGeofence(geofenceData, fenceId)) { if (!geoService.updateGeofence(geofenceData, fenceId)) {
@ -912,6 +916,8 @@ public class GeoLocationBasedServiceImpl implements GeoLocationBasedService {
geoService.updateGeoEventConfigurations(geofenceData, eventsToRemove, geoService.updateGeoEventConfigurations(geofenceData, eventsToRemove,
geofenceData.getGroupIds(), fenceId); geofenceData.getGroupIds(), fenceId);
return Response.status(Response.Status.CREATED).entity("Geo Fence update successfully").build(); return Response.status(Response.Status.CREATED).entity("Geo Fence update successfully").build();
} catch (BadRequestException e){
return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();
} catch (GeoLocationBasedServiceException e) { } catch (GeoLocationBasedServiceException e) {
String msg = "Failed to update geofence"; String msg = "Failed to update geofence";
log.error(msg, e); log.error(msg, e);

@ -165,7 +165,7 @@ public class GroupManagementServiceImpl implements GroupManagementService {
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (GroupAlreadyExistException e) { } catch (GroupAlreadyExistException e) {
String msg = "Group already exists with name " + group.getName() + "."; String msg = "Group already exists with name : " + group.getName() + ".";
log.warn(msg); log.warn(msg);
return Response.status(Response.Status.CONFLICT).entity(msg).build(); return Response.status(Response.Status.CONFLICT).entity(msg).build();
} }
@ -179,7 +179,7 @@ public class GroupManagementServiceImpl implements GroupManagementService {
if (deviceGroup != null) { if (deviceGroup != null) {
return Response.status(Response.Status.OK).entity(deviceGroup).build(); return Response.status(Response.Status.OK).entity(deviceGroup).build();
} else { } else {
return Response.status(Response.Status.NOT_FOUND).build(); return Response.status(Response.Status.NOT_FOUND).entity("Group not found.").build();
} }
} catch (GroupManagementException e) { } catch (GroupManagementException e) {
String error = "Error occurred while getting the group."; String error = "Error occurred while getting the group.";
@ -196,7 +196,7 @@ public class GroupManagementServiceImpl implements GroupManagementService {
if (deviceGroup != null) { if (deviceGroup != null) {
return Response.status(Response.Status.OK).entity(deviceGroup).build(); return Response.status(Response.Status.OK).entity(deviceGroup).build();
} else { } else {
return Response.status(Response.Status.NOT_FOUND).build(); return Response.status(Response.Status.NOT_FOUND).entity("Group not found.").build();
} }
} catch (GroupManagementException e) { } catch (GroupManagementException e) {
String error = "Error occurred while getting the group."; String error = "Error occurred while getting the group.";
@ -218,11 +218,11 @@ public class GroupManagementServiceImpl implements GroupManagementService {
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (GroupNotExistException e) { } catch (GroupNotExistException e) {
String msg = "Group doesn't exist with ID '" + deviceGroup.getGroupId() + "'."; String msg = "Group does not exist.";
log.warn(msg); log.warn(msg);
return Response.status(Response.Status.CONFLICT).entity(msg).build(); return Response.status(Response.Status.CONFLICT).entity(msg).build();
} catch (GroupAlreadyExistException e) { } catch (GroupAlreadyExistException e) {
String msg = "Group already exists with name '" + deviceGroup.getName() + "'."; String msg = "Group already exists with name : '" + deviceGroup.getName() + "'.";
log.warn(msg); log.warn(msg);
return Response.status(Response.Status.CONFLICT).entity(msg).build(); return Response.status(Response.Status.CONFLICT).entity(msg).build();
} }

@ -83,8 +83,9 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
.validatePolicyDetails(policyWrapper); .validatePolicyDetails(policyWrapper);
// validation failure results; // validation failure results;
if (!features.isEmpty()) { if (!features.isEmpty()) {
log.error("Policy feature/s validation failed."); String msg = "Policy feature/s validation failed." ;
return Response.status(Response.Status.BAD_REQUEST).entity(features).build(); log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).entity(msg + " Features : " + features).build();
} }
PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService(); PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
@ -212,9 +213,8 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
PolicyAdministratorPoint policyAdministratorPoint = policyManagementService.getPAP(); PolicyAdministratorPoint policyAdministratorPoint = policyManagementService.getPAP();
policy = policyAdministratorPoint.getPolicy(id); policy = policyAdministratorPoint.getPolicy(id);
if (policy == null) { if (policy == null) {
return Response.status(Response.Status.NOT_FOUND).entity( String msg = "Policy not found.";
new ErrorResponse.ErrorResponseBuilder().setMessage( return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
"No policy found with the id '" + id + "'").build()).build();
} }
} catch (PolicyManagementException e) { } catch (PolicyManagementException e) {
String msg = "Error occurred while retrieving policy corresponding to the id '" + id + "'"; String msg = "Error occurred while retrieving policy corresponding to the id '" + id + "'";
@ -233,8 +233,9 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
.validatePolicyDetails(policyWrapper); .validatePolicyDetails(policyWrapper);
// validation failure results; // validation failure results;
if (!features.isEmpty()) { if (!features.isEmpty()) {
log.error("Policy feature/s validation failed."); String msg = "Policy feature/s validation failed." ;
return Response.status(Response.Status.BAD_REQUEST).entity(features).build(); log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).entity(msg + " Features : " + features).build();
} }
PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService(); PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
try { try {
@ -296,10 +297,8 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
//TODO:Check of this logic is correct //TODO:Check of this logic is correct
String modifiedInvalidPolicyIds = String modifiedInvalidPolicyIds =
invalidPolicyIds.substring(0, invalidPolicyIds.length() - 1); invalidPolicyIds.substring(0, invalidPolicyIds.length() - 1);
return Response.status(Response.Status.BAD_REQUEST). String msg = "Policies does not exist.";
entity(new ErrorResponse.ErrorResponseBuilder(). return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
setMessage("Policies with the policy ID " + modifiedInvalidPolicyIds +
" doesn't exist").build()).build();
} }
} }
@ -329,9 +328,8 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
return Response.status(Response.Status.OK).entity("Selected policies have been successfully activated") return Response.status(Response.Status.OK).entity("Selected policies have been successfully activated")
.build(); .build();
} else { } else {
return Response.status(Response.Status.NOT_FOUND).entity( String msg = "Selected policies have not been activated.";
new ErrorResponse.ErrorResponseBuilder().setMessage("Selected policies have " + return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
"not been activated").build()).build();
} }
} }
@ -361,9 +359,8 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
return Response.status(Response.Status.OK).entity("Selected policies have been successfully " + return Response.status(Response.Status.OK).entity("Selected policies have been successfully " +
"deactivated").build(); "deactivated").build();
} else { } else {
return Response.status(Response.Status.NOT_FOUND).entity( String msg = "Selected policies have not been activated.";
new ErrorResponse.ErrorResponseBuilder().setMessage("Selected policies have " + return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
"not been deactivated").build()).build();
} }
} }
@ -412,9 +409,8 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
+ "updated.").build(); + "updated.").build();
} else { } else {
return Response.status(Response.Status.NOT_FOUND).entity( String msg = "Policy priorities did not update. Bad Request.";
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Policy priorities did " return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
+ "not update. Bad Request.").build()).build();
} }
} }
@ -440,9 +436,8 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
} }
policy = policyManagementService.getAppliedPolicyToDevice(device); policy = policyManagementService.getAppliedPolicyToDevice(device);
if (policy == null) { if (policy == null) {
return Response.status(Response.Status.NOT_FOUND).entity( String msg = "Policy not found for the requested device.";
new ErrorResponse.ErrorResponseBuilder().setMessage( return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
"No policy found for device ID '" + deviceId + "'"+ deviceId).build()).build();
} }
} catch (PolicyManagementException e) { } catch (PolicyManagementException e) {
String msg = "Error occurred while retrieving policy corresponding to the id '" + deviceType + "'"+ deviceId; String msg = "Error occurred while retrieving policy corresponding to the id '" + deviceType + "'"+ deviceId;
@ -491,8 +486,9 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
= RequestValidationUtil.validateProfileFeatures(profileFeaturesList); = RequestValidationUtil.validateProfileFeatures(profileFeaturesList);
// validation failure results; // validation failure results;
if (!features.isEmpty()) { if (!features.isEmpty()) {
log.error("Policy feature/s validation failed."); String msg = "Policy feature/s validation failed." ;
return Response.status(Response.Status.BAD_REQUEST).entity(features).build(); log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).entity(msg + " Features : " +features).build();
} }
return Response.status(Response.Status.OK).entity("Valid request").build(); return Response.status(Response.Status.OK).entity("Valid request").build();

@ -169,8 +169,9 @@ public class RoleManagementServiceImpl implements RoleManagementService {
try { try {
final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm(); final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm();
if (!userRealm.getUserStoreManager().isExistingRole(roleName)) { if (!userRealm.getUserStoreManager().isExistingRole(roleName)) {
return Response.status(404).entity(new ErrorResponse.ErrorResponseBuilder().setMessage(
"No role exists with the name '" + roleName + "'").build()).build(); String msg = "No role exists with the name : " + roleName ;
return Response.status(404).entity(msg).build();
} }
final UIPermissionNode rolePermissions = this.getUIPermissionNode(roleName, userRealm); final UIPermissionNode rolePermissions = this.getUIPermissionNode(roleName, userRealm);
@ -249,9 +250,8 @@ public class RoleManagementServiceImpl implements RoleManagementService {
final UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); final UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm(); final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm();
if (!userStoreManager.isExistingRole(roleName)) { if (!userStoreManager.isExistingRole(roleName)) {
return Response.status(404).entity( String msg = "No role exists with the name : " + roleName ;
new ErrorResponse.ErrorResponseBuilder().setMessage("No role exists with the name '" + return Response.status(404).entity(msg).build();
roleName + "'").build()).build();
} }
roleInfo.setRoleName(roleName); roleInfo.setRoleName(roleName);
roleInfo.setUsers(userStoreManager.getUserListOfRole(roleName)); roleInfo.setUsers(userStoreManager.getUserListOfRole(roleName));
@ -325,7 +325,7 @@ public class RoleManagementServiceImpl implements RoleManagementService {
} }
if (ErrorMessages.ERROR_CODE_ROLE_ALREADY_EXISTS.getCode().equals(errorCode)) { if (ErrorMessages.ERROR_CODE_ROLE_ALREADY_EXISTS.getCode().equals(errorCode)) {
String roleName = roleInfo.getRoleName().split("/")[1]; String roleName = roleInfo.getRoleName().split("/")[1];
String msg = "Role already exists with name " + roleName + "."; String msg = "Role already exists with name : " + roleName + ". Try with another role name.";
log.warn(msg); log.warn(msg);
return Response.status(Response.Status.CONFLICT).entity(msg).build(); return Response.status(Response.Status.CONFLICT).entity(msg).build();
} else { } else {
@ -354,10 +354,8 @@ public class RoleManagementServiceImpl implements RoleManagementService {
roleName = userStoreName + "/" + roleName; roleName = userStoreName + "/" + roleName;
} }
if (roles.size() < 2) { if (roles.size() < 2) {
return Response.status(400).entity( String msg = "Combining Roles requires at least two roles.";
new ErrorResponse.ErrorResponseBuilder().setMessage("Combining Roles requires at least two roles.") return Response.status(400).entity(msg).build();
.build()
).build();
} }
for (String role : roles) { for (String role : roles) {
RequestValidationUtil.validateRoleName(role); RequestValidationUtil.validateRoleName(role);
@ -374,9 +372,7 @@ public class RoleManagementServiceImpl implements RoleManagementService {
mergePermissions(new UIPermissionNode[]{getRolePermissions(role)}, permsSet); mergePermissions(new UIPermissionNode[]{getRolePermissions(role)}, permsSet);
} }
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return Response.status(404).entity( return Response.status(404).entity(e.getMessage()).build();
new ErrorResponse.ErrorResponseBuilder().setMessage(e.getMessage()).build()
).build();
} }
Permission[] permissions = permsSet.toArray(new Permission[permsSet.size()]); Permission[] permissions = permsSet.toArray(new Permission[permsSet.size()]);
@ -424,9 +420,8 @@ public class RoleManagementServiceImpl implements RoleManagementService {
final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm(); final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm();
final UserStoreManager userStoreManager = userRealm.getUserStoreManager(); final UserStoreManager userStoreManager = userRealm.getUserStoreManager();
if (!userStoreManager.isExistingRole(roleName)) { if (!userStoreManager.isExistingRole(roleName)) {
return Response.status(404).entity( String msg = "No role exists with the name : " + roleName ;
new ErrorResponse.ErrorResponseBuilder().setMessage("No role exists with the name '" + return Response.status(404).entity(msg).build();
roleName + "'").build()).build();
} }
final AuthorizationManager authorizationManager = userRealm.getAuthorizationManager(); final AuthorizationManager authorizationManager = userRealm.getAuthorizationManager();
@ -481,10 +476,23 @@ public class RoleManagementServiceImpl implements RoleManagementService {
return Response.status(Response.Status.OK).entity("Role '" + roleInfo.getRoleName() + "' has " + return Response.status(Response.Status.OK).entity("Role '" + roleInfo.getRoleName() + "' has " +
"successfully been updated").build(); "successfully been updated").build();
} catch (UserStoreException e) { } catch (UserStoreException e) {
String msg = "Error occurred while updating role '" + roleName + "'"; String errorCode = "";
log.error(msg, e); String errorMessage = e.getMessage();
return Response.serverError().entity( if (errorMessage != null && !errorMessage.isEmpty() &&
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); errorMessage.contains(ErrorMessages.ERROR_CODE_ROLE_ALREADY_EXISTS.getCode())) {
errorCode = e.getMessage().split("-")[0].trim();
}
if (ErrorMessages.ERROR_CODE_ROLE_ALREADY_EXISTS.getCode().equals(errorCode)) {
String role = roleInfo.getRoleName().split("/")[1];
String msg = "Role already exists with name : " + role + ". Try with another role name.";
log.warn(msg);
return Response.status(Response.Status.CONFLICT).entity(msg).build();
}else{
String msg = "Error occurred while updating role '" + roleName + "'";
log.error(msg, e);
return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
}
} catch (UserAdminException e) { } catch (UserAdminException e) {
String msg = "Error occurred while updating permissions of the role '" + roleName + "'"; String msg = "Error occurred while updating permissions of the role '" + roleName + "'";
log.error(msg, e); log.error(msg, e);
@ -559,9 +567,8 @@ public class RoleManagementServiceImpl implements RoleManagementService {
final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm(); final UserRealm userRealm = DeviceMgtAPIUtils.getUserRealm();
final UserStoreManager userStoreManager = userRealm.getUserStoreManager(); final UserStoreManager userStoreManager = userRealm.getUserStoreManager();
if (!userStoreManager.isExistingRole(roleName)) { if (!userStoreManager.isExistingRole(roleName)) {
return Response.status(404).entity( String msg = "No role exists with the name : " + roleName ;
new ErrorResponse.ErrorResponseBuilder().setMessage("No role exists with the name '" + return Response.status(404).entity(msg).build();
roleName + "'").build()).build();
} }
final AuthorizationManager authorizationManager = userRealm.getAuthorizationManager(); final AuthorizationManager authorizationManager = userRealm.getAuthorizationManager();

@ -157,10 +157,8 @@ public class UserManagementServiceImpl implements UserManagementService {
" already exists. Therefore, request made to add user was refused."); " already exists. Therefore, request made to add user was refused.");
} }
// returning response with bad request state // returning response with bad request state
return Response.status(Response.Status.CONFLICT).entity( String msg = "User by username: " + userInfo.getUsername() + " already exists. Try with another username." ;
new ErrorResponse.ErrorResponseBuilder().setMessage("User by username: " + return Response.status(Response.Status.CONFLICT).entity(msg).build();
userInfo.getUsername() + " already exists. Therefore, request made to add user " +
"was refused.").build()).build();
} }
String initialUserPassword; String initialUserPassword;
@ -290,9 +288,8 @@ public class UserManagementServiceImpl implements UserManagementService {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("User by username: " + username + " does not exist."); log.debug("User by username: " + username + " does not exist.");
} }
return Response.status(Response.Status.NOT_FOUND).entity( String msg = "User by username: " + username + " does not exist.";
new ErrorResponse.ErrorResponseBuilder().setMessage( return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
"User doesn't exist.").build()).build();
} }
BasicUserInfo user = this.getBasicUserInfo(username); BasicUserInfo user = this.getBasicUserInfo(username);
@ -318,9 +315,8 @@ public class UserManagementServiceImpl implements UserManagementService {
log.debug("User by username: " + username + log.debug("User by username: " + username +
" doesn't exists. Therefore, request made to update user was refused."); " doesn't exists. Therefore, request made to update user was refused.");
} }
return Response.status(Response.Status.NOT_FOUND).entity( String msg = "User by username: " + username + " does not exist.";
new ErrorResponse.ErrorResponseBuilder().setMessage("User by username: " + return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
username + " doesn't exist.").build()).build();
} }
Map<String, String> defaultUserClaims = Map<String, String> defaultUserClaims =
@ -396,9 +392,8 @@ public class UserManagementServiceImpl implements UserManagementService {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("User by username: " + username + " does not exist for removal."); log.debug("User by username: " + username + " does not exist for removal.");
} }
return Response.status(Response.Status.NOT_FOUND).entity( String msg = "User by username: " + username + " does not exist for removal.";
new ErrorResponse.ErrorResponseBuilder().setMessage("User '" + return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
username + "' does not exist for removal.").build()).build();
} }
// Un-enroll all devices for the user // Un-enroll all devices for the user
DeviceManagementProviderService deviceManagementService = DeviceMgtAPIUtils.getDeviceManagementService(); DeviceManagementProviderService deviceManagementService = DeviceMgtAPIUtils.getDeviceManagementService();
@ -430,9 +425,8 @@ public class UserManagementServiceImpl implements UserManagementService {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("User by username: " + username + " does not exist for role retrieval."); log.debug("User by username: " + username + " does not exist for role retrieval.");
} }
return Response.status(Response.Status.NOT_FOUND).entity( String msg = "User by username: " + username + " does not exist for role retrieval.";
new ErrorResponse.ErrorResponseBuilder().setMessage("User by username: " + username + return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
" does not exist for role retrieval.").build()).build();
} }
RoleList result = new RoleList(); RoleList result = new RoleList();
@ -867,8 +861,8 @@ public class UserManagementServiceImpl implements UserManagementService {
try { try {
ifSinceDate = format.parse(ifModifiedSince); ifSinceDate = format.parse(ifModifiedSince);
} catch (ParseException e) { } catch (ParseException e) {
return Response.status(400).entity(new ErrorResponse.ErrorResponseBuilder() String msg = "Invalid date string is provided in [If-Modified-Since] header";
.setMessage("Invalid date string is provided in 'If-Modified-Since' header").build()).build(); return Response.status(400).entity(msg).build();
} }
ifModifiedSinceTimestamp = ifSinceDate.getTime(); ifModifiedSinceTimestamp = ifSinceDate.getTime();
isIfModifiedSinceSet = true; isIfModifiedSinceSet = true;
@ -879,8 +873,8 @@ public class UserManagementServiceImpl implements UserManagementService {
try { try {
sinceDate = format.parse(since); sinceDate = format.parse(since);
} catch (ParseException e) { } catch (ParseException e) {
return Response.status(400).entity(new ErrorResponse.ErrorResponseBuilder() String msg = "Invalid date string is provided in [since] filter";
.setMessage("Invalid date string is provided in 'since' filter").build()).build(); return Response.status(400).entity(msg).build();
} }
sinceTimestamp = sinceDate.getTime(); sinceTimestamp = sinceDate.getTime();
timestamp = sinceTimestamp / 1000; timestamp = sinceTimestamp / 1000;
@ -1094,8 +1088,7 @@ public class UserManagementServiceImpl implements UserManagementService {
if (!userStoreManager.isExistingUser(username)) { if (!userStoreManager.isExistingUser(username)) {
String message = "User by username: " + username + " does not exist for permission retrieval."; String message = "User by username: " + username + " does not exist for permission retrieval.";
log.error(message); log.error(message);
return Response.status(Response.Status.NOT_FOUND) return Response.status(Response.Status.NOT_FOUND).entity(message).build();
.entity(new ErrorResponse.ErrorResponseBuilder().setMessage(message).build()).build();
} }
// Get a list of roles which the user assigned to // Get a list of roles which the user assigned to
List<String> roles = getFilteredRoles(userStoreManager, username); List<String> roles = getFilteredRoles(userStoreManager, username);

@ -81,9 +81,8 @@ public class ApplicationManagementAdminServiceImpl implements ApplicationManagem
applicationWrapper.getDeviceIdentifiers().size() > 0) { applicationWrapper.getDeviceIdentifiers().size() > 0) {
activity = appManagerConnector.installApplicationForDevices(operation, applicationWrapper.getDeviceIdentifiers()); activity = appManagerConnector.installApplicationForDevices(operation, applicationWrapper.getDeviceIdentifiers());
} else { } else {
return Response.status(Response.Status.BAD_REQUEST).entity( String msg = "No application installation criteria i.e. user/role/device is given";
new ErrorResponse.ErrorResponseBuilder().setMessage( return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
"No application installation criteria i.e. user/role/device is given").build()).build();
} }
} }
return Response.status(Response.Status.ACCEPTED).entity(activity).build(); return Response.status(Response.Status.ACCEPTED).entity(activity).build();
@ -131,9 +130,8 @@ public class ApplicationManagementAdminServiceImpl implements ApplicationManagem
applicationWrapper.getDeviceIdentifiers().size() > 0) { applicationWrapper.getDeviceIdentifiers().size() > 0) {
activity = appManagerConnector.installApplicationForDevices(operation, applicationWrapper.getDeviceIdentifiers()); activity = appManagerConnector.installApplicationForDevices(operation, applicationWrapper.getDeviceIdentifiers());
} else { } else {
return Response.status(Response.Status.BAD_REQUEST).entity( String msg = "No application un-installation criteria i.e. user/role/device is given";
new ErrorResponse.ErrorResponseBuilder().setMessage( return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
"No application un-installation criteria i.e. user/role/device is given").build()).build();
} }
} }
return Response.status(Response.Status.ACCEPTED).entity(activity).build(); return Response.status(Response.Status.ACCEPTED).entity(activity).build();

@ -165,7 +165,7 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (UserNotFoundException e) { } catch (UserNotFoundException e) {
String msg = "Couldn't found the owner in user store to update the owner of devices."; String msg = "Could not found the owner in user store to update the owner of devices.";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }
@ -194,8 +194,7 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
catch (InvalidDeviceException e) { catch (InvalidDeviceException e) {
String msg = "Found Invalid devices"; String msg = "Found Invalid devices";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity( return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} }
} }
@ -219,7 +218,7 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
log.error(msg); log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (BadRequestException e) { } catch (BadRequestException e) {
String msg = "Bad request, can't proceed. Hence verify the request and re-try"; String msg = "Bad request, cannot proceed. Hence verify the request and re-try";
log.error(msg); log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
@ -227,7 +226,7 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
log.error(msg); log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (DeviceNotFoundException e) { } catch (DeviceNotFoundException e) {
String msg = "Couldn't find an device for device identifier: " + deviceIdentifier; String msg = "Could not find an device";
log.error(msg); log.error(msg);
return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
} }

@ -156,7 +156,7 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (GroupAlreadyExistException e) { } catch (GroupAlreadyExistException e) {
String msg = "Group already exists with name " + group.getName() + "."; String msg = "Group already exists with name : " + group.getName() + ". Try with another group name.";
log.warn(msg); log.warn(msg);
return Response.status(Response.Status.CONFLICT).entity(msg).build(); return Response.status(Response.Status.CONFLICT).entity(msg).build();
} }

@ -43,6 +43,7 @@ import org.wso2.carbon.device.mgt.jaxrs.beans.PolicyWrapper;
import org.wso2.carbon.device.mgt.jaxrs.beans.ProfileFeature; import org.wso2.carbon.device.mgt.jaxrs.beans.ProfileFeature;
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleInfo; import org.wso2.carbon.device.mgt.jaxrs.beans.RoleInfo;
import org.wso2.carbon.device.mgt.jaxrs.beans.Scope; import org.wso2.carbon.device.mgt.jaxrs.beans.Scope;
import org.wso2.carbon.device.mgt.jaxrs.exception.BadRequestException;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants; import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils; import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
import org.wso2.carbon.policy.mgt.common.PolicyPayloadValidator; import org.wso2.carbon.policy.mgt.common.PolicyPayloadValidator;
@ -711,8 +712,7 @@ public class RequestValidationUtil {
if (geofenceWrapper.getFenceName() == null || geofenceWrapper.getFenceName().trim().isEmpty()) { if (geofenceWrapper.getFenceName() == null || geofenceWrapper.getFenceName().trim().isEmpty()) {
String msg = "Geofence name should not be null or empty"; String msg = "Geofence name should not be null or empty";
log.error(msg); log.error(msg);
throw new InputValidationException( throw new BadRequestException(msg);
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build());
} }
if (geofenceWrapper.getGeoJson() != null && !geofenceWrapper.getGeoJson().trim().isEmpty()) { if (geofenceWrapper.getGeoJson() != null && !geofenceWrapper.getGeoJson().trim().isEmpty()) {
isGeoJsonExists = true; isGeoJsonExists = true;
@ -720,26 +720,22 @@ public class RequestValidationUtil {
if ((geofenceWrapper.getLatitude() < -90 || geofenceWrapper.getLatitude() > 90) && !isGeoJsonExists) { if ((geofenceWrapper.getLatitude() < -90 || geofenceWrapper.getLatitude() > 90) && !isGeoJsonExists) {
String msg = "Latitude should be a value between -90 and 90"; String msg = "Latitude should be a value between -90 and 90";
log.error(msg); log.error(msg);
throw new InputValidationException( throw new BadRequestException(msg);
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build());
} }
if ((geofenceWrapper.getLongitude() < -180 || geofenceWrapper.getLongitude() > 180) && !isGeoJsonExists) { if ((geofenceWrapper.getLongitude() < -180 || geofenceWrapper.getLongitude() > 180) && !isGeoJsonExists) {
String msg = "Longitude should be a value between -180 and 180"; String msg = "Longitude should be a value between -180 and 180";
log.error(msg); log.error(msg);
throw new InputValidationException( throw new BadRequestException(msg);
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build());
} }
if (geofenceWrapper.getRadius() < 1 && !isGeoJsonExists) { if (geofenceWrapper.getRadius() < 1 && !isGeoJsonExists) {
String msg = "Minimum radius of the fence should be 1m"; String msg = "Minimum radius of the fence should be 1m";
log.error(msg); log.error(msg);
throw new InputValidationException( throw new BadRequestException(msg);
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build());
} }
if (geofenceWrapper.getFenceShape().trim().isEmpty()) { if (geofenceWrapper.getFenceShape().trim().isEmpty()) {
String msg = "Fence shape should not be empty"; String msg = "Fence shape should not be empty";
log.error(msg); log.error(msg);
throw new InputValidationException( throw new BadRequestException(msg);
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build());
} }
} }
@ -751,23 +747,20 @@ public class RequestValidationUtil {
if (eventConfig == null ||eventConfig.isEmpty()) { if (eventConfig == null ||eventConfig.isEmpty()) {
String msg = "Event configuration is mandatory, since should not be null or empty"; String msg = "Event configuration is mandatory, since should not be null or empty";
log.error(msg); log.error(msg);
throw new InputValidationException( throw new BadRequestException(msg);
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build());
} }
for (EventConfig config : eventConfig) { for (EventConfig config : eventConfig) {
if (config.getActions() == null || config.getActions().isEmpty()) { if (config.getActions() == null || config.getActions().isEmpty()) {
String msg = "Event actions are mandatory, since should not be null or empty"; String msg = "Event actions are mandatory, since should not be null or empty";
log.error(msg); log.error(msg);
throw new InputValidationException( throw new BadRequestException(msg);
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build());
} }
if (config.getEventLogic() == null || config.getEventLogic().trim().isEmpty()) { if (config.getEventLogic() == null || config.getEventLogic().trim().isEmpty()) {
String msg = "Event logic is mandatory, since should not be null or empty"; String msg = "Event logic is mandatory, since should not be null or empty";
log.error(msg); log.error(msg);
throw new InputValidationException( throw new BadRequestException(msg);
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build());
} }
} }
} }

@ -57,8 +57,8 @@ CREATE TABLE IF NOT EXISTS AP_APP_REVIEW(
COMMENT TEXT NOT NULL, COMMENT TEXT NOT NULL,
ROOT_PARENT_ID INTEGER NOT NULL, ROOT_PARENT_ID INTEGER NOT NULL,
IMMEDIATE_PARENT_ID INTEGER NOT NULL, IMMEDIATE_PARENT_ID INTEGER NOT NULL,
CREATED_AT TIMESTAMP NOT NULL, CREATED_AT BIGINT NOT NULL,
MODIFIED_AT TIMESTAMP NOT NULL, MODIFIED_AT BIGINT NOT NULL,
RATING INTEGER NULL, RATING INTEGER NULL,
USERNAME VARCHAR(45) NOT NULL, USERNAME VARCHAR(45) NOT NULL,
ACTIVE_REVIEW BOOLEAN NOT NULL DEFAULT TRUE, ACTIVE_REVIEW BOOLEAN NOT NULL DEFAULT TRUE,

@ -58,8 +58,8 @@ CREATE TABLE AP_APP_REVIEW(
COMMENT VARCHAR(max) NOT NULL, COMMENT VARCHAR(max) NOT NULL,
ROOT_PARENT_ID INTEGER NOT NULL, ROOT_PARENT_ID INTEGER NOT NULL,
IMMEDIATE_PARENT_ID INTEGER NOT NULL, IMMEDIATE_PARENT_ID INTEGER NOT NULL,
CREATED_AT DATETIME2(0) NOT NULL, CREATED_AT BIGINT NOT NULL,
MODIFIED_AT DATETIME2(0) NOT NULL, MODIFIED_AT BIGINT NOT NULL,
RATING INTEGER NULL, RATING INTEGER NULL,
USERNAME VARCHAR(45) NOT NULL, USERNAME VARCHAR(45) NOT NULL,
ACTIVE_REVIEW BIT NOT NULL DEFAULT 1, ACTIVE_REVIEW BIT NOT NULL DEFAULT 1,

@ -63,8 +63,8 @@ CREATE TABLE IF NOT EXISTS AP_APP_REVIEW(
COMMENT TEXT NOT NULL, COMMENT TEXT NOT NULL,
ROOT_PARENT_ID INTEGER NOT NULL, ROOT_PARENT_ID INTEGER NOT NULL,
IMMEDIATE_PARENT_ID INTEGER NOT NULL, IMMEDIATE_PARENT_ID INTEGER NOT NULL,
CREATED_AT TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP NOT NULL, CREATED_AT BIGINT NOT NULL,
MODIFIED_AT TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP NOT NULL, MODIFIED_AT BIGINT NOT NULL,
RATING INTEGER NULL, RATING INTEGER NULL,
USERNAME VARCHAR(45) NOT NULL, USERNAME VARCHAR(45) NOT NULL,
ACTIVE_REVIEW BOOLEAN NOT NULL DEFAULT TRUE, ACTIVE_REVIEW BOOLEAN NOT NULL DEFAULT TRUE,

Loading…
Cancel
Save