def poll(self, path, sa=None): for entry in os.listdir(path): subpath = os.path.join(path, entry) if os.path.isfile(subpath): continue objid = os.path.basename(subpath) if InformationPackage.objects.filter( object_identifier_value=objid).exists(): logger.debug( 'Information package with object identifier value "{}" already exists' .format(objid)) continue if not stable_path(subpath): continue sa = SubmissionAgreement.objects.get(name=sa) if sa.profile_workflow is None: logger.debug('No workflow profile in SA, skipping') continue # storage_policy_name = 'default' # try: # storage_policy = StoragePolicy.objects.get(policy_name=storage_policy_name) # except StoragePolicy.DoesNotExist: # logger.exception('Storage policy "{}" not found'.format(storage_policy_name)) # raise org = Group.objects.get(name='Default') role = 'Administrator' responsible = GroupMember.objects.filter( roles__codename=role, group=org).get().member.django_user with transaction.atomic(): ip = InformationPackage.objects.create( object_identifier_value=objid, object_path=subpath, package_type=InformationPackage.SIP, submission_agreement=sa, state='Prepared', responsible=responsible, ) org.add_object(ip) sa.lock_to_information_package(ip, responsible) for profile_ip in ProfileIP.objects.filter(ip=ip).iterator(): try: profile_ip.clean() except ValidationError as e: raise exceptions.ParseError( '%s: %s' % (profile_ip.profile.name, str(e))) profile_ip.lock(responsible) yield ip
def poll(self, path, sa=None): for entry in os.listdir(path): subpath = os.path.join(path, entry) if os.path.isfile(subpath): continue objid = os.path.basename(subpath) if InformationPackage.objects.filter( object_identifier_value=objid).exists(): logger.debug( 'Information package with object identifier value "{}" already exists' .format(objid)) continue if not stable_path(subpath): continue sa = SubmissionAgreement.objects.get(name=sa) if sa.profile_workflow is None: logger.debug('No workflow profile in SA, skipping') continue storage_policy_name = 'default' try: storage_policy = StoragePolicy.objects.get( policy_name=storage_policy_name) except StoragePolicy.DoesNotExist: logger.exception('Storage policy "{}" not found'.format( storage_policy_name)) raise org = Group.objects.get(name='Default') role = 'admin' responsible = GroupMember.objects.filter( roles__codename=role, group=org).get().member.django_user with transaction.atomic(): ip = InformationPackage.objects.create( object_identifier_value=objid, object_path=subpath, package_type=InformationPackage.SIP, submission_agreement=sa, submission_agreement_locked=True, state='Prepared', responsible=responsible, policy=storage_policy, ) ip.create_profile_rels(p_types, responsible) org.add_object(ip) yield ip
def poll(self, path, sa=None): for entry in os.listdir(path): subpath = os.path.join(path, entry) if os.path.isfile(subpath): continue objid = os.path.basename(subpath) if InformationPackage.objects.filter( object_identifier_value=objid).exists(): logger.debug( u'Information package with object identifier value "{}" already exists' .format(objid)) continue if not stable_path(subpath): continue sa = SubmissionAgreement.objects.get(name=sa) if sa.profile_workflow is None: logger.debug(u'No workflow profile in SA, skipping') continue if proj not in sa.profile_workflow.specification: logger.debug( u'No workflow specified in {} for current project {}, skipping' .format(sa.profile_workflow, proj)) continue org = Group.objects.get(name='Default') role = 'admin' responsible = GroupMember.objects.filter( roles__codename=role, group=org).get().member.django_user ip = InformationPackage.objects.create( object_identifier_value=objid, object_path=subpath, package_type=InformationPackage.SIP, submission_agreement=sa, submission_agreement_locked=True, state='Prepared', responsible=responsible, ) ip.create_profile_rels(p_types, responsible) org.add_object(ip) yield ip
def poll(self, path, sa=None): for entry in os.listdir(path): subpath = os.path.join(path, entry) if os.path.isdir(subpath): continue entryname, entryext = os.path.splitext(entry) entryext = entryext[1:] if entryext != 'tar': continue objid = os.path.basename(entryname) if InformationPackage.objects.filter(object_identifier_value=objid).exists(): logger.debug(u'Information package with object identifier value "{}" already exists'.format(objid)) continue if not stable_path(subpath): continue xmlfile = os.path.splitext(subpath)[0] + '.xml' if sa is None: logger.info(u'No SA specified, get from submit description instead') tree = etree.parse(xmlfile) root = tree.getroot() altrecordids = get_altrecordids(root) sa_id = altrecordids['SUBMISSIONAGREEMENT'][0] logger.info(u'Found SA in submit description: {}'.format(sa_id)) sa = SubmissionAgreement.objects.get(pk=sa_id) else: logger.info(u'Using specified sa: {}'.format(sa)) sa = SubmissionAgreement.objects.get(name=sa) if sa.profile_workflow is None: logger.debug(u'No workflow profile in SA, skipping') continue if proj not in sa.profile_workflow.specification: logger.debug( 'No workflow specified in {} for current project {}, skipping'.format( sa.profile_workflow, proj ) ) continue org = Group.objects.get(name='Default') role = 'admin' responsible = GroupMember.objects.filter(roles__codename=role, group=org).get().member.django_user ip = InformationPackage.objects.create( object_identifier_value=objid, sip_objid=objid, object_path=subpath, package_type=InformationPackage.AIP, submission_agreement=sa, submission_agreement_locked=True, state='Prepared', responsible=responsible, package_mets_path=xmlfile, ) ip.create_profile_rels(p_types, responsible) org.add_object(ip) yield ip
def poll(self, path, sa=None): for entry in os.listdir(path): subpath = os.path.join(path, entry) if os.path.isdir(subpath): continue entryname, entryext = os.path.splitext(entry) entryext = entryext[1:] if entryext != 'tar': continue objid = os.path.basename(entryname) if InformationPackage.objects.filter( object_identifier_value=objid).exists(): logger.debug( u'Information package with object identifier value "{}" already exists' .format(objid)) continue if not stable_path(subpath): continue xmlfile = os.path.splitext(subpath)[0] + '.xml' if sa is None: logger.info( u'No SA specified, get from submit description instead') tree = etree.parse(xmlfile) root = tree.getroot() altrecordids = get_altrecordids(root) sa_id = altrecordids['SUBMISSIONAGREEMENT'][0] logger.info( u'Found SA in submit description: {}'.format(sa_id)) sa = SubmissionAgreement.objects.get(pk=sa_id) else: logger.info(u'Using specified sa: {}'.format(sa)) sa = SubmissionAgreement.objects.get(name=sa) if sa.profile_workflow is None: logger.debug(u'No workflow profile in SA, skipping') continue if proj not in sa.profile_workflow.specification: logger.debug( 'No workflow specified in {} for current project {}, skipping' .format(sa.profile_workflow, proj)) continue org = Group.objects.get(name='Default') role = 'admin' responsible = GroupMember.objects.filter( roles__codename=role, group=org).get().member.django_user ip = InformationPackage.objects.create( object_identifier_value=objid, sip_objid=objid, object_path=subpath, package_type=InformationPackage.AIP, submission_agreement=sa, submission_agreement_locked=True, state='Prepared', responsible=responsible, package_mets_path=xmlfile, ) ip.create_profile_rels(p_types, responsible) org.add_object(ip) yield ip