use of io.joynr.messaging.bounceproxy.controller.directory.jdbc.entities.BounceProxyInformationEntity in project joynr by bmwcarit.
the class ChannelDatabase method addChannel.
@Override
public void addChannel(Channel channel) {
logger.trace("add channel {}", channel);
EntityManager em = emf.createEntityManager();
EntityTransaction tx = em.getTransaction();
try {
tx.begin();
BounceProxyInformationEntity bpInfoEntity = em.find(BounceProxyInformationEntity.class, channel.getBounceProxy().getId());
if (bpInfoEntity == null) {
tx.rollback();
logger.error("No bounce proxy with ID {} registered for channel {}", channel.getBounceProxy().getId(), channel.getChannelId());
throw new IllegalArgumentException("No bounce proxy with ID '" + channel.getBounceProxy().getId() + "' registered for channel '" + channel.getChannelId() + "'");
}
ChannelEntity entity = new ChannelEntity(channel.getChannelId(), bpInfoEntity, channel.getLocation().toString());
em.persist(entity);
tx.commit();
} catch (RuntimeException ex) {
logger.error("Error persisting channel with ID {}: error: {}", channel.getChannelId(), ex.getMessage());
if (tx != null && tx.isActive())
tx.rollback();
throw ex;
}
}
Aggregations