throw(ex);
} catch (Exception ex) {
log.error(ex);
if (session.isOpen() && session.getTransaction().isActive()) session.getTransaction().rollback();
throw new StoreInternalException(ex, "Cannot access database.");
}
// run XRD through the CREATE pipeline
XRD newXRD;
try {
if (createPipeline != null) {
newXRD = createPipeline.execute(this, xrd, null, parentAuthority, subSegmentName, authority, true);
} else {
newXRD = xrd;
}
} catch (Exception ex) {
log.error(ex);
if (session.isOpen() && session.getTransaction().isActive()) session.getTransaction().rollback();
throw new StoreInternalException(ex, "Cannot execute pipeline.");
}
// start database session
session = this.getSessionFactory().getCurrentSession();
// set XRD
try {
session.beginTransaction();
reattach(session, authority);
authority.setXrd(newXRD);
session.update(authority);
session.flush();
session.getTransaction().commit();
} catch (Exception ex) {
log.error(ex);
if (session.isOpen() && session.getTransaction().isActive()) session.getTransaction().rollback();
throw new StoreInternalException(ex, "Cannot access database.");
}
// start database session
session = this.getSessionFactory().getCurrentSession();
// create subsegment with this authority
DbSubSegment subSegment;
try {
session.beginTransaction();
reattach(session, parentAuthority);
reattach(session, authority);
subSegment = new DbSubSegment();
subSegment.setParent((DbAuthority) parentAuthority);
subSegment.setName(subSegmentName);
subSegment.setAuthority(authority);
((DbAuthority) parentAuthority).getChildren().add(subSegment);
authority.getSubSegments().add(subSegment);
session.save(subSegment);
session.flush();
session.refresh(subSegment);
session.getTransaction().commit();
} catch (Exception ex) {
log.error(ex);
if (session.isOpen() && session.getTransaction().isActive()) session.getTransaction().rollback();
throw new StoreInternalException(ex, "Cannot access database.");
}
// done
log.trace("Done.");