def reset(request, name): try: install_builtin_config(name, force=True) messages.info(request, 'Configuration "%s" was reset' % name) except Exception: msg = 'Failed to reset processing config "%s".' % name logger.exception(msg) messages.error(request, msg) return redirect("components.administration.views_processing.list")
def setUp(self): self.client = Client() self.client.login(username='******', password='******') helpers.set_setting('dashboard_uuid', 'test-uuid') settings.SHARED_DIRECTORY = tempfile.gettempdir() self.config_path = os.path.join( settings.SHARED_DIRECTORY, 'sharedMicroServiceTasksConfigs/processingMCPConfigs/') if not os.path.exists(self.config_path): os.makedirs(self.config_path) install_builtin_config('default')
def created_shared_directory_structure(): dirs = ( "arrange", "completed", "completed/transfers", "currentlyProcessing", "DIPbackups", "failed", "rejected", "sharedMicroServiceTasksConfigs", "sharedMicroServiceTasksConfigs/createXmlEventsAssist", "sharedMicroServiceTasksConfigs/generateAIP", "sharedMicroServiceTasksConfigs/generateAIP/bagit", "sharedMicroServiceTasksConfigs/processingMCPConfigs", "sharedMicroServiceTasksConfigs/transcoder", "sharedMicroServiceTasksConfigs/transcoder/defaultIcons", "SIPbackups", "tmp", "watchedDirectories", "watchedDirectories/activeTransfers", "watchedDirectories/activeTransfers/baggitDirectory", "watchedDirectories/activeTransfers/baggitZippedDirectory", "watchedDirectories/activeTransfers/dataverseTransfer", "watchedDirectories/activeTransfers/Dspace", "watchedDirectories/activeTransfers/maildir", "watchedDirectories/activeTransfers/standardTransfer", "watchedDirectories/activeTransfers/TRIM", "watchedDirectories/approveNormalization", "watchedDirectories/approveSubmissionDocumentationIngest", "watchedDirectories/quarantined", "watchedDirectories/SIPCreation", "watchedDirectories/SIPCreation/completedTransfers", "watchedDirectories/SIPCreation/SIPsUnderConstruction", "watchedDirectories/storeAIP", "watchedDirectories/system", "watchedDirectories/system/autoProcessSIP", "watchedDirectories/system/autoRestructureForCompliance", "watchedDirectories/system/createAIC", "watchedDirectories/system/reingestAIP", "watchedDirectories/uploadDIP", "watchedDirectories/uploadedDIPs", "watchedDirectories/workFlowDecisions", "watchedDirectories/workFlowDecisions/compressionAIPDecisions", "watchedDirectories/workFlowDecisions/createDip", "watchedDirectories/workFlowDecisions/createTree", "watchedDirectories/workFlowDecisions/examineContentsChoice", "watchedDirectories/workFlowDecisions/extractPackagesChoice", "watchedDirectories/workFlowDecisions/metadataReminder", "watchedDirectories/workFlowDecisions/quarantineTransfer", "watchedDirectories/workFlowDecisions/selectFormatIDToolIngest", "watchedDirectories/workFlowDecisions/selectFormatIDToolTransfer", "www", "www/AIPsStore", "www/AIPsStore/transferBacklog", "www/AIPsStore/transferBacklog/arrange", "www/AIPsStore/transferBacklog/originals", "www/DIPsStore") for d in dirs: d = os.path.join(django_settings.SHARED_DIRECTORY, d) if os.path.isdir(d): continue logger.info('Creating directory: %s', d) os.makedirs(d, mode=0o770) # Populate processing configurations for config in processing.BUILTIN_CONFIGS: processing.install_builtin_config(config)
def processing_configuration(request, name): """ Return a processing configuration XML document given its name, i.e. where name is "default" the returned file will be "defaultProcessingMCP.xml" found in the standard processing configuration directory. """ config_path = os.path.join(helpers.processing_config_path(), '{}ProcessingMCP.xml'.format(name)) if request.method == 'DELETE': try: os.remove(config_path) return helpers.json_response({'success': True}) except OSError: msg = 'No such processing config "%s".' % name LOGGER.error(msg) return helpers.json_response({ "success": False, "error": msg }, status_code=404) else: accepted_types = request.META.get('HTTP_ACCEPT', '').lower() if accepted_types != '*/*' and 'xml' not in accepted_types: return django.http.HttpResponse(status=415) try: # Attempt to read the file with open(config_path, 'r') as f: content = f.read() except IOError: # The file didn't exist, so recreate it from the builtin config try: content = install_builtin_config(name) if content: LOGGER.info('Regenerated processing config "%s".' % name) else: msg = 'No such processing config "%s".' % name LOGGER.error(msg) return helpers.json_response( { "success": False, "error": msg }, status_code=404) except Exception: msg = 'Failed to reset processing config "%s".' % name LOGGER.exception(msg) return helpers.json_response({ "success": False, "error": msg }, status_code=500) return django.http.HttpResponse(content, content_type='text/xml')