protected SdkProfile generateSdkProfile(Application application, String token) { SdkProfile entity = new SdkProfile(); if (application == null) { application = this.generateApplication(null); } entity.setApplication(application); if (token == null) { token = "token"; } entity.setToken(token); return sdkProfileDao.save(entity); }
@Override public SdkProfileDto saveSdkProfile(SdkProfileDto sdkProfileDto) { SdkProfileDto saved = null; if (Validator.isValidSqlObject(sdkProfileDto)) { if (StringUtils.isNotBlank(sdkProfileDto.getId())) { throw new IncorrectParameterException("Update of existing SDK profile is prohibited."); } else { applicationDao.findById(sdkProfileDto.getApplicationId()); SdkTokenGenerator.generateSdkToken(sdkProfileDto); SdkProfile entity = new SdkProfile(sdkProfileDto); SdkProfile loaded = sdkProfileDao.findSdkProfileByToken(entity.getToken()); if (loaded == null) { saved = DaoUtil.getDto(sdkProfileDao.save(entity)); } else { throw new IncorrectParameterException("An SDK profile with token [" + entity.getToken() + "] already exists."); } } } return saved; }