use of io.joynr.messaging.bounceproxy.controller.directory.jdbc.entities.BounceProxyEntity in project joynr by bmwcarit.
the class BounceProxyDatabase method getBounceProxyStatusInformation.
@Override
public List<BounceProxyStatusInformation> getBounceProxyStatusInformation() {
logger.trace("getBounceProxyStatusInformation()");
List<BounceProxyStatusInformation> result = new LinkedList<BounceProxyStatusInformation>();
for (BounceProxyEntity bp : getBounceProxyEntityList()) {
result.add(bp.convertToBounceProxyRecord());
}
logger.debug("found {} bounce proxies", result.size());
return result;
}
use of io.joynr.messaging.bounceproxy.controller.directory.jdbc.entities.BounceProxyEntity in project joynr by bmwcarit.
the class BounceProxyDatabase method getBounceProxy.
@Override
public BounceProxyRecord getBounceProxy(String bpId) throws IllegalArgumentException {
logger.trace("getBounceProxy(bpid={})", bpId);
EntityManager em = emf.createEntityManager();
BounceProxyEntity bounceProxyEntity = em.find(BounceProxyEntity.class, bpId);
if (bounceProxyEntity == null) {
logger.error("No bounce proxy with ID {} in bounce proxy database", bpId);
throw new IllegalArgumentException("No bounce proxy with ID '" + bpId + "' in bounce proxy database");
}
return bounceProxyEntity.convertToBounceProxyRecord();
}
use of io.joynr.messaging.bounceproxy.controller.directory.jdbc.entities.BounceProxyEntity in project joynr by bmwcarit.
the class BounceProxyDatabase method containsBounceProxy.
@Override
public boolean containsBounceProxy(String bpId) {
logger.trace("containsBounceProxy(bpid={})", bpId);
EntityManager em = emf.createEntityManager();
BounceProxyEntity bounceProxyEntity = em.find(BounceProxyEntity.class, bpId);
return bounceProxyEntity != null;
}
use of io.joynr.messaging.bounceproxy.controller.directory.jdbc.entities.BounceProxyEntity in project joynr by bmwcarit.
the class BounceProxyDatabase method updateChannelAssignment.
@Override
public void updateChannelAssignment(String ccid, BounceProxyInformation bpInfo) throws IllegalArgumentException {
logger.trace("updateChannelAssignment(ccid={}, bpId={})", ccid, bpInfo.getId());
EntityManager em = emf.createEntityManager();
EntityTransaction tx = em.getTransaction();
try {
tx.begin();
BounceProxyEntity bpEntity = em.find(BounceProxyEntity.class, bpInfo.getId());
if (bpEntity == null) {
logger.error("No bounce proxy with ID {} registered", bpInfo.getId());
throw new IllegalArgumentException("No bounce proxy with ID '" + bpInfo.getId() + "' registered");
}
ChannelEntity channelEntity = em.find(ChannelEntity.class, ccid);
if (channelEntity == null) {
logger.error("No channel with ID {} was registered before.", ccid);
throw new IllegalArgumentException("No channel with ID '" + ccid + "' was registered before.");
}
// TODO what to do if channel with the same ID is added, but
// different other properties?
bpEntity.addChannel(channelEntity);
em.merge(bpEntity);
tx.commit();
} catch (RuntimeException ex) {
logger.error("Channel assignment could not be persisted. error: {}", ex.getMessage());
if (tx != null && tx.isActive())
tx.rollback();
throw ex;
}
}
use of io.joynr.messaging.bounceproxy.controller.directory.jdbc.entities.BounceProxyEntity in project joynr by bmwcarit.
the class BounceProxyDatabase method addBounceProxy.
@Override
public void addBounceProxy(ControlledBounceProxyInformation bpInfo) throws IllegalArgumentException {
logger.trace("addBounceProxy(bpid={})", bpInfo.getId());
BounceProxyRecord record = new BounceProxyRecord(bpInfo);
record.setFreshness(timestampProvider.getCurrentTime());
BounceProxyEntity bpEntity = new BounceProxyEntity(record);
EntityManager em = emf.createEntityManager();
EntityTransaction tx = em.getTransaction();
try {
tx.begin();
em.persist(bpEntity);
tx.commit();
} catch (RuntimeException ex) {
logger.error("Bounce proxy {} could not be persisted. error: {}", bpInfo.getId(), ex.getMessage());
if (tx != null && tx.isActive())
tx.rollback();
throw ex;
}
}
Aggregations