Example #1
0
	def sendObject(self, dest_repo, export_context='migrate', overwrite=False, show_progress=True, refresh_remote=True):		

		# use syncutil
		print "sending object..."
		result = syncutil.sync_object(
			self.ohandle,
			fedoraHandles.remoteRepo(dest_repo),
			export_context=export_context,
			overwrite=overwrite,
			show_progress=show_progress)

		# refresh object in remote repo (requires refreshObject() method in remote Ouroboros)
		if refresh_remote:
			print "refreshing remote object in remote repository"
			refresh_remote_url = '%s/tasks/objectRefresh/%s' % (localConfig.REMOTE_REPOSITORIES[dest_repo]['OUROBOROS_BASE_URL'], self.pid)
			print refresh_remote_url
			r = requests.get( refresh_remote_url )
			print r.content
		else:
			print "skipping remote refresh"
Example #2
0
def getRemoteObject(repo, PID, index=True, skip_constituents=False):
	
	sync_list = [PID]
	
	# remote repo
	dest_repo_handle = fedoraHandles.remoteRepo(repo)
	
	# check if remote object has constituent parts
	if not skip_constituents:
		constituents = dest_repo_handle.risearch.spo_search(None,"fedora-rels-ext:isConstituentOf","info:fedora/%s" % PID)
		print len(constituents)
		if len(constituents) > 0:
			for constituent in constituents:
				# add to sync list
				print "adding %s to sync list" % constituent[0]
				sync_list.append(constituent[0])
			
	# sync objects 
	for i,pid in enumerate(sync_list):
		print "retrieving %s, %d/%d..." % (pid,i,len(sync_list))
		print eulfedora.syncutil.sync_object(dest_repo_handle.get_object(pid), fedora_handle, show_progress=False, export_context='archive')
Example #3
0
	def sendObject(self, 
		dest_repo, 
		export_context='archive', 
		overwrite=False, 
		show_progress=False, 
		refresh_remote=True, 
		omit_checksums=True, 
		skip_constituents=False, 
		refresh_remote_constituents=False):

		'''
		dest_repo = string key from localConfig for remote repositories credentials
		'''

		# handle string or eulfedora handle
		print dest_repo,type(dest_repo)
		if type(dest_repo) == str or type(dest_repo) == unicode:
			dest_repo_handle = fedoraHandles.remoteRepo(dest_repo)
		elif type(dest_repo) == eulfedora.server.Repository:
			dest_repo_handle = dest_repo
		else:
			print "destination eulfedora not found, try again"
			return False
			
		# generate list of objects to send
		'''
		This is important if objects have constituent objects, need to send them too
		'''
		
		# init list
		sync_list = [self.pid]
		
		# if not skipping constituents, check for them
		if not skip_constituents:
			constituents = fedora_handle.risearch.spo_search(None, "fedora-rels-ext:isConstituentOf", "info:fedora/%s" % self.pid)
			if len(constituents) > 0:
				for constituent in constituents:
					# add to sync list
					print "adding %s to sync list" % constituent[0]
					sync_list.append(constituent[0].split("/")[-1])
					
		# iterate and send
		for i,pid in enumerate(sync_list):
			print "sending %s, %d/%d..." % (pid, i+1, len(sync_list))

			# remove IIIF manifest
			print "removing IIIF Manifest before transfer"			
			fedora_handle.api.purgeDatastream(self.ohandle,'IIIF_MANIFEST')

			# use syncutil
			result = syncutil.sync_object(
				fedora_handle.get_object(pid),
				dest_repo_handle,
				export_context=export_context,
				overwrite=overwrite,
				show_progress=show_progress,
				omit_checksums=omit_checksums)
				
		# refresh remote objects
		# refresh object in remote repo (requires refreshObject() method in remote Ouroboros)
		if type(dest_repo) == str or type(dest_repo) == unicode:
			
			# indexing both
			if refresh_remote and refresh_remote_constituents:
				for i,pid in enumerate(sync_list):
					print "refreshing remote object in remote repository %s, %d/%d..." % (pid, i+1, len(sync_list))
					refresh_remote_url = '%s/tasks/objectRefresh/%s' % (localConfig.REMOTE_REPOSITORIES[dest_repo]['OUROBOROS_BASE_URL'], pid)
					print refresh_remote_url
					r = requests.get( refresh_remote_url )
					print r.content
			
			# index self pid only
			elif refresh_remote and not refresh_remote_constituents:
				print "refreshing remote object in remote repository %s, 1/1..." % (self.pid)
				refresh_remote_url = '%s/tasks/objectRefresh/%s' % (localConfig.REMOTE_REPOSITORIES[dest_repo]['OUROBOROS_BASE_URL'], self.pid)
				print refresh_remote_url
				r = requests.get( refresh_remote_url )
				print r.content
				
			else:
				print "skipping remote refresh"
				
		# cannot refresh
		else:
			print "Cannot refresh remote.  It is likely you passed an Eulfedora Repository object.  To refresh remote, please provide string of remote repository that aligns with localConfig"