Package org.eurekastreams.server.action.request.notification

Examples of org.eurekastreams.server.action.request.notification.SendPrebuiltNotificationRequest


                EventBus.getInstance().notifyObservers(
                        ShowNotificationEvent.getInstance("Notification destination must be an http or https URL"));
                return;
            }

            SendPrebuiltNotificationRequest rqst = new SendPrebuiltNotificationRequest();
            rqst.setHighPriority(highPriorityUi.getValue());
            rqst.setMessage(messageUi.getValue());

            rqst.setUrl(url);

            sendButton.setVisible(false);
            waitSpinner.setVisible(true);

            SendNotificationModel.getInstance().insert(rqst);
View Full Code Here


            }

            @Override
            public Serializable getParams()
            {
                return new SendPrebuiltNotificationRequest(true, RECIPIENT_ACCOUNT_ID, MESSAGE, URL);
            }

            @Override
            public String getActionId()
            {
View Full Code Here

            }

            @Override
            public Serializable getParams()
            {
                return new SendPrebuiltNotificationRequest(true, RECIPIENT_ACCOUNT_ID, message, url);
            }

            @Override
            public String getActionId()
            {
View Full Code Here

    private void runTest(final String message, final String url, final String... errorKeys)
    {
        try
        {

            Serializable params = new SendPrebuiltNotificationRequest(true, null, message, url);
            PrincipalActionContext ctx = TestContextCreator.createPrincipalActionContext(params, null);
            sut.validate(ctx);
        }
        catch (ValidationException ex)
        {
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    public void validate(final ActionContext inActionContext) throws ValidationException
    {
        SendPrebuiltNotificationRequest params = (SendPrebuiltNotificationRequest) inActionContext.getParams();
        ValidationException ve = new ValidationException();

        // message
        if (params.getMessage() == null || params.getMessage().isEmpty())
        {
            ve.addError("message", "Message must be provided.");
        }
        else if (params.getMessage().length() > maxMessageLength)
        {
            ve.addError("message", "Message must be no more than " + maxMessageLength + " characters.");
        }
        // TODO: Should we check content of message?

        // URL
        if (params.getUrl() != null && params.getUrl().length() > maxUrlLength)
        {
            ve.addError("url", "URL must be no more than " + maxUrlLength + " characters.");
        }
        // TODO: Should we check format of URL?

View Full Code Here

     * {@inheritDoc}
     */
    @Override
    public void validate(final ClientPrincipalActionContext inActionContext) throws ValidationException
    {
        SendPrebuiltNotificationRequest params = (SendPrebuiltNotificationRequest) inActionContext.getParams();
        ValidationException ve = new ValidationException();

        // insure valid recipient
        PersonModelView recipient = personMapper.execute(params.getRecipientAccountId());
        if (recipient == null)
        {
            ve.addError("recipientAccountId", "Unknown or missing recipient account id.");
        }
        else if (recipient.isAccountLocked())
        {
            ve.addError("recipientAccountId", "Cannot send notifications to locked users.");
        }
        else
        {
            inActionContext.getState().put("recipient", recipient);
        }

        // message
        if (params.getMessage() == null || params.getMessage().isEmpty())
        {
            ve.addError("message", "Message must be provided.");
        }
        else if (params.getMessage().length() > maxMessageLength)
        {
            ve.addError("message", "Message must be no more than " + maxMessageLength + " characters.");
        }
        // TODO: Should we check content of message?

        // URL
        if (params.getUrl() != null && params.getUrl().length() > maxUrlLength)
        {
            ve.addError("url", "URL must be no more than " + maxUrlLength + " characters.");
        }
        // TODO: Should we check format of URL?

View Full Code Here

        long unlockedPersonCount = (Long) getEntityManager().createQuery(
                "SELECT COUNT(*) FROM Person WHERE accountLocked=false").getSingleResult();
        assertTrue("Test is meaningless with no unlocked users.", unlockedPersonCount > 0);

        // test
        sut.execute(new SendPrebuiltNotificationRequest(true, null, MESSAGE, URL));

        // verify
        List results = getEntityManager().createQuery("FROM InAppNotification WHERE id > :id")
                .setParameter("id", maxId).getResultList();
        assertEquals(unlockedPersonCount, results.size());
View Full Code Here

    public Serializable execute(final TaskHandlerActionContext<ClientPrincipalActionContext> inWrapperContext)
    {
        final ClientPrincipalActionContext actionContext = inWrapperContext.getActionContext();

        String clientId = actionContext.getClientUniqueId();
        SendPrebuiltNotificationRequest params = (SendPrebuiltNotificationRequest) actionContext.getParams();

        PersonModelView recipient = (PersonModelView) actionContext.getState().get("recipient");
        long recipientId = recipient != null ? recipient.getId() : personIdMapper.execute(params
                .getRecipientAccountId());

        PrebuiltNotificationsRequest notifRequest = new PrebuiltNotificationsRequest(RequestType.EXTERNAL_PRE_BUILT,
                params.isHighPriority(), clientId, recipientId, params.getMessage(), params.getUrl());
        inWrapperContext.getUserActionRequests().add(
                new UserActionRequest(CreateNotificationsRequest.ACTION_NAME, null, notifRequest));

        return null;
    }
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.action.request.notification.SendPrebuiltNotificationRequest

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.