// check if the parent authority overrides the CREATE pipeline. if not, use the default.
ServerConfig serverConfig = ServerConfigFactory.getSingleton();
PipelineRegistry pipelineRegistry = (serverConfig == null) ? null : serverConfig.getPipelineRegistry();
Pipeline createPipeline = null;
String pipelineName = this.getAuthorityAttributes(parentAuthority).get(Pipeline.ATTRIBUTE_OVERRIDE_CREATE_PIPELINE);
if (pipelineRegistry != null && pipelineName != null) createPipeline = pipelineRegistry.getPipelineByName(pipelineName);
if (pipelineRegistry != null && createPipeline == null) createPipeline = pipelineRegistry.getDefaultCreatePipeline();
// start database session
Session session = this.getSessionFactory().getCurrentSession();
// create authority
DbAuthority authority;
try {
session.beginTransaction();
reattach(session, parentAuthority);
if (DbSubSegment.ByParentAndName(session, (DbAuthority) parentAuthority, subSegmentName) != null) {
throw new StoreDuplicateEntryException("Subsegment exists already.");
}
authority = new DbAuthority();
session.save(authority);
session.flush();
session.refresh(authority);
session.getTransaction().commit();
} catch (StoreException ex) {
log.error(ex);
if (session.isOpen() && session.getTransaction().isActive()) session.getTransaction().rollback();
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) {