if (!newSchemaMetaInfo.equals(prevSchemaMetaInfo)) { if (isBlank(newSchemaMetaInfo.getFqn())) { throw new DatabaseProcessingException("FQN can't be empty."); throw new DatabaseProcessingException("Can't change FQN of the existing common type."); != prevScope) { if (SYSTEM.equals(newScope)) { throw new DatabaseProcessingException("Can't update scope to system."); throw new DatabaseProcessingException("Can't update scope to lower."); throw new DatabaseProcessingException("Can't change tenant reference for the existing " + "common type."); throw new DatabaseProcessingException("Can't change application reference for the " + "existing common type.");
} else { LOG.warn("Endpoint is not assigned to current user {}!", endpointUserId); throw new DatabaseProcessingException("Endpoint is not assigned to current user."); throw new DatabaseProcessingException("Endpoint user is not present in db.");
LOG.warn("Endpoint is already assigned to different user {}. Unassign it first!.", endpoint.getEndpointUserId()); throw new DatabaseProcessingException("Endpoint is already assigned to different user."); throw new DatabaseProcessingException("No endpoint found for specified accessToken."); throw new DatabaseProcessingException("Endpoint user is not present in db.");
throw new DatabaseProcessingException("Common type version can't be deleted because " + "it is referenced by system modules."); throw new DatabaseProcessingException("Common type version can't be deleted because it is" + " referenced by other types.");
@Override public CTLSchemaDto updateCtlSchema(CTLSchemaDto ctlSchema) { validateCtlSchemaObject(ctlSchema); LOG.debug("Update ctl schema with id [{}]", ctlSchema.getId()); CtlSchema schema = ctlSchemaDao.findById(ctlSchema.getId()); if (schema != null) { synchronized (this) { if (ctlSchema.getVersion() != schema.getVersion()) { throw new DatabaseProcessingException("Can't change version of existing common type " + "version."); } CtlSchemaMetaInfo metaInfo = schema.getMetaInfo(); if (!ctlSchema.getMetaInfo().equals(metaInfo.toDto())) { throw new DatabaseProcessingException("Can't update scope of existing common type " + "version within update procedure."); } ctlSchemaMetaInfoDao.lockRequest(lockOptions).setScope(true).lock(metaInfo); schema.update(ctlSchema); return DaoUtil.getDto(ctlSchemaDao.save(schema, true)); } } else { throw new DatabaseProcessingException("Can't find common type version by id."); } }
dto.setType(schema.getType()); } else { throw new DatabaseProcessingException("Can't find notification schema by id " + schemaId); } catch (IOException ex) { LOG.error("Can't serialize notification body using schema. ", ex); throw new DatabaseProcessingException("Can't serialize notification body using schema: " + schemaId);
LOG.error("[{}] Stored profile is null. Can't update endpoint profile.", profile.getId()); throw new DatabaseProcessingException("Stored profile is null. " + "Can't update endpoint profile.");
@Override public void removeEndpointProfileByKeyHash(byte[] endpointProfileKeyHash) { validateHash(endpointProfileKeyHash, "Can't remove endpoint profile by key hash. Invalid key " + "hash " + endpointProfileKeyHash); EndpointProfile endpointProfile = endpointProfileDao.findByKeyHash(endpointProfileKeyHash); if (endpointProfile != null) { if (isValidId(endpointProfile.getEndpointUserId())) { detachEndpointFromUser(getDto(endpointProfile)); } endpointProfileDao.removeByKeyHash(endpointProfileKeyHash); } else { throw new DatabaseProcessingException("Endpoint profile is not present in db."); } }
@Override public CtlSchemaMetaInfoDto updateCtlSchemaMetaInfoScope(CtlSchemaMetaInfoDto ctlSchemaMetaInfo) { validateObject(ctlSchemaMetaInfo, "Incorrect ctl schema meta info object"); LOG.debug("Update ctl schema meta info scope with id [{}]", ctlSchemaMetaInfo.getId()); CtlSchemaMetaInfo schemaMetaInfo = ctlSchemaMetaInfoDao.findById(ctlSchemaMetaInfo.getId()); if (schemaMetaInfo != null) { synchronized (this) { ctlSchemaMetaInfoDao.lockRequest(lockOptions).setScope(true).lock(schemaMetaInfo); if (checkScopeUpdate(ctlSchemaMetaInfo, schemaMetaInfo.toDto())) { List<CtlSchemaMetaInfo> others = ctlSchemaMetaInfoDao.findOthersByFqnAndTenantId( ctlSchemaMetaInfo.getFqn(), ctlSchemaMetaInfo.getTenantId(), ctlSchemaMetaInfo .getId()); if (others != null && !others.isEmpty()) { throw new DatabaseProcessingException("Can't update scope of the common type due to " + "an FQN conflict."); } schemaMetaInfo = ctlSchemaMetaInfoDao.updateScope( new CtlSchemaMetaInfo(ctlSchemaMetaInfo)); } return DaoUtil.getDto(schemaMetaInfo); } } else { throw new DatabaseProcessingException("Can't find common type by id."); } }
.getFqn(), metaInfo.getTenantId(), metaInfo.getApplicationId()); if (existingFqns != null && !existingFqns.isEmpty()) { throw new DatabaseProcessingException("Can't save common type due to an FQN conflict."); dto = getDto(ctlSchemaDao.save(ctlSchema, true)); } catch (DataIntegrityViolationException ex) { throw new DatabaseProcessingException("Can't save common type: such FQN and version " + "already exist."); } catch (Exception ex) { throw new DatabaseProcessingException(ex);
EndpointProfile ep = endpointProfileDao.findByKeyHash(endpointKeyHash); if (ep == null) { throw new DatabaseProcessingException("Can't find endpoint profile by hash " + endpointKeyHash); throw new DatabaseProcessingException("Endpoint profile is not subscribed to this topic"); } catch (IOException ex) { LOG.error("Can't serialize notification body using schema. ", ex); throw new DatabaseProcessingException("Can't serialize notification body using schema: " + schemaId); throw new DatabaseProcessingException("Can't find notification schema by id " + schemaId);
} else { LOG.warn("Endpoint profile with key hash {} already exists.", keyHash); throw new DatabaseProcessingException("Can't save endpoint profile with existing key " + "hash.");
activatedUsername); } else { throw new DatabaseProcessingException("Incorrect old profile filters. " + "Profile schema id is empty."); profileNotification.setChangeNotificationDto(changeNotificationDto); } else { throw new DatabaseProcessingException("Can't activate profile filter.");
configurationDao.deactivateOldConfiguration(schemaId, groupId, activatedUsername); } else { throw new DatabaseProcessingException( "Incorrect old configuration. Configuration schema or endpoint group id is empty.");