Package org.jboss.aerogear.simplepush.server.datastore.model

Examples of org.jboss.aerogear.simplepush.server.datastore.model.ChannelDTO


            @Override
            public ChannelDTO perform(EntityManager em) {
                return em.find(ChannelDTO.class, channelId);
            }
        };
        final ChannelDTO dto = jpaExecutor.execute(findChannel);
        if (dto == null) {
            throw new ChannelNotFoundException("No Channel for [" + channelId + "] was found", channelId);
        }
        return new DefaultChannel(dto.getUserAgent().getUaid(), dto.getChannelId(), dto.getVersion(), dto.getEndpointToken());
    }
View Full Code Here


                select.setParameter("endpointToken", endpointToken);
                final List<ChannelDTO> resultList = select.getResultList();
                if (resultList.isEmpty()) {
                    return null;
                }
                final ChannelDTO channelDTO = resultList.get(0);
                if (channelDTO != null) {
                    if (version > channelDTO.getVersion()) {
                        channelDTO.setVersion(version);
                        em.merge(channelDTO);
                    } else {
                        throw new VersionException("New version [" + version + "] must be greater than current version [" + channelDTO.getVersion() + "]");
                    }
                }
                return channelDTO;
            }
        };
        try {
            final ChannelDTO channelDto = jpaExecutor.execute(updateVersion);
            if (channelDto == null) {
                throw new ChannelNotFoundException("No Channel for endpointToken [" + endpointToken + "] was found", endpointToken);
            }
            return channelDto.getChannelId();
        } catch (final JpaException e) {
            final Throwable cause = e.getCause();
            if (cause instanceof VersionException) {
                throw (VersionException) cause;
            }
View Full Code Here

    @Override
    public String saveUnacknowledged(final String channelId, final long version) throws ChannelNotFoundException {
        final JpaOperation<String> saveAcks = new JpaOperation<String>() {
            @Override
            public String perform(final EntityManager em) {
                final ChannelDTO channel = em.find(ChannelDTO.class, channelId);
                final UserAgentDTO userAgent = channel.getUserAgent();
                final Set<AckDTO> dtos = new HashSet<AckDTO>();
                dtos.add(new AckDTO(userAgent, channel.getChannelId(), version));
                userAgent.setAcks(dtos);
                em.merge(userAgent);
                return userAgent.getUaid();
            }
        };
View Full Code Here

        final String channelId = UUID.randomUUID().toString();
        final String uaid = UUIDUtil.newUAID();
        persist(uaid, channelId, 10, "/endpoint/" + channelId);

        entityManager.getTransaction().begin();
        final ChannelDTO channel = entityManager.find(ChannelDTO.class, channelId);
        assertThat(channel.getChannelId(), equalTo(channelId));
        assertThat(channel.getVersion(), equalTo(10L));
        entityManager.getTransaction().commit();
    }
View Full Code Here

        entityManager.getTransaction().begin();
        entityManager.remove(userAgent);
        entityManager.getTransaction().commit();
        final UserAgentDTO ua = entityManager.find(UserAgentDTO.class, userAgent.getUaid());
        assertThat(ua, is(nullValue()));
        final ChannelDTO channel = entityManager.find(ChannelDTO.class, channelId);
        assertThat(channel, is(nullValue()));
    }
View Full Code Here

TOP

Related Classes of org.jboss.aerogear.simplepush.server.datastore.model.ChannelDTO

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.