}
}
public void putModel(SecurityModel model, String modelString) throws ModelChangeException {
String modelId = model.getId();
ModelMetaInfo modelMetaInfo = (ModelMetaInfo) modelService.getSerializedModel(modelId);
modelChanger.checkModel(model);
if (modelMetaInfo == null) {
modelMetaInfo = new ModelMetaInfo();
modelMetaInfo.setId(model.getId());
modelMetaInfo.setModel(modelString);
modelService.addTransientModel(modelMetaInfo);
// this is a new model, we need to create an application
String newAppId = APPLICATION_PREFIX + model.getId();
IApplicationMetaInfo application = applicationService.getApplication(newAppId);
if (application == null) {
application = applicationService.getApplicationImpl(modelMetaInfo);
application.setName(model.getName());
application.setId(newAppId);
}
// assign the first configured UMI as default if application hasn't
// any others
if (application.getUmiSettings() == null) {
List<? extends ISettings> list = umiSettingsManager.getSettingsList();
if (!list.isEmpty()) {
application.setUmiSettings(list.get(0));
}
}
try {
application = applicationService.saveApplication(application);
} catch (DataModelException e) {
throw new ModelChangeException(application, "Application with such name already exists."); //$NON-NLS-1$
}
} else {
modelMetaInfo.setModel(modelString);
modelService.addTransientModel(modelMetaInfo);
}
}