Package org.eurekastreams.commons.exceptions

Examples of org.eurekastreams.commons.exceptions.ValidationException


    {
        // insure the message has a From address
        Address[] addresses = message.getFrom();
        if (addresses == null || addresses.length != 1 || addresses[0] == null)
        {
            throw new ValidationException("Message must contain a single From address.");
        }
        return ((InternetAddress) addresses[0]).getAddress();
    }
View Full Code Here


            if (noReplyFound)
            {
                return null;
            }
        }
        throw new ValidationException("Cannot find To address for the system with an address tag.");
    }
View Full Code Here

                {
                    @Override
                    public Object invoke(final Invocation inInvocation) throws Throwable
                    {
                        ((List<Message>) inInvocation.getParameter(1)).add(responseMessage);
                        throw new ValidationException();
                    }
                });

                oneOf(inputFolder).copyMessages(with(IsArrayContaining.hasItemInArray(message)),
                        with(same(errorFolder)));
View Full Code Here

        }
        catch (Exception e)
        {
            if (e instanceof ValidationException)
            {
                ValidationException ve = (ValidationException) e;
                Set<Entry<String, String>> errors = ve.getErrors().entrySet();
                StringBuffer b = new StringBuffer();
                for (Entry<String, String> entry : errors)
                {
                    b.append(entry.getKey() + ":" + entry.getValue() + " ");
                }
View Full Code Here

        {
            valDecorator.validate(map, errors);
        }
        else if (!errors.isEmpty())
        {
            ValidationException ve = new ValidationException();
            for (String errorKey : errors.keySet())
            {
                ve.addError(errorKey, errors.get(errorKey));
            }
            throw ve;
        }
    }
View Full Code Here

            {
                query.accumulate(parts[i], URLDecoder.decode(parts[i + 1], "UTF-8"));
            }
            else
            {
                throw new ValidationException("Unable to parse request, unrecognized keyword: " + parts[i]);
            }
        }

        json.accumulate("query", query);
View Full Code Here

        try
        {
            InternetAddress emailAddr = new InternetAddress(emailAddress);
            if (!fullAddress(emailAddress))
            {
                throw new ValidationException("Please enter a properly formatted email address.");
            }

            if (!emailAddress.matches(validEmailRegex))
            {
                throw new ValidationException(inValidEmailError);
            }
        }
        catch (AddressException ex)
        {
            throw new ValidationException("Please provide a valid email address.");
        }
    }
View Full Code Here

    public void validate(final ServiceActionContext inActionContext) throws ValidationException
    {
        HashMap<String, Serializable> personData = (HashMap<String, Serializable>) inActionContext.getParams();

        ValidationHelper vHelper = new ValidationHelper();
        ValidationException ve = new ValidationException();

        String title = (String) vHelper.getAndCheckStringFieldExist(personData, PersonModelView.TITILE_KEY, true, ve);
        vHelper.stringMeetsRequirments(PersonModelView.TITILE_KEY, title, ve, "Title is required.",
                Person.MAX_TITLE_LENGTH, Person.TITLE_MESSAGE, null, null);

        String perferredName = (String) vHelper.getAndCheckStringFieldExist(personData,
                PersonModelView.PREFERREDNAME_KEY, true, ve);
        vHelper.stringMeetsRequirments(PersonModelView.PREFERREDNAME_KEY, perferredName, ve, PREFERREDNAME_MESSAGE,
                +DEFAULT_MAX_STRING_LENGTH, PREFERREDNAME_MESSAGE, "^[a-zA-Z\\'\\`\\ \\-]+$",
                "Display Name has invalid characters.");

        String description = (String) vHelper.getAndCheckStringFieldExist(personData, PersonModelView.DESCRIPTION_KEY,
                true, ve);
        vHelper.stringMeetsRequirments(PersonModelView.DESCRIPTION_KEY, description, ve, null,
                Person.MAX_JOB_DESCRIPTION_LENGTH, Person.JOB_DESCRIPTION_MESSAGE, null, null);

        String workNumber = (String) vHelper.getAndCheckStringFieldExist(personData, PersonModelView.WORKPHONE_KEY,
                true, ve);
        vHelper.stringMeetsRequirments(PersonModelView.WORKPHONE_KEY, workNumber, ve, null,
                Person.MAX_PHONE_NUMBER_LENGTH, Person.PHONE_NUMBER_MESSAGE, null, null);

        // TODO: Commented out to fix person update for 1.5, but future of phone numbers is uncertain right now as spec
        // shows us
        // collecting a number, but not displaying it,
        // Also, prod db shows more people have entered fax numbers than either of the other two numbers (which is
        // weird)
        // so we may want to wait before dropping all that data.
        // will submit to Lisa for clarification before deleteing this fuctionality all the way through the entity/db,
        // losing
        // a lot of data.

        // String cellNumber = (String) vHelper.getAndCheckStringFieldExist(personData, PersonModelView.CELLPHONE_KEY,
        // true, ve);
        // vHelper.stringMeetsRequirments(PersonModelView.CELLPHONE_KEY, cellNumber, ve, null,
        // Person.MAX_PHONE_NUMBER_LENGTH, Person.PHONE_NUMBER_MESSAGE, null, null);
        //
        // String faxNumber = (String) vHelper.getAndCheckStringFieldExist(personData, PersonModelView.FAX_KEY, true,
        // ve);
        // vHelper.stringMeetsRequirments(PersonModelView.FAX_KEY, faxNumber, ve, null, Person.MAX_PHONE_NUMBER_LENGTH,
        // Person.FAX_NUMBER_MESSAGE, null, null);

        String email = (String) vHelper.getAndCheckStringFieldExist(personData, PersonModelView.EMAIL_KEY, true, ve);
        if (vHelper.stringMeetsRequirments(PersonModelView.EMAIL_KEY, email, ve, EMAIL_REQUIRED_MESSAGE,
                DEFAULT_MAX_STRING_LENGTH, EMAIL_LENGTH_MESSAGE, null, null)
                && StringUtils.isNotBlank(email))
        {
            try
            {
                emailValidator.validate(email);
            }
            catch (ValidationException ex)
            {
                ve.addError(PersonModelView.EMAIL_KEY, ex.getMessage());
            }
        }

        String skills = (String) vHelper.getAndCheckStringFieldExist(personData, PersonModelView.SKILLS_KEY, true, ve);
        if (skills != null)
        {
            if (!vHelper.validBackgroundItems(skills))
            {
                ve.addError(PersonModelView.SKILLS_KEY, PersonModelView.SKILLS_MESSAGE);
            }
        }

        if (!ve.getErrors().isEmpty())
        {
            throw ve;
        }

    }
View Full Code Here

    {
        CommentDTO request = (CommentDTO) inActionContext.getParams();

        if (request == null)
        {
            throw new ValidationException("A comment must be provided.");
        }

        if (StringUtils.isBlank(request.getBody()))
        {
            throw new ValidationException("Comment must contain body content.");
        }
    }
View Full Code Here

    {
        CreateNotificationsRequest currentRequest = (CreateNotificationsRequest) inActionContext.getParams();
        NotificationTranslator translator = translators.get(currentRequest.getType());
        if (translator == null)
        {
            throw new ValidationException("Invalid notification type: " + currentRequest.getType());
        }
    }
View Full Code Here

TOP

Related Classes of org.eurekastreams.commons.exceptions.ValidationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.