Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring

This commit is contained in:
Sofia Papacharalampous 2024-05-15 17:22:56 +03:00
commit 0cbdc1bb52
9 changed files with 76 additions and 22 deletions

View File

@ -10,9 +10,10 @@ public class DepositSourceEntity {
private String scope; private String scope;
private String pdfTransformerId; private String pdfTransformerId;
private String rdaTransformerId; private String rdaTransformerId;
private int maxInMemorySizeInBytes;
public String getRepositoryId() { public String getRepositoryId() {
return repositoryId; return this.repositoryId;
} }
public void setRepositoryId(String repositoryId) { public void setRepositoryId(String repositoryId) {
@ -20,7 +21,7 @@ public class DepositSourceEntity {
} }
public String getUrl() { public String getUrl() {
return url; return this.url;
} }
public void setUrl(String url) { public void setUrl(String url) {
@ -28,7 +29,7 @@ public class DepositSourceEntity {
} }
public String getIssuerUrl() { public String getIssuerUrl() {
return issuerUrl; return this.issuerUrl;
} }
public void setIssuerUrl(String issuerUrl) { public void setIssuerUrl(String issuerUrl) {
@ -36,7 +37,7 @@ public class DepositSourceEntity {
} }
public String getClientId() { public String getClientId() {
return clientId; return this.clientId;
} }
public void setClientId(String clientId) { public void setClientId(String clientId) {
@ -44,7 +45,7 @@ public class DepositSourceEntity {
} }
public String getClientSecret() { public String getClientSecret() {
return clientSecret; return this.clientSecret;
} }
public void setClientSecret(String clientSecret) { public void setClientSecret(String clientSecret) {
@ -52,7 +53,7 @@ public class DepositSourceEntity {
} }
public String getScope() { public String getScope() {
return scope; return this.scope;
} }
public void setScope(String scope) { public void setScope(String scope) {
@ -60,7 +61,7 @@ public class DepositSourceEntity {
} }
public String getPdfTransformerId() { public String getPdfTransformerId() {
return pdfTransformerId; return this.pdfTransformerId;
} }
public void setPdfTransformerId(String pdfTransformerId) { public void setPdfTransformerId(String pdfTransformerId) {
@ -68,10 +69,18 @@ public class DepositSourceEntity {
} }
public String getRdaTransformerId() { public String getRdaTransformerId() {
return rdaTransformerId; return this.rdaTransformerId;
} }
public void setRdaTransformerId(String rdaTransformerId) { public void setRdaTransformerId(String rdaTransformerId) {
this.rdaTransformerId = rdaTransformerId; this.rdaTransformerId = rdaTransformerId;
} }
public int getMaxInMemorySizeInBytes() {
return this.maxInMemorySizeInBytes;
}
public void setMaxInMemorySizeInBytes(int maxInMemorySizeInBytes) {
this.maxInMemorySizeInBytes = maxInMemorySizeInBytes;
}
} }

View File

@ -8,9 +8,10 @@ public class FileTransformerSourceEntity {
private String clientId; private String clientId;
private String clientSecret; private String clientSecret;
private String scope; private String scope;
private int maxInMemorySizeInBytes;
public String getUrl() { public String getUrl() {
return url; return this.url;
} }
public void setUrl(String url) { public void setUrl(String url) {
@ -18,7 +19,7 @@ public class FileTransformerSourceEntity {
} }
public String getTransformerId() { public String getTransformerId() {
return transformerId; return this.transformerId;
} }
public void setTransformerId(String transformerId) { public void setTransformerId(String transformerId) {
@ -26,7 +27,7 @@ public class FileTransformerSourceEntity {
} }
public String getIssuerUrl() { public String getIssuerUrl() {
return issuerUrl; return this.issuerUrl;
} }
public void setIssuerUrl(String issuerUrl) { public void setIssuerUrl(String issuerUrl) {
@ -34,7 +35,7 @@ public class FileTransformerSourceEntity {
} }
public String getClientId() { public String getClientId() {
return clientId; return this.clientId;
} }
public void setClientId(String clientId) { public void setClientId(String clientId) {
@ -42,7 +43,7 @@ public class FileTransformerSourceEntity {
} }
public String getClientSecret() { public String getClientSecret() {
return clientSecret; return this.clientSecret;
} }
public void setClientSecret(String clientSecret) { public void setClientSecret(String clientSecret) {
@ -50,10 +51,18 @@ public class FileTransformerSourceEntity {
} }
public String getScope() { public String getScope() {
return scope; return this.scope;
} }
public void setScope(String scope) { public void setScope(String scope) {
this.scope = scope; this.scope = scope;
} }
public int getMaxInMemorySizeInBytes() {
return this.maxInMemorySizeInBytes;
}
public void setMaxInMemorySizeInBytes(int maxInMemorySizeInBytes) {
this.maxInMemorySizeInBytes = maxInMemorySizeInBytes;
}
} }

View File

@ -15,6 +15,9 @@ import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.time.Instant; import java.time.Instant;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -125,12 +128,17 @@ public class FieldPersist {
protected List<Specification> specifications(FieldPersist item) { protected List<Specification> specifications(FieldPersist item) {
FieldType fieldType = this.fieldEntity != null && this.fieldEntity.getData() != null ? this.fieldEntity.getData().getFieldType() : FieldType.FREE_TEXT; FieldType fieldType = this.fieldEntity != null && this.fieldEntity.getData() != null ? this.fieldEntity.getData().getFieldType() : FieldType.FREE_TEXT;
boolean required = this.fieldEntity != null && this.fieldEntity.getValidations() != null ? this.fieldEntity.getValidations().contains(FieldValidationType.Required) : false; boolean required = this.fieldEntity != null && this.fieldEntity.getValidations() != null ? this.fieldEntity.getValidations().contains(FieldValidationType.Required) : false;
boolean isUrlRequired = this.fieldEntity != null && this.fieldEntity.getValidations() != null ? this.fieldEntity.getValidations().contains(FieldValidationType.Url) : false;
boolean isVisible = this.fieldEntity != null ? this.visibilityService.isVisible(this.fieldEntity.getId(), this.ordinal) : true; boolean isVisible = this.fieldEntity != null ? this.visibilityService.isVisible(this.fieldEntity.getId(), this.ordinal) : true;
return Arrays.asList( return Arrays.asList(
this.spec() this.spec()
.iff(()-> FieldType.isTextType(fieldType) && DescriptionStatus.Finalized.equals(this.status) && isVisible && required) .iff(()-> FieldType.isTextType(fieldType) && DescriptionStatus.Finalized.equals(this.status) && isVisible && required)
.must(() -> !this.isEmpty(item.getTextValue())) .must(() -> !this.isEmpty(item.getTextValue()))
.failOn(FieldPersist._textValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._textValue}, LocaleContextHolder.getLocale())), .failOn(FieldPersist._textValue).failWith(this.messageSource.getMessage("Validation_Required", new Object[]{FieldPersist._textValue}, LocaleContextHolder.getLocale())),
this.spec()
.iff(()-> fieldType.equals(FieldType.FREE_TEXT) && DescriptionStatus.Finalized.equals(this.status) && isVisible && isUrlRequired)
.must(() -> this.isValidURL(item.getTextValue()))
.failOn(FieldPersist._textValue).failWith(this.messageSource.getMessage("Validation_UrlRequired", new Object[]{FieldPersist._textValue}, LocaleContextHolder.getLocale())),
this.spec() this.spec()
.iff(()-> FieldType.isDateType(fieldType) && DescriptionStatus.Finalized.equals(this.status) && isVisible && required) .iff(()-> FieldType.isDateType(fieldType) && DescriptionStatus.Finalized.equals(this.status) && isVisible && required)
.must(() -> !this.isNull(item.getDateValue())) .must(() -> !this.isNull(item.getDateValue()))
@ -196,6 +204,17 @@ public class FieldPersist {
this.ordinal = ordinal; this.ordinal = ordinal;
return this; return this;
} }
boolean isValidURL(String url){
try {
new URL(url).toURI();
return true;
} catch (MalformedURLException e) {
return false;
} catch (URISyntaxException e) {
return false;
}
}
} }
} }

View File

@ -158,7 +158,10 @@ public class DepositServiceImpl implements DepositService {
exchangeFilterFunctions.add(apiKeyExchangeFilterFunction); exchangeFilterFunctions.add(apiKeyExchangeFilterFunction);
exchangeFilterFunctions.add(logRequest()); exchangeFilterFunctions.add(logRequest());
exchangeFilterFunctions.add(logResponse()); exchangeFilterFunctions.add(logResponse());
}).build(); }).codecs(codecs -> codecs
.defaultCodecs()
.maxInMemorySize(source.getMaxInMemorySizeInBytes())
).build();
DepositClientImpl repository = new DepositClientImpl(webClient); DepositClientImpl repository = new DepositClientImpl(webClient);
this.clients.put(repositoryIdByTenant, repository); this.clients.put(repositoryIdByTenant, repository);
return repository; return repository;

View File

@ -109,7 +109,10 @@ public class FileTransformerServiceImpl implements FileTransformerService {
exchangeFilterFunctions.add(tokenExchangeFilterFunction); exchangeFilterFunctions.add(tokenExchangeFilterFunction);
exchangeFilterFunctions.add(logRequest()); exchangeFilterFunctions.add(logRequest());
exchangeFilterFunctions.add(logResponse()); exchangeFilterFunctions.add(logResponse());
}).build()); }).codecs(codecs -> codecs
.defaultCodecs()
.maxInMemorySize(source.getMaxInMemorySizeInBytes())
).build());
this.clients.put(repositoryIdByTenant, repository); this.clients.put(repositoryIdByTenant, repository);
return repository; return repository;
} }

View File

@ -8,6 +8,7 @@ deposit:
client-id: ${IDP_APIKEY_CLIENT_ID} client-id: ${IDP_APIKEY_CLIENT_ID}
client-secret: ${IDP_APIKEY_CLIENT_SECRET} client-secret: ${IDP_APIKEY_CLIENT_SECRET}
scope: ${IDP_APIKEY_SCOPE} scope: ${IDP_APIKEY_SCOPE}
maxInMemorySizeInBytes: 6554000
- url: http://dev04.local.cite.gr:55330/zenodo1 - url: http://dev04.local.cite.gr:55330/zenodo1
repositoryId: Zenodo1 repositoryId: Zenodo1
pdfTransformerId: docx-file-transformer pdfTransformerId: docx-file-transformer
@ -16,3 +17,4 @@ deposit:
client-id: ${IDP_APIKEY_CLIENT_ID} client-id: ${IDP_APIKEY_CLIENT_ID}
client-secret: ${IDP_APIKEY_CLIENT_SECRET} client-secret: ${IDP_APIKEY_CLIENT_SECRET}
scope: ${IDP_APIKEY_SCOPE} scope: ${IDP_APIKEY_SCOPE}
maxInMemorySizeInBytes: 6554000

View File

@ -1,14 +1,16 @@
file-transformer: file-transformer:
sources: sources:
- url: http://dev04.local.cite.gr:55330/file/docx - url: http://localhost:8084
transformerId: docx-file-transformer transformerId: docx-file-transformer
issuer-url: ${IDP_ISSUER_URI_TOKEN} issuer-url: ${IDP_ISSUER_URI_TOKEN}
client-id: ${IDP_APIKEY_CLIENT_ID} client-id: ${IDP_APIKEY_CLIENT_ID}
client-secret: ${IDP_APIKEY_CLIENT_SECRET} client-secret: ${IDP_APIKEY_CLIENT_SECRET}
scope: ${IDP_APIKEY_SCOPE} scope: ${IDP_APIKEY_SCOPE}
maxInMemorySizeInBytes: 6554000
- url: http://dev04.local.cite.gr:55330/file/rdajson - url: http://dev04.local.cite.gr:55330/file/rdajson
transformerId: rda-file-transformer transformerId: rda-file-transformer
issuer-url: ${IDP_ISSUER_URI_TOKEN} issuer-url: ${IDP_ISSUER_URI_TOKEN}
client-id: ${IDP_APIKEY_CLIENT_ID} client-id: ${IDP_APIKEY_CLIENT_ID}
client-secret: ${IDP_APIKEY_CLIENT_SECRET} client-secret: ${IDP_APIKEY_CLIENT_SECRET}
scope: ${IDP_APIKEY_SCOPE} scope: ${IDP_APIKEY_SCOPE}
maxInMemorySizeInBytes: 6554000

View File

@ -27,3 +27,4 @@ Validation.LargerThenEqual= value {0} must be equal or larger than {1}
Validation.MissingFields= missing fields: {0} Validation.MissingFields= missing fields: {0}
Validation.InvalidDescriptionTemplateMultiplicity= {0} can not be used Validation.InvalidDescriptionTemplateMultiplicity= {0} can not be used
Validation.InvalidDescriptionTemplateMultiplicityOnDMP= Description Templates has multiplicity errors Validation.InvalidDescriptionTemplateMultiplicityOnDMP= Description Templates has multiplicity errors
Validation_UrlRequired={0} is not valid url

View File

@ -1,11 +1,12 @@
import { COMMA, ENTER } from '@angular/cdk/keycodes'; import { COMMA, ENTER } from '@angular/cdk/keycodes';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit, SimpleChanges } from '@angular/core'; import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit, SimpleChanges } from '@angular/core';
import { UntypedFormControl, UntypedFormGroup } from '@angular/forms'; import { UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms';
import { MatCheckboxChange } from '@angular/material/checkbox'; import { MatCheckboxChange } from '@angular/material/checkbox';
import { MatDialog } from "@angular/material/dialog"; import { MatDialog } from "@angular/material/dialog";
import { DescriptionTemplateFieldType } from '@app/core/common/enum/description-template-field-type'; import { DescriptionTemplateFieldType } from '@app/core/common/enum/description-template-field-type';
import { DescriptionTemplateFieldValidationType } from '@app/core/common/enum/description-template-field-validation-type'; import { DescriptionTemplateFieldValidationType } from '@app/core/common/enum/description-template-field-validation-type';
import { ValidatorURL } from '@app/core/common/enum/validation-type';
import { DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateLabelAndMultiplicityData, DescriptionTemplateUploadData } from '@app/core/model/description-template/description-template'; import { DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateLabelAndMultiplicityData, DescriptionTemplateUploadData } from '@app/core/model/description-template/description-template';
import { StorageFile } from '@app/core/model/storage-file/storage-file'; import { StorageFile } from '@app/core/model/storage-file/storage-file';
import { DescriptionService } from '@app/core/services/description/description.service'; import { DescriptionService } from '@app/core/services/description/description.service';
@ -122,6 +123,11 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn
this.isRequired = this.field.validations?.includes(DescriptionTemplateFieldValidationType.Required); this.isRequired = this.field.validations?.includes(DescriptionTemplateFieldValidationType.Required);
switch (this.field?.data?.fieldType) { switch (this.field?.data?.fieldType) {
case DescriptionTemplateFieldType.FREE_TEXT:
const isUrlRequired = this.field.validations?.includes(DescriptionTemplateFieldValidationType.Url) || false;
if (isUrlRequired) this.propertiesFormGroup?.get(this.field.id).get('textValue').addValidators(ValidatorURL.validator)
break;
case DescriptionTemplateFieldType.TAGS: case DescriptionTemplateFieldType.TAGS:
this.tagsAutoCompleteConfiguration = { this.tagsAutoCompleteConfiguration = {
filterFn: this.filterTags.bind(this), filterFn: this.filterTags.bind(this),