|
|
@ -2423,21 +2423,22 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
|
|
|
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
|
|
|
ApplicationDTO applicationDTO = getApplication(applicationId);
|
|
|
|
ApplicationDTO applicationDTO = getApplication(applicationId);
|
|
|
|
|
|
|
|
String sanitizedName = ApplicationManagementUtil.sanitizeName(applicationUpdateWrapper.getName(),
|
|
|
|
|
|
|
|
Constants.ApplicationProperties.NAME );
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
ConnectionManagerUtil.beginDBTransaction();
|
|
|
|
if (!StringUtils.isEmpty(applicationUpdateWrapper.getName()) && !applicationDTO.getName()
|
|
|
|
if (!StringUtils.isEmpty(sanitizedName) && !applicationDTO.getName()
|
|
|
|
.equals(applicationUpdateWrapper.getName())) {
|
|
|
|
.equals(sanitizedName)) {
|
|
|
|
if (applicationDAO
|
|
|
|
if (applicationDAO
|
|
|
|
.isExistingAppName(applicationUpdateWrapper.getName().trim(), applicationDTO.getDeviceTypeId(),
|
|
|
|
.isExistingAppName(sanitizedName.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 " + sanitizedName
|
|
|
|
+ ". Hence you can't update the application name from " + applicationDTO.getName() + " to "
|
|
|
|
+ ". Hence you can't update the application name from " + applicationDTO.getName() + " to "
|
|
|
|
+ applicationUpdateWrapper.getName();
|
|
|
|
+ sanitizedName;
|
|
|
|
log.error(msg);
|
|
|
|
log.error(msg);
|
|
|
|
throw new BadRequestException(msg);
|
|
|
|
throw new BadRequestException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
applicationDTO.setName(ApplicationManagementUtil.sanitizeName(applicationUpdateWrapper.getName(),
|
|
|
|
applicationDTO.setName(sanitizedName);
|
|
|
|
Constants.ApplicationProperties.NAME));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!StringUtils.isEmpty(applicationUpdateWrapper.getSubMethod()) && !applicationDTO.getSubType()
|
|
|
|
if (!StringUtils.isEmpty(applicationUpdateWrapper.getSubMethod()) && !applicationDTO.getSubType()
|
|
|
|
.equals(applicationUpdateWrapper.getSubMethod())) {
|
|
|
|
.equals(applicationUpdateWrapper.getSubMethod())) {
|
|
|
|