/** * This method validates <code>Object</code> object. If object is null than throw * <code>IncorrectParameterException</code> exception * * @param obj the obj * @param errorMessage the error message for exception */ public static void validateNotNull(Object obj, String errorMessage) { if (obj == null) { throw new IncorrectParameterException(errorMessage); } }
/** * This method validates <code>Object</code> object. If object is not null than throw * <code>IncorrectParameterException</code> exception * * @param obj the obj * @param errorMessage the error message for exception */ public static void validateNull(Object obj, String errorMessage) { if (obj != null) { throw new IncorrectParameterException(errorMessage); } }
/** * This method validate <code>String</code> string. If string is invalid than throw * <code>IncorrectParameterException</code> exception * * @param id the id * @param errorMessage the error message for exception */ public static void validateString(String id, String errorMessage) { if (id == null || id.isEmpty()) { throw new IncorrectParameterException(errorMessage); } }
/** * @param id the id. * @param errorMessage the error message for exception */ public static void validateSqlId(String id, String errorMessage) { try { Long.valueOf(id); } catch (NumberFormatException ex) { throw new IncorrectParameterException(errorMessage, ex); } }
private void validateFilterSchemaIds(String endpointProfileSchemaId, String serverProfileSchemaId) { if (isBlank(endpointProfileSchemaId) && isBlank(serverProfileSchemaId)) { throw new IncorrectParameterException("Both profile schema ids can't be empty"); } }
/** * This method validate <code>HasId</code> object. If object is invalid than throw * <code>IncorrectParameterException</code> exception * * @param hasId the hash id * @param errorMessage the error message for exception */ public static void validateObject(HasId hasId, String errorMessage) { if (!isValidObject(hasId)) { throw new IncorrectParameterException(errorMessage); } }
/** * This method validate <code>byte</code> array hash. If hash is invalid than throw * <code>IncorrectParameterException</code> exception * * @param hash the hash * @param errorMessage the error message for exception */ public static void validateHash(byte[] hash, String errorMessage) { if (!isValidHash(hash)) { throw new IncorrectParameterException(errorMessage); } }
/** * This method validate <code>String</code> id. If id is invalid than throw * <code>IncorrectParameterException</code> exception * * @param id the id * @param errorMessage the error message for exception */ public static void validateId(String id, String errorMessage) { if (!isValidId(id)) { throw new IncorrectParameterException(errorMessage); } }
/** * This method validate <code>HasId</code> object. If object is invalid than throw * <code>IncorrectParameterException</code> exception * * @param hasId the hash id * @param errorMessage the error message for exceptio */ public static void validateSqlObject(HasId hasId, String errorMessage) { if (!isValidSqlObject(hasId)) { throw new IncorrectParameterException(errorMessage); } } }
@Override public List<CtlSchemaMetaInfoDto> findSiblingsByFqnTenantIdAndApplicationId(String fqn, String tenantId, String applicationId) { if (isBlank(fqn)) { throw new IncorrectParameterException("Incorrect parameters for ctl schema request."); } LOG.debug("Find sibling ctl schemas by fqn {}, tenant id {} and application id {}", fqn, tenantId, applicationId); return convertDtoList(ctlSchemaMetaInfoDao.findSiblingsByFqnTenantIdAndApplicationId(fqn, tenantId, applicationId)); }
@Override public CTLSchemaDto findCtlSchemaByFqnAndVerAndTenantIdAndApplicationId(String fqn, Integer version, String tenantId, String applicationId) { if (isBlank(fqn) || version == null) { throw new IncorrectParameterException("Incorrect parameters for ctl schema request."); } LOG.debug("Find ctl schema by fqn {} version {}, tenant id {} and application id {}", fqn, version, tenantId, applicationId); return DaoUtil.getDto(ctlSchemaDao.findByFqnAndVerAndTenantIdAndApplicationId(fqn, version, tenantId, applicationId)); }
@Override public CTLSchemaDto findByMetaInfoIdAndVer(String metaInfoId, Integer version) { if (isBlank(metaInfoId) || version == null) { throw new IncorrectParameterException("Incorrect parameters for ctl schema request."); } LOG.debug("Find ctl schema by meta info id {} and version {}", metaInfoId, version); return DaoUtil.getDto(ctlSchemaDao.findByMetaInfoIdAndVer(metaInfoId, version)); }
@Override public List<ApplicationDto> findAppsByTenantId(String tenantId) { List<ApplicationDto> applicationDto; if (isValidSqlId(tenantId)) { LOG.debug("Find applications by tenant id [{}]", tenantId); applicationDto = convertDtoList(applicationDao.findByTenantId(tenantId)); } else { throw new IncorrectParameterException("Incorrect tenant id: " + tenantId); } return applicationDto; }
@Override public List<EventClassFamilyDto> findEventClassFamiliesByTenantId( String tenantId) { List<EventClassFamilyDto> eventClassFamilies; if (isValidSqlId(tenantId)) { LOG.debug("Find event class families by tenant id [{}]", tenantId); eventClassFamilies = convertDtoList(eventClassFamilyDao.findByTenantId(tenantId)); } else { throw new IncorrectParameterException("Incorrect tenant id: " + tenantId); } return eventClassFamilies; }
@Override public EventClassDto findEventClassById(String eventClassId) { if (isValidSqlId(eventClassId)) { LOG.debug("Find event class by id [{}] ", eventClassId); return getDto(eventClassDao.findById(eventClassId)); } else { throw new IncorrectParameterException("Incorrect event class id: " + eventClassId); } }
@Override public EventClassFamilyDto findEventClassFamilyByTenantIdAndName(String tenantId, String name) { if (isValidSqlId(tenantId)) { LOG.debug("Find event class family by tenant id [{}] and name {}", tenantId, name); return eventClassFamilyDao.findByTenantIdAndName(tenantId, name).toDto(); } else { throw new IncorrectParameterException("Incorrect tenant id: " + tenantId); } }
@Override public List<EventClassDto> findEventClassByTenantIdAndFqn(String tenantId, String fqn) { if (isValidSqlId(tenantId)) { LOG.debug("Find event class family by tenant id [{}] and fqn {}", tenantId, fqn); return convertDtoList(eventClassDao.findByTenantIdAndFqn(tenantId, fqn)); } else { throw new IncorrectParameterException("Incorrect tenant id: " + tenantId); } }
@Override public EventClassDto findEventClassByTenantIdAndFqnAndVersion(String tenantId, String fqn, int version) { if (isValidSqlId(tenantId)) { LOG.debug("Find event class family by tenant id [{}] and fqn {}", tenantId, fqn); return getDto(eventClassDao.findByTenantIdAndFqnAndVersion(tenantId, fqn, version)); } else { throw new IncorrectParameterException("Incorrect tenant id: " + tenantId); } }
@Override public List<ApplicationEventFamilyMapDto> findApplicationEventFamilyMapsByApplicationId( String applicationId) { List<ApplicationEventFamilyMapDto> eventFamilyMaps; if (isValidSqlId(applicationId)) { LOG.debug("Find application event family maps by applicationId id [{}]", applicationId); eventFamilyMaps = convertDtoList(applicationEventFamilyMapDao.findByApplicationId( applicationId)); } else { throw new IncorrectParameterException("Incorrect applicationId id: " + applicationId); } return eventFamilyMaps; }
private void validateNotificationSchemaObject(NotificationSchemaDto dto) { validateObject(dto, "Invalid notification schema object"); if (isBlank(dto.getApplicationId()) && !isValidId(dto.getApplicationId()) || dto.getType() == null) { throw new IncorrectParameterException( "Invalid notification schema object. Check type or applicationId."); } }