if (dockerHostId != null) {
name.append("-").append(dockerHostId);
}
}
final String locationName = name.toString();
DockerInfrastructure infrastructure = (DockerInfrastructure) managementContext.getEntityManager().getEntity(infrastructureId);
if (dockerHostId == null) {
LocationSpec<DockerLocation> locationSpec = LocationSpec.create(DockerLocation.class)
.configure(flags)
.configure(DynamicLocation.OWNER, infrastructure)
.configure(LocationInternal.NAMED_SPEC_NAME, locationName)
.displayName(displayName);
return managementContext.getLocationManager().createLocation(locationSpec);
} else {
DockerHost dockerHost = (DockerHost) managementContext.getEntityManager().getEntity(dockerHostId);
LocationSpec<DockerHostLocation> locationSpec = LocationSpec.create(DockerHostLocation.class)
.parent(infrastructure.getDynamicLocation())
.configure(flags)
.configure(DynamicLocation.OWNER, dockerHost)
.configure(LocationInternal.NAMED_SPEC_NAME, locationName)
.displayName(displayName);
return managementContext.getLocationManager().createLocation(locationSpec);