// first see if the bundle exists or not; if not, create one
BundleCriteria criteria = new BundleCriteria();
criteria.setStrict(true);
criteria.addFilterBundleTypeId(Integer.valueOf(bundleTypeId));
criteria.addFilterName(bundleName);
criteria.clearPaging(); //disable paging as the code assumes all the results will be returned.
PageList<Bundle> bundles = findBundlesByCriteria(subject, criteria);
Bundle bundle;
if (bundles.getTotalSize() == 0) {
bundle = createBundle(subject, bundleName, bundleDescription, bundleTypeId, bundleGroupIds);