use of org.wso2.carbon.identity.application.common.IdentityApplicationRegistrationFailureException in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method doPreAddApplicationChecks.
private void doPreAddApplicationChecks(ServiceProvider serviceProvider, String tenantDomain, String username) throws IdentityApplicationManagementException {
String appName = serviceProvider.getApplicationName();
if (StringUtils.isBlank(appName)) {
// check for required attributes.
throw buildClientException(INVALID_REQUEST, "Application name cannot be empty.");
}
ApplicationDAO appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
if (appDAO.isApplicationExists(appName, tenantDomain)) {
String msg = "An application with name: '" + appName + "' already exists in tenantDomain: " + tenantDomain;
throw new IdentityApplicationRegistrationFailureException(APPLICATION_ALREADY_EXISTS.getCode(), msg);
}
if (ApplicationManagementServiceComponent.getFileBasedSPs().containsKey(appName)) {
String msg = "Application with name: '" + appName + "' already loaded from the file system.";
throw buildClientException(APPLICATION_ALREADY_EXISTS, msg);
}
if (!isRegexValidated(appName)) {
String message = "The Application name: '" + appName + "' is not valid! It is not adhering to the regex: " + ApplicationMgtUtil.getSPValidatorRegex();
throw buildClientException(INVALID_REQUEST, message);
}
addUserIdAsDefaultSubject(serviceProvider);
validateApplicationConfigurations(serviceProvider, tenantDomain, username);
}
Aggregations