Compare commits

..

2 commits

Author SHA1 Message Date
6b04ad9910 Release: merge develop for v2.1.0
Some checks failed
CI Pipeline / japa-tests (push) Failing after 1s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 7s
2025-11-13 11:42:59 +01:00
fbc34a7456 Merge branch 'develop'
Some checks failed
CI Pipeline / japa-tests (push) Has been cancelled
nerge latest hotfix updates from develop branch into master branch
2025-07-03 10:44:39 +02:00
5 changed files with 158 additions and 201 deletions

View file

@ -195,7 +195,7 @@ export default class DatasetsController {
if (!user) { if (!user) {
return response.flash('You must be logged in to edit a dataset.', 'error').redirect().toRoute('app.login.show'); return response.flash('You must be logged in to edit a dataset.', 'error').redirect().toRoute('app.login.show');
} }
// $dataset = Dataset::with('user:id,login')->findOrFail($id); // $dataset = Dataset::with('user:id,login')->findOrFail($id);
const dataset = await Dataset.query().where('id', id).where('editor_id', user.id).firstOrFail(); const dataset = await Dataset.query().where('id', id).where('editor_id', user.id).firstOrFail();
@ -236,7 +236,7 @@ export default class DatasetsController {
throw error; throw error;
} }
const id = request.param('id'); const id = request.param('id');
const user = auth.user; const user = auth.user;
if (!user) { if (!user) {
return response.flash('You must be logged in to edit a dataset.', 'error').redirect().toRoute('app.login.show'); return response.flash('You must be logged in to edit a dataset.', 'error').redirect().toRoute('app.login.show');
} }
@ -306,7 +306,7 @@ export default class DatasetsController {
public async rejectUpdate({ request, response, auth }: HttpContext) { public async rejectUpdate({ request, response, auth }: HttpContext) {
const authUser = auth.user!; const authUser = auth.user!;
if (!authUser) { if (!authUser) {
return response.flash('You must be logged in to edit a dataset.', 'error').redirect().toRoute('app.login.show'); return response.flash('You must be logged in to edit a dataset.', 'error').redirect().toRoute('app.login.show');
} }
@ -619,7 +619,7 @@ export default class DatasetsController {
}); });
} }
public async doiStore({ request, response, session, auth }: HttpContext) { public async doiStore({ request, response, auth }: HttpContext) {
const dataId = request.param('publish_id'); const dataId = request.param('publish_id');
const user = auth.user; const user = auth.user;
if (!user) { if (!user) {
@ -627,7 +627,10 @@ export default class DatasetsController {
} }
// Load dataset with minimal required relationships // Load dataset with minimal required relationships
const dataset = await Dataset.query().where('editor_id', user.id).where('publish_id', dataId).firstOrFail(); const dataset = await Dataset.query()
.where('editor_id', user.id) // Ensure the user is the editor of the dataset
.where('publish_id', dataId)
.firstOrFail();
const prefix = process.env.DATACITE_PREFIX || ''; const prefix = process.env.DATACITE_PREFIX || '';
const base_domain = process.env.BASE_DOMAIN || ''; const base_domain = process.env.BASE_DOMAIN || '';
@ -636,44 +639,30 @@ export default class DatasetsController {
const xmlMeta = (await Index.getDoiRegisterString(dataset)) as string; const xmlMeta = (await Index.getDoiRegisterString(dataset)) as string;
// Prepare DOI registration data // Prepare DOI registration data
const doiValue = `${prefix}/tethys.${dataset.publish_id}`; const doiValue = `${prefix}/tethys.${dataset.publish_id}`; //'10.21388/tethys.213'
const landingPageUrl = `https://doi.${getDomain(base_domain)}/${prefix}/tethys.${dataset.publish_id}`; const landingPageUrl = `https://doi.${getDomain(base_domain)}/${prefix}/tethys.${dataset.publish_id}`; //https://doi.dev.tethys.at/10.21388/tethys.213
// Register DOI with DataCite
const doiClient = new DoiClient();
const dataciteResponse = await doiClient.registerDoi(doiValue, xmlMeta, landingPageUrl);
if (dataciteResponse?.status !== 201) {
const message = `Unexpected DataCite MDS response code ${dataciteResponse?.status}`;
throw new DoiClientException(dataciteResponse?.status, message);
}
// DOI registration successful - persist and index
try { try {
// Register DOI with DataCite // Save identifier
const doiClient = new DoiClient();
const dataciteResponse = await doiClient.registerDoi(doiValue, xmlMeta, landingPageUrl);
if (dataciteResponse?.status !== 201) {
const message = `Unexpected DataCite MDS response code ${dataciteResponse?.status}`;
throw new DoiClientException(dataciteResponse?.status, message);
}
// DOI registration successful - persist and index
await this.persistDoiAndIndex(dataset, doiValue); await this.persistDoiAndIndex(dataset, doiValue);
return response return response.toRoute('editor.dataset.list').flash('message', 'You have successfully created a DOI for the dataset!');
.flash('message', 'You have successfully created a DOI for the dataset!')
.redirect()
.toRoute('editor.dataset.list');
} catch (error) { } catch (error) {
// logger.error(`${__filename}: DOI registration failed for dataset ${dataset.id}: ${error.message}`); logger.error(`${__filename}: Failed to persist DOI and index dataset ${dataset.id}: ${error.message}`);
throw new HttpException(error.message);
if (error instanceof DoiClientException) {
// Flash error for Inertia to pick up
session.flash('errors', {
doi: `DOI registration failed: ${error.message}`,
});
// Optionally also flash a warning for your warning display
session.flash('warning', error.message);
} else {
session.flash('errors', {
general: `An unexpected error occurred: ${error.message}`,
});
}
return response.redirect().back();
} }
// return response.toRoute('editor.dataset.list').flash('message', xmlMeta);
} }
/** /**

View file

@ -17,7 +17,7 @@ interface XslTParameter {
} }
export default { export default {
// opensearchNode: process.env.OPENSEARCH_HOST || 'localhost', // opensearchNode: process.env.OPENSEARCH_HOST || 'localhost',
client: new Client({ node: `${process.env.OPENSEARCH_HOST || 'localhost'}` }), // replace with your OpenSearch endpoint client: new Client({ node: `http://${process.env.OPENSEARCH_HOST || 'localhost'}` }), // replace with your OpenSearch endpoint
async getDoiRegisterString(dataset: Dataset): Promise<string | undefined> { async getDoiRegisterString(dataset: Dataset): Promise<string | undefined> {
try { try {

File diff suppressed because one or more lines are too long

View file

@ -62,19 +62,15 @@
</xsl:choose> </xsl:choose>
<!--<datacite:creator>--> <!--<datacite:creator>-->
<xsl:if test="PersonAuthor[normalize-space(concat(@FirstName, @LastName)) != '']"> <creators>
<creators> <xsl:apply-templates select="PersonAuthor" mode="oai_datacite">
<xsl:apply-templates select="PersonAuthor" mode="oai_datacite"> <xsl:sort select="@SortOrder"/>
<xsl:sort select="@SortOrder"/> </xsl:apply-templates>
</xsl:apply-templates> </creators>
</creators> <titles>
</xsl:if> <xsl:apply-templates select="TitleMain" mode="oai_datacite" />
<xsl:if test="TitleMain[normalize-space(@Value) != ''] or TitleAdditional[normalize-space(@Value) != '']"> <xsl:apply-templates select="TitleAdditional" mode="oai_datacite" />
<titles> </titles>
<xsl:apply-templates select="TitleMain" mode="oai_datacite" />
<xsl:apply-templates select="TitleAdditional" mode="oai_datacite" />
</titles>
</xsl:if>
<publisher> <publisher>
<!-- <xsl:value-of select="@PublisherName" /> --> <!-- <xsl:value-of select="@PublisherName" /> -->
<xsl:value-of select="@CreatingCorporation" /> <xsl:value-of select="@CreatingCorporation" />
@ -82,26 +78,22 @@
<publicationYear> <publicationYear>
<xsl:value-of select="ServerDatePublished/@Year" /> <xsl:value-of select="ServerDatePublished/@Year" />
</publicationYear> </publicationYear>
<xsl:if test="Subject[normalize-space(@Value) != '']"> <subjects>
<subjects> <xsl:apply-templates select="Subject" mode="oai_datacite" />
<xsl:apply-templates select="Subject" mode="oai_datacite" /> </subjects>
</subjects>
</xsl:if>
<language> <language>
<xsl:value-of select="@Language" /> <xsl:value-of select="@Language" />
</language> </language>
<xsl:if test="PersonContributor[normalize-space(concat(@FirstName, @LastName)) != '']"> <xsl:if test="PersonContributor">
<contributors> <contributors>
<xsl:apply-templates select="PersonContributor" mode="oai_datacite"> <xsl:apply-templates select="PersonContributor" mode="oai_datacite">
<xsl:sort select="@SortOrder"/> <xsl:sort select="@SortOrder"/>
</xsl:apply-templates> </xsl:apply-templates>
</contributors> </contributors>
</xsl:if> </xsl:if>
<xsl:if test="(EmbargoDate and ($unixTimestamp &lt; EmbargoDate/@UnixTimestamp)) or CreatedAt"> <dates>
<dates> <xsl:call-template name="RdrDate2" />
<xsl:call-template name="RdrDate2" /> </dates>
</dates>
</xsl:if>
<version> <version>
<xsl:choose> <xsl:choose>
<xsl:when test="@Version"> <xsl:when test="@Version">
@ -117,46 +109,42 @@
<!-- <xsl:value-of select="@Type" /> --> <!-- <xsl:value-of select="@Type" /> -->
</resourceType> </resourceType>
<xsl:if test="normalize-space(@landingpage) != ''"> <alternateIdentifiers>
<alternateIdentifiers> <xsl:call-template name="AlternateIdentifier" />
<xsl:call-template name="AlternateIdentifier" /> </alternateIdentifiers>
</alternateIdentifiers>
</xsl:if>
<xsl:if test="Reference[normalize-space(@Type) != '' and normalize-space(@Relation) != '']"> <xsl:if test="Reference">
<relatedIdentifiers> <relatedIdentifiers>
<xsl:apply-templates select="Reference" mode="oai_datacite" /> <xsl:apply-templates select="Reference" mode="oai_datacite" />
</relatedIdentifiers> </relatedIdentifiers>
</xsl:if> </xsl:if>
<xsl:if test="Licence[normalize-space(@Name) != '' or normalize-space(@Url) != '']"> <rightsList>
<rightsList> <xsl:apply-templates select="Licence" mode="oai_datacite" />
<xsl:apply-templates select="Licence" mode="oai_datacite" /> </rightsList>
</rightsList> <sizes>
</xsl:if> <size>
<xsl:if test="File"> <xsl:value-of select="count(File)" />
<sizes> <xsl:text> datasets</xsl:text>
<size> </size>
<xsl:value-of select="count(File)" /> </sizes>
<xsl:text> datasets</xsl:text> <formats>
</size> <xsl:apply-templates select="File/@MimeType" mode="oai_datacite" />
</sizes> </formats>
</xsl:if> <descriptions>
<xsl:if test="File[normalize-space(@MimeType) != '']"> <xsl:apply-templates select="TitleAbstract" mode="oai_datacite" />
<formats> <xsl:apply-templates select="TitleAbstractAdditional" mode="oai_datacite" />
<xsl:apply-templates select="File/@MimeType" mode="oai_datacite" /> </descriptions>
</formats> <geoLocations>
</xsl:if> <xsl:apply-templates select="Coverage" mode="oai_datacite" />
<xsl:if test="TitleAbstract[normalize-space(@Value) != ''] or TitleAbstractAdditional[normalize-space(@Value) != '']"> <!-- <geoLocation>
<descriptions> <geoLocationBox>
<xsl:apply-templates select="TitleAbstract" mode="oai_datacite" /> <westBoundLongitude>6.58987</westBoundLongitude>
<xsl:apply-templates select="TitleAbstractAdditional" mode="oai_datacite" /> <eastBoundLongitude>6.83639</eastBoundLongitude>
</descriptions> <southBoundLatitude>50.16</southBoundLatitude>
</xsl:if> <northBoundLatitude>50.18691</northBoundLatitude>
<xsl:if test="Coverage[normalize-space(@XMin) != '' and normalize-space(@XMax) != '' and normalize-space(@YMin) != '' and normalize-space(@YMax) != '']"> </geoLocationBox>
<geoLocations> </geoLocation> -->
<xsl:apply-templates select="Coverage" mode="oai_datacite" /> </geoLocations>
</geoLocations>
</xsl:if>
</resource> </resource>
</xsl:template> </xsl:template>
@ -188,54 +176,54 @@
<xsl:template match="Coverage" mode="oai_datacite" <xsl:template match="Coverage" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4"> xmlns="http://datacite.org/schema/kernel-4">
<xsl:if test="normalize-space(@XMin) != '' and normalize-space(@XMax) != '' and normalize-space(@YMin) != '' and normalize-space(@YMax) != ''"> <geoLocation>
<geoLocation> <geoLocationBox>
<geoLocationBox> <westBoundLongitude>
<westBoundLongitude><xsl:value-of select="@XMin" /></westBoundLongitude> <xsl:value-of select="@XMin" />
<eastBoundLongitude><xsl:value-of select="@XMax" /></eastBoundLongitude> </westBoundLongitude>
<southBoundLatitude><xsl:value-of select="@YMin" /></southBoundLatitude> <eastBoundLongitude>
<northBoundLatitude><xsl:value-of select="@YMax" /></northBoundLatitude> <xsl:value-of select="@XMax" />
</geoLocationBox> </eastBoundLongitude>
</geoLocation> <southBoundLatitude>
</xsl:if> <xsl:value-of select="@YMin" />
</xsl:template> </southBoundLatitude>
<northBoundLatitude>
<!-- TitleAbstract template --> <xsl:value-of select="@YMax" />
<xsl:template match="TitleAbstract" mode="oai_datacite" </northBoundLatitude>
xmlns="http://datacite.org/schema/kernel-4"> </geoLocationBox>
<xsl:if test="normalize-space(@Value) != ''"> </geoLocation>
<description>
<xsl:attribute name="xml:lang">
<xsl:value-of select="@Language" />
</xsl:attribute>
<xsl:if test="@Type != ''">
<xsl:attribute name="descriptionType">
<xsl:text>Abstract</xsl:text>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="@Value" />
</description>
</xsl:if>
</xsl:template> </xsl:template>
<!-- TitleAbstractAdditional template --> <xsl:template match="TitleAbstract" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4">
<description>
<xsl:attribute name="xml:lang">
<xsl:value-of select="@Language" />
</xsl:attribute>
<xsl:if test="@Type != ''">
<xsl:attribute name="descriptionType">
<!-- <xsl:value-of select="@Type" /> -->
<xsl:text>Abstract</xsl:text>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="@Value" />
</description>
</xsl:template>
<xsl:template match="TitleAbstractAdditional" mode="oai_datacite" <xsl:template match="TitleAbstractAdditional" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4"> xmlns="http://datacite.org/schema/kernel-4">
<xsl:if test="normalize-space(@Value) != ''"> <description>
<description> <xsl:attribute name="xml:lang">
<xsl:attribute name="xml:lang"> <xsl:value-of select="@Language" />
<xsl:value-of select="@Language" /> </xsl:attribute>
<xsl:if test="@Type != ''">
<xsl:attribute name="descriptionType">
<xsl:call-template name="CamelCaseWord">
<xsl:with-param name="text" select="@Type" />
</xsl:call-template>
</xsl:attribute> </xsl:attribute>
<xsl:if test="@Type != ''"> </xsl:if>
<xsl:attribute name="descriptionType"> <xsl:value-of select="@Value" />
<xsl:call-template name="CamelCaseWord"> </description>
<xsl:with-param name="text" select="@Type" />
</xsl:call-template>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="@Value" />
</description>
</xsl:if>
</xsl:template> </xsl:template>
<xsl:template name="CamelCaseWord"> <xsl:template name="CamelCaseWord">
@ -268,7 +256,6 @@
<xsl:template match="TitleMain" mode="oai_datacite" <xsl:template match="TitleMain" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4"> xmlns="http://datacite.org/schema/kernel-4">
<xsl:if test="normalize-space(@Value) != ''">
<title> <title>
<xsl:if test="@Language != ''"> <xsl:if test="@Language != ''">
<xsl:attribute name="xml:lang"> <xsl:attribute name="xml:lang">
@ -282,12 +269,9 @@
</xsl:if> </xsl:if>
<xsl:value-of select="@Value" /> <xsl:value-of select="@Value" />
</title> </title>
</xsl:if>
</xsl:template> </xsl:template>
<xsl:template match="TitleAdditional" mode="oai_datacite" <xsl:template match="TitleAdditional" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4"> xmlns="http://datacite.org/schema/kernel-4">
<xsl:if test="normalize-space(@Value) != ''">
<title> <title>
<xsl:if test="@Language != ''"> <xsl:if test="@Language != ''">
<xsl:attribute name="xml:lang"> <xsl:attribute name="xml:lang">
@ -310,70 +294,61 @@
</xsl:choose> </xsl:choose>
<xsl:value-of select="@Value" /> <xsl:value-of select="@Value" />
</title> </title>
</xsl:if>
</xsl:template> </xsl:template>
<xsl:template match="Subject" mode="oai_datacite" <xsl:template match="Subject" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4"> xmlns="http://datacite.org/schema/kernel-4">
<xsl:if test="normalize-space(@Value) != ''"> <subject>
<subject> <xsl:if test="@Language != ''">
<xsl:if test="@Language != ''"> <xsl:attribute name="xml:lang">
<xsl:attribute name="xml:lang"> <xsl:value-of select="@Language" />
<xsl:value-of select="@Language" /> </xsl:attribute>
</xsl:attribute> </xsl:if>
</xsl:if> <xsl:value-of select="@Value" />
<xsl:value-of select="@Value" /> </subject>
</subject>
</xsl:if>
</xsl:template> </xsl:template>
<xsl:template name="AlternateIdentifier" match="AlternateIdentifier" mode="oai_datacite" <xsl:template name="AlternateIdentifier" match="AlternateIdentifier" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4"> xmlns="http://datacite.org/schema/kernel-4">
<xsl:if test="normalize-space(@landingpage) != ''"> <alternateIdentifier>
<alternateIdentifier> <xsl:attribute name="alternateIdentifierType">
<xsl:attribute name="alternateIdentifierType"> <xsl:text>url</xsl:text>
<xsl:text>url</xsl:text> </xsl:attribute>
</xsl:attribute> <!-- <xsl:variable name="identifier" select="concat($repURL, '/dataset/', @Id)" /> -->
<xsl:value-of select="@landingpage" /> <xsl:value-of select="@landingpage" />
</alternateIdentifier> </alternateIdentifier>
</xsl:if>
</xsl:template> </xsl:template>
<xsl:template match="Reference" mode="oai_datacite" <xsl:template match="Reference" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4"> xmlns="http://datacite.org/schema/kernel-4">
<xsl:if test="normalize-space(@Type) != '' and normalize-space(@Relation) != ''"> <relatedIdentifier>
<relatedIdentifier> <xsl:attribute name="relatedIdentifierType">
<xsl:attribute name="relatedIdentifierType"> <xsl:value-of select="@Type" />
<xsl:value-of select="@Type" /> </xsl:attribute>
</xsl:attribute> <xsl:attribute name="relationType">
<xsl:attribute name="relationType"> <xsl:value-of select="@Relation" />
<xsl:value-of select="@Relation" /> </xsl:attribute>
</xsl:attribute> <xsl:value-of select="@Value" />
<xsl:value-of select="@Value" /> </relatedIdentifier>
</relatedIdentifier>
</xsl:if>
</xsl:template> </xsl:template>
<!-- PersonContributor template -->
<xsl:template match="PersonContributor" mode="oai_datacite" <xsl:template match="PersonContributor" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4"> xmlns="http://datacite.org/schema/kernel-4">
<xsl:if test="normalize-space(concat(@FirstName, @LastName)) != ''"> <contributor>
<contributor> <xsl:if test="@ContributorType != ''">
<xsl:if test="@ContributorType != ''"> <xsl:attribute name="contributorType">
<xsl:attribute name="contributorType"> <xsl:value-of select="@ContributorType" />
<xsl:value-of select="@ContributorType" /> </xsl:attribute>
</xsl:attribute> </xsl:if>
</xsl:if> <contributorName>
<contributorName> <!-- <xsl:if test="@NameType != ''">
<!-- <xsl:if test="@NameType != ''"> <xsl:attribute name="nameType">
<xsl:attribute name="nameType"> <xsl:value-of select="@NameType" />
<xsl:value-of select="@NameType" /> </xsl:attribute>
</xsl:attribute> </xsl:if> -->
</xsl:if> --> <xsl:value-of select="concat(@FirstName, ' ',@LastName)" />
<xsl:value-of select="concat(@FirstName, ' ', @LastName)" /> </contributorName>
</contributorName> </contributor>
</contributor>
</xsl:if>
</xsl:template> </xsl:template>
<xsl:template match="PersonAuthor" mode="oai_datacite" <xsl:template match="PersonAuthor" mode="oai_datacite"
@ -428,11 +403,9 @@
<xsl:template match="File/@MimeType" mode="oai_datacite" <xsl:template match="File/@MimeType" mode="oai_datacite"
xmlns="http://datacite.org/schema/kernel-4"> xmlns="http://datacite.org/schema/kernel-4">
<xsl:if test="normalize-space(.) != ''"> <format>
<format> <xsl:value-of select="." />
<xsl:value-of select="." /> </format>
</format>
</xsl:if>
</xsl:template> </xsl:template>
<xsl:template match="Licence" mode="oai_datacite" <xsl:template match="Licence" mode="oai_datacite"

View file

@ -2,7 +2,7 @@
import LayoutAuthenticated from '@/Layouts/LayoutAuthenticated.vue'; import LayoutAuthenticated from '@/Layouts/LayoutAuthenticated.vue';
import SectionMain from '@/Components/SectionMain.vue'; import SectionMain from '@/Components/SectionMain.vue';
import SectionTitleLineWithButton from '@/Components/SectionTitleLineWithButton.vue'; import SectionTitleLineWithButton from '@/Components/SectionTitleLineWithButton.vue';
import { router, Head, usePage } from '@inertiajs/vue3'; import { router, Head, usePage } from '@inertiajs/vue3';
import { computed, Ref } from 'vue'; import { computed, Ref } from 'vue';
import CardBox from '@/Components/CardBox.vue'; import CardBox from '@/Components/CardBox.vue';
import BaseButton from '@/Components/BaseButton.vue'; import BaseButton from '@/Components/BaseButton.vue';
@ -51,11 +51,6 @@ const handleSubmit = async (e) => {
</SectionTitleLineWithButton> </SectionTitleLineWithButton>
<CardBox form @submit.prevent="handleSubmit"> <CardBox form @submit.prevent="handleSubmit">
<FormValidationErrors v-bind:errors="errors" /> <FormValidationErrors v-bind:errors="errors" />
<!-- Your existing warning display will show the warning -->
<!-- <div v-if="flash && flash.warning">
<p>{{ flash.warning }}</p>
</div> -->
<!-- <div class="flex flex-col md:flex-row items-center"> --> <!-- <div class="flex flex-col md:flex-row items-center"> -->
<!-- <div class="w-full"> <!-- <div class="w-full">