Package org.eurekastreams.commons.exceptions

Examples of org.eurekastreams.commons.exceptions.ValidationException


        if (!currentRequest.getTypeOfRelationshipForPeopleReturned().equals("self")
                && !currentRequest.getTypeOfRelationshipForPeopleReturned().equals("all")
                && !currentRequest.getTypeOfRelationshipForPeopleReturned().equals("friends"))
        {
            throw new ValidationException("Unsupported relationship type provided.");
        }
    }
View Full Code Here


            {
                JSONObject.fromObject(currentRequest.getGadgetUserPref());
            }
            catch (JSONException jex)
            {
                throw new ValidationException("Gadget User Prefs must be valid JSON format.");
            }
        }
    }
View Full Code Here

        DomainGroup group = findByIdDAO.execute(new FindByIdRequest("DomainGroup", ((Long) inActionContext.getParams())
                .longValue()));

        if (null == group)
        {
            throw new ValidationException("Attempt to delete group that is no longer present");
        }

    }
View Full Code Here

        PostSplitActivityAndCommentsRequest request = (PostSplitActivityAndCommentsRequest) inActionContext
                .getParams();

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

        if (StringUtils.isBlank(request.getText()))
        {
            throw new ValidationException("Request must provide text content.");
        }
    }
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    public void validate(final PrincipalActionContext inActionContext) throws ValidationException
    {
        ValidationException vex = new ValidationException();
        SetFollowingStatusRequest inRequest = (SetFollowingStatusRequest) inActionContext.getParams();

        if (!inRequest.getTargetEntityType().equals(EntityType.GROUP))
        {
            vex.addError("EntityType", "This action only supports following a group.");
        }

        DomainGroupModelView targetResult = domainGroupMapper.fetchUniqueResult(inRequest.getTargetUniqueId());

        if (targetResult == null)
        {
            vex.addError("FollowerAndTarget", "Target unique id must refer to valid entity.");
        }

        if (vex.getErrors().size() > 0)
        {
            throw vex;
        }
    }
View Full Code Here

    {
        PersonPagePropertiesDTO result = personPagePropertiesByIdMapper.execute(inActionContext.getPrincipal().getId());

        if (result.getTabDTOs().size() <= 1)
        {
            throw new ValidationException("Start page must have at least 1 tab.");
        }
    }
View Full Code Here

     * - The target zone index is consistent with the gadgets that are already in place.
     */
    @Override
    public void validate(final PrincipalActionContext inActionContext) throws ValidationException
    {
        ValidationException vex = new ValidationException();

        ReorderGadgetRequest request = (ReorderGadgetRequest) inActionContext.getParams();
        Long targetTabId = request.getCurrentTabId();
        Long gadgetId = request.getGadgetId();
        Integer targetZoneNumber = request.getTargetZoneNumber();
        Integer targetZoneIndex = request.getTargetZoneIndex();

        TabTemplate sourceTemplate = tabMapper.findByGadgetId(gadgetId);

        Tab destinationTab = tabMapper.findById(targetTabId);

        // Ensure that the destination tab exists.
        if (destinationTab == null)
        {
            vex.addError("invalidTab", "Destination zone does not exist.");
            throw vex;
        }

        TabTemplate destinationTemplate = destinationTab.getTemplate();
        Layout destinationLayout = destinationTemplate.getTabLayout();

        // Save the Source and Destination TabTemplate to state so they can be reused in execution.
        inActionContext.getState().put("destinationTemplate", destinationTemplate);
        inActionContext.getState().put("sourceTemplate", sourceTemplate);

        // Destination zone is within the valid number of destination zones.
        if (targetZoneNumber + 1 > destinationLayout.getNumberOfZones())
        {
            vex.addError("invalidZone", "ReorderGadgetAction told to move a gadget to a nonexistent zone.");
            throw vex;
        }

        // Ensure that the gadget to be moved exists.
        if (sourceTemplate == null)
        {
            vex.addError("invalidGadget", "Gadget to be moved is invalid.");
            throw vex;
        }

        // Create a map of the zonenumbers and a list of the corresponding zone indexes.
        HashMap<Integer, List<Integer>> gadgetZoneIndexes = new HashMap<Integer, List<Integer>>();
        for (Gadget currentGadget : destinationTemplate.getGadgets())
        {
            if (gadgetZoneIndexes.containsKey(currentGadget.getZoneNumber()))
            {
                gadgetZoneIndexes.get(currentGadget.getZoneNumber()).add(currentGadget.getZoneIndex());
            }
            else
            {
                ArrayList<Integer> currentZoneIndexes = new ArrayList<Integer>();
                currentZoneIndexes.add(currentGadget.getZoneIndex());
                gadgetZoneIndexes.put(currentGadget.getZoneNumber(), currentZoneIndexes);
            }
        }

        //Test the zone boundaries only if the target zone contains gadgets.
        if (gadgetZoneIndexes.containsKey(targetZoneNumber))
        {
            List<Integer> targetZoneIndexes = gadgetZoneIndexes.get(targetZoneNumber);
            Collections.sort(targetZoneIndexes);
            // Test the targetzoneindex to be sure it is within the range of the indexes in the target zone.
            // Test that the target zone index is not greater than the last position in the list of indexes
            // or less than the first position in the list of indexes.
            if (targetZoneIndex > targetZoneIndexes.get(targetZoneIndexes.size() - 1) + 1
                    || targetZoneIndex < targetZoneIndexes.get(0) - 1)
            {
                vex.addError("invalidZoneIndex",
                        "Destination zone index is outside of the acceptable bounds for the target zone index.");
                throw vex;
            }
        }
        //If the target zone number does not have any gadgets in it, then the index should always be 0.
        else if (targetZoneIndex != 0)
        {
            vex.addError("invalidZoneIndex",
                    "Destination zone index should be zero when moving to an empty zone.");
        }
    }
View Full Code Here

            id = (Long) inActionContext.getParams();

        }
        catch (ClassCastException ex)
        {
            throw new ValidationException("Unable to retreive information expects a Person Id.");
        }

        Person user = pMapper.execute(new FindByIdRequest("Person", id));
        if (user == null)
        {
            throw new ValidationException("Unable to retreive information Person does not exist.");
        }
    }
View Full Code Here

        {
            decorated.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

        }
        catch (InvalidStateException e)
        {
            log.error("Failed to persist Group", e);
            InvalidValue[] invalidValues = e.getInvalidValues();
            ValidationException validationException = new ValidationException();

            for (InvalidValue invalidValue : invalidValues)
            {
                validationException.addError(invalidValue.getPropertyName(), invalidValue.getMessage());
            }

            throw validationException;
        }
        catch (PersistenceException e)
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.