private SecurityRoleEntity getSecurityRoleEntityByName(SecurityRoleKey securityRoleKey) { SecurityRoleEntity securityRoleEntity = securityRoleDao.getSecurityRoleByName(securityRoleKey.getSecurityRoleName()); if (securityRoleEntity == null) { throw new ObjectNotFoundException(String.format("Security role with name \"%s\" doesn't exist.", securityRoleKey.getSecurityRoleName())); } return securityRoleEntity; } }
/** * Gets a notification registration entity by its namespace and name, or throws an ObjectNotFoundException if not found. * * @param namespace The namespace of the notification registration * @param name The name of the notification registration * * @return The notification registration entity */ public NotificationRegistrationEntity getNotificationRegistration(String namespace, String name) { NotificationRegistrationEntity notificationRegistration = notificationRegistrationDao.getNotificationRegistration(namespace, name); if (notificationRegistration == null) { throw new ObjectNotFoundException("The notification registration with namespace \"" + namespace + "\" and name \"" + name + "\" was not found."); } return notificationRegistration; } }
@Test public void testExceptionNoArgConstructor() throws Exception { ObjectNotFoundException exception = new ObjectNotFoundException(); assertTrue(exception.getMessage() == null); }
@Test public void testExceptionNoArgConstructor() throws Exception { AlreadyExistsException exception = new AlreadyExistsException(); assertTrue(exception.getMessage() == null); }
@Test public void testAlreadyExists() throws Exception { validateErrorInformation(exceptionHandler.handleConflictException(new AlreadyExistsException(MESSAGE)), HttpStatus.CONFLICT); }
@Test public void testHandleOperationNotAllowedFound() throws Exception { validateErrorInformation(exceptionHandler.handleOperationNotAllowedException(new MethodNotAllowedException(MESSAGE)), HttpStatus.METHOD_NOT_ALLOWED); }
/** * Gets a notification registration entity by its namespace and name, or throws an ObjectNotFoundException if not found. * * @param namespace The namespace of the notification registration * @param name The name of the notification registration * * @return The notification registration entity */ public NotificationRegistrationEntity getNotificationRegistration(String namespace, String name) { NotificationRegistrationEntity notificationRegistration = notificationRegistrationDao.getNotificationRegistration(namespace, name); if (notificationRegistration == null) { throw new ObjectNotFoundException("The notification registration with namespace \"" + namespace + "\" and name \"" + name + "\" was not found."); } return notificationRegistration; } }
private SecurityRoleEntity getSecurityRoleEntityByName(SecurityRoleKey securityRoleKey) { SecurityRoleEntity securityRoleEntity = securityRoleDao.getSecurityRoleByName(securityRoleKey.getSecurityRoleName()); if (securityRoleEntity == null) { throw new ObjectNotFoundException(String.format("Security role with name \"%s\" doesn't exist.", securityRoleKey.getSecurityRoleName())); } return securityRoleEntity; } }
@Test public void testExceptionMessageConstructor() throws Exception { ObjectNotFoundException exception = new ObjectNotFoundException(TEST_MESSAGE_1); assertTrue(exception.getMessage().equals(TEST_MESSAGE_1)); }
@Test public void testExceptionMessageConstructor() throws Exception { AlreadyExistsException exception = new AlreadyExistsException(TEST_MESSAGE_1); assertTrue(exception.getMessage().equals(TEST_MESSAGE_1)); }
/** * Gets a storage platform entity by name. * * @param storagePlatformName the storage platform name. * * @return the retrieved storage platform. * @throws ObjectNotFoundException if the storage platform was not found. */ public StoragePlatformEntity getStoragePlatformEntity(String storagePlatformName) throws ObjectNotFoundException { // Get the associated storage platform and verify that it exists. StoragePlatformEntity storagePlatformEntity = storagePlatformDao.getStoragePlatformByName(storagePlatformName); if (storagePlatformEntity == null) { throw new ObjectNotFoundException("Storage platform with name \"" + storagePlatformName + "\" doesn't exist."); } return storagePlatformEntity; } }
/** * Gets a storage platform entity by name. * * @param storagePlatformName the storage platform name. * * @return the retrieved storage platform. * @throws ObjectNotFoundException if the storage platform was not found. */ public StoragePlatformEntity getStoragePlatformEntity(String storagePlatformName) throws ObjectNotFoundException { // Get the associated storage platform and verify that it exists. StoragePlatformEntity storagePlatformEntity = storagePlatformDao.getStoragePlatformByName(storagePlatformName); if (storagePlatformEntity == null) { throw new ObjectNotFoundException("Storage platform with name \"" + storagePlatformName + "\" doesn't exist."); } return storagePlatformEntity; } }
/** * Gets a security function entity and ensure it exists. * * @param securityFunctionName the security function name (case insensitive) * * @return the security function entity */ public SecurityFunctionEntity getSecurityFunctionEntity(String securityFunctionName) { SecurityFunctionEntity securityFunctionEntity = securityFunctionDao.getSecurityFunctionByName(securityFunctionName); if (securityFunctionEntity == null) { throw new ObjectNotFoundException(String.format("Security function with name \"%s\" doesn't exist.", securityFunctionName)); } return securityFunctionEntity; } }
/** * Gets a security role entity and ensure it exists. * * @param securityRoleName the security role name (case insensitive) * * @return the security role entity */ public SecurityRoleEntity getSecurityRoleEntity(String securityRoleName) { SecurityRoleEntity securityRoleEntity = securityRoleDao.getSecurityRoleByName(securityRoleName); if (securityRoleEntity == null) { throw new ObjectNotFoundException(String.format("Security role with name \"%s\" doesn't exist.", securityRoleName)); } return securityRoleEntity; } }
/** * Gets record retention type entity form retention type code * * @param retentionTypeCode retention type code * * @return the retention type entity */ public RetentionTypeEntity getRecordRetentionTypeEntity(String retentionTypeCode) { RetentionTypeEntity recordRetentionTypeEntity = retentionTypeDao.getRetentionTypeByCode(retentionTypeCode); if (recordRetentionTypeEntity == null) { throw new ObjectNotFoundException(String.format("Record retention type with code \"%s\" doesn't exist.", retentionTypeCode)); } return recordRetentionTypeEntity; } }
/** * Gets a message type entity by its code and ensure it exists. * * @param code the message type code (case insensitive) * * @return the message type entity */ public MessageTypeEntity getMessageTypeEntity(String code) { MessageTypeEntity messageTypeEntity = messageTypeDao.getMessageTypeByCode(code); if (messageTypeEntity == null) { throw new ObjectNotFoundException(String.format("Message type with code \"%s\" doesn't exist.", code)); } return messageTypeEntity; } }
/** * Gets a storage entity based on the storage name and makes sure that it exists. * * @param storageName the storage name (case insensitive) * * @return the storage entity * @throws ObjectNotFoundException if the storage entity doesn't exist */ public StorageEntity getStorageEntity(String storageName) throws ObjectNotFoundException { StorageEntity storageEntity = storageDao.getStorageByName(storageName); if (storageEntity == null) { throw new ObjectNotFoundException(String.format("Storage with name \"%s\" doesn't exist.", storageName)); } return storageEntity; }
/** * Gets a security role entity and ensure it exists. * * @param securityRoleName the security role name (case insensitive) * * @return the security role entity */ public SecurityRoleEntity getSecurityRoleEntity(String securityRoleName) { SecurityRoleEntity securityRoleEntity = securityRoleDao.getSecurityRoleByName(securityRoleName); if (securityRoleEntity == null) { throw new ObjectNotFoundException(String.format("Security role with name \"%s\" doesn't exist.", securityRoleName)); } return securityRoleEntity; } }
/** * Gets an external interface entity and ensure it exists. * * @param externalInterfaceName the external interface name (case insensitive) * * @return the external interface entity */ public ExternalInterfaceEntity getExternalInterfaceEntity(String externalInterfaceName) { ExternalInterfaceEntity externalInterfaceEntity = externalInterfaceDao.getExternalInterfaceByName(externalInterfaceName); if (externalInterfaceEntity == null) { throw new ObjectNotFoundException(String.format("External interface with name \"%s\" doesn't exist.", externalInterfaceName)); } return externalInterfaceEntity; } }
@Test public void testHandleNotFound() throws Exception { validateErrorInformation(exceptionHandler.handleNotFoundException(new ObjectNotFoundException(MESSAGE)), HttpStatus.NOT_FOUND); }