/** * Checks that object reference is not null, throws {@link ValidationException} in the case of * null {@code object} with given {@code message}. */ private static void checkNotNull(Object object, String message) throws ValidationException { if (object == null) { throw new ValidationException(message); } }
private Workspace doUpdate(String id, Workspace update) throws BadRequestException, ConflictException, NotFoundException, ServerException { try { return workspaceManager.updateWorkspace(id, update); } catch (ValidationException x) { throw new BadRequestException(x.getMessage()); } }
sharedPool.getExecutor()); } catch (ValidationException e) { LOG.error(e.getLocalizedMessage(), e); throw new ConflictException(e.getLocalizedMessage()); } catch (InfrastructureException e) { LOG.error(e.getLocalizedMessage(), e);
return asDtoWithLinksAndToken(workspace); } catch (ValidationException x) { throw new BadRequestException(x.getMessage());
/** * Checks that expression is true, throws {@link ValidationException} otherwise. * * <p>Exception uses error message built from error message template and error message parameters. */ private static void check(boolean expression, String message) throws ValidationException { if (!expression) { throw new ValidationException(message); } } }
workspace = workspaceManager.createWorkspace(config, namespace, attributes); } catch (ValidationException x) { throw new BadRequestException(x.getMessage());
private static void checkArgument(boolean expression, String error) throws ValidationException { if (!expression) { throw new ValidationException(error); } }
/** * Validate stack object * * @param stack stack to validate * @throws BadRequestException if stack is not valid */ public void check(Stack stack) throws BadRequestException, ServerException, NotFoundException { if (stack == null) { throw new BadRequestException("Required non-null stack"); } if (stack.getName() == null || stack.getName().isEmpty()) { throw new BadRequestException("Required non-null and non-empty stack name"); } if (stack.getScope() == null || !stack.getScope().equals("general") && !stack.getScope().equals("advanced")) { throw new BadRequestException("Required non-null scope value: 'general' or 'advanced'"); } if (stack.getWorkspaceConfig() == null) { throw new BadRequestException("Workspace config required"); } try { wsValidator.validateConfig(stack.getWorkspaceConfig()); } catch (ValidationException x) { throw new BadRequestException(x.getMessage()); } } }
private void checkNotNull(Object object, String errorMessage) throws ValidationException { if (object == null) { throw new ValidationException(errorMessage); } }
private static void checkArgument(boolean expression, String error) throws ValidationException { if (!expression) { throw new ValidationException(error); } }
private static void checkArgument( boolean expression, String errorMessageTemplate, Object... errorMessageParams) throws ValidationException { if (!expression) { throw new ValidationException(format(errorMessageTemplate, errorMessageParams)); } } }
private static void checkNotNull( Object object, String errorMessageTemplate, Object... errorMessageParams) throws ValidationException { if (object == null) { throw new ValidationException(format(errorMessageTemplate, errorMessageParams)); } } }
private static void checkNotNull( Object object, String errorMessageTemplate, Object... errorMessageParams) throws ValidationException { if (object == null) { throw new ValidationException(format(errorMessageTemplate, errorMessageParams)); } } }
private static void checkArgument( boolean expression, String errorMessageTemplate, Object... errorMessageParams) throws ValidationException { if (!expression) { throw new ValidationException(format(errorMessageTemplate, errorMessageParams)); } } }
private static void checkNotNull( Object object, String errorMessageTemplate, Object... errorMessageParams) throws ValidationException { if (object == null) { throw new ValidationException(format(errorMessageTemplate, errorMessageParams)); } } }
/** * Checks that expression is true, throws {@link ValidationException} otherwise. * * <p>Exception uses error message built from error message template and error message parameters. */ private static void check(boolean expression, String fmt, Object... args) throws ValidationException { if (!expression) { throw new ValidationException(format(fmt, args)); } }
private void checkNotNull(Object object, String messageFmt, Object... messageArguments) throws ValidationException { if (object == null) { throw new ValidationException(format(messageFmt, messageArguments)); } } }
/** Parses link content into depends_on field representation - removes column and further chars */ private String getContainerFromLink(String link) throws ValidationException { String container = link; if (link != null) { String[] split = container.split(":"); if (split.length > 2) { throw new ValidationException(format("Service link '%s' is invalid", link)); } container = split[0]; } return container; }
private void validateLongAttribute( String attributeName, String attributeValue, String machineName) throws ValidationException { if (attributeValue != null) { try { Long.parseLong(attributeValue); } catch (NumberFormatException e) { throw new ValidationException( format( "Value '%s' of attribute '%s' in machine '%s' is illegal", attributeValue, attributeName, machineName)); } } }
@VisibleForTesting ComposeRecipe doParse(String recipeContent) throws ValidationException { ComposeRecipe composeRecipe; try { composeRecipe = YAML_PARSER.readValue(recipeContent, ComposeRecipe.class); } catch (IOException e) { throw new ValidationException( "Parsing of environment configuration failed. " + e.getLocalizedMessage()); } return composeRecipe; }