From d80a8ab3f4376ac58af86a8673c1bd8479012859 Mon Sep 17 00:00:00 2001 From: Arno Kaimbacher Date: Thu, 10 Jun 2021 11:53:45 +0200 Subject: [PATCH] - also update solr index in EditorController.php and DoiController.php - composer updates --- app/Http/Controllers/Publish/DoiController.php | 8 ++++++++ .../Controllers/Publish/EditorController.php | 18 +++++++++++------- composer.lock | 10 +++++----- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/Publish/DoiController.php b/app/Http/Controllers/Publish/DoiController.php index ecffa81..97c0ac4 100644 --- a/app/Http/Controllers/Publish/DoiController.php +++ b/app/Http/Controllers/Publish/DoiController.php @@ -11,6 +11,8 @@ use App\Models\Oai\OaiModelError; use App\Exceptions\OaiModelException; use Illuminate\Support\Facades\View; use App\Exceptions\GeneralException; +use App\Library\Search\SolariumAdapter; +use \Exception; class DoiController extends Controller { @@ -233,6 +235,12 @@ class DoiController extends Controller // $doi['status'] = "findable"; // $doi->save(); $doi->touch(); + try { + $service = new SolariumAdapter("solr", config('solarium')); + $service->addDatasetsToIndex($dataset); + } catch (Exception $e) { + $this->error(__METHOD__ . ': ' . 'Indexing document ' . $dataset->id . ' failed: ' . $e->getMessage()); + } return redirect() ->route('publish.workflow.doi.index') ->with('flash_message', 'You have successfully updated a DOI for the dataset!'); diff --git a/app/Http/Controllers/Publish/EditorController.php b/app/Http/Controllers/Publish/EditorController.php index 6d39f97..6b9a647 100644 --- a/app/Http/Controllers/Publish/EditorController.php +++ b/app/Http/Controllers/Publish/EditorController.php @@ -33,6 +33,7 @@ use App\Models\DatasetIdentifier; use App\Models\Oai\OaiModelError; use App\Exceptions\OaiModelException; use App\Interfaces\DoiInterface; +use App\Library\Search\SolariumAdapter; class EditorController extends Controller { @@ -714,13 +715,16 @@ class EditorController extends Controller $doi['type'] = "doi"; $doi['status'] = "findable"; if ($doi->save()) { - // touch doi (and dataset) for solr - $doi->touch(); - // update server_date_modified for triggering nex xml cache (doi interface) - // $time = new \Illuminate\Support\Carbon(); - // $dataset->server_date_modified = $time; - // $dataset->save(); - // dataset gets automatically updated because of touches array + // touch unnecessary, save() also updates datasat modified date + // $doi->touch(); + $dataset = Dataset::where('publish_id', '=', $dataId)->firstOrFail(); + // add to solr + try { + $service = new SolariumAdapter("solr", config('solarium')); + $service->addDatasetsToIndex($dataset); + } catch (Exception $e) { + $this->error(__METHOD__ . ': ' . 'Indexing document ' . $dataset->id . ' failed: ' . $e->getMessage()); + } return redirect() ->route('publish.workflow.editor.index') ->with('flash_message', 'You have successfully created a DOI for the dataset!'); diff --git a/composer.lock b/composer.lock index d75b9a4..337689a 100755 --- a/composer.lock +++ b/composer.lock @@ -2200,16 +2200,16 @@ }, { "name": "nesbot/carbon", - "version": "2.48.1", + "version": "2.49.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "8d1f50f1436fb4b05e7127360483dd9c6e73da16" + "reference": "93d9db91c0235c486875d22f1e08b50bdf3e6eee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/8d1f50f1436fb4b05e7127360483dd9c6e73da16", - "reference": "8d1f50f1436fb4b05e7127360483dd9c6e73da16", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/93d9db91c0235c486875d22f1e08b50bdf3e6eee", + "reference": "93d9db91c0235c486875d22f1e08b50bdf3e6eee", "shasum": "" }, "require": { @@ -2289,7 +2289,7 @@ "type": "tidelift" } ], - "time": "2021-05-26T22:08:38+00:00" + "time": "2021-06-02T07:31:40+00:00" }, { "name": "nikic/php-parser",