Compare commits

...

27 Commits

Author SHA1 Message Date
Efstratios Giannopoulos a733b1c4a1 update common models 2024-05-03 11:44:22 +03:00
Efstratios Giannopoulos ab3d1029e8 update common models 2024-05-03 10:46:40 +03:00
Efstratios Giannopoulos 627edfac61 update common models 2024-05-03 09:53:40 +03:00
Efstratios Giannopoulos f1d20dc793 package rename 2024-04-26 14:23:56 +03:00
Efstratios Giannopoulos c7c4200c77 rename to OpenCDMP 2024-04-26 14:14:51 +03:00
Efstratios Giannopoulos e591256956 update common models 2024-04-25 12:00:56 +03:00
Efstratios Giannopoulos 0c6249161e update pom 2024-04-19 11:26:37 +03:00
Efstratios Giannopoulos c424cd95ff update pom 2024-04-10 13:25:28 +03:00
Efstratios Giannopoulos 5815862af8 update deposit controller 2024-03-27 10:17:25 +02:00
Efstratios Giannopoulos d96a2e28fb update pom 2024-03-22 12:43:13 +02:00
Efstratios Giannopoulos 9b0e0cd2cf update config 2024-03-11 13:01:51 +02:00
Efstratios Giannopoulos b9d6d3387b update models 2024-03-05 16:54:33 +02:00
Efstratios Giannopoulos 9f91779802 update models 2024-03-05 16:50:40 +02:00
Efstratios Giannopoulos d6cc4fd597 use commons models 2024-03-01 17:43:17 +02:00
Efstratios Giannopoulos 31e3cbcf12 models refactor 2024-03-01 16:48:54 +02:00
Efstratios Giannopoulos 43739a8f3b update models 2024-03-01 14:43:56 +02:00
Alexandros Mandilaras fbb5f699d3 dont deploy on dockerfile.sonar 2023-12-22 16:31:20 +02:00
Alexandros Mandilaras 09ab082f14 add Dockerfile for sonar analysis 2023-12-22 15:22:39 +02:00
Efstratios Giannopoulos 0b64ec24b1 add dev profile to settings 2023-12-13 11:31:32 +02:00
Efstratios Giannopoulos d40e58d06c add dev profile to settings 2023-12-13 11:27:10 +02:00
Efstratios Giannopoulos 08624cbe74 build docker change 2023-12-13 11:18:49 +02:00
Efstratios Giannopoulos 9a03afe8f3 fix maven version 2023-12-13 11:14:58 +02:00
Efstratios Giannopoulos 4bcfc9b49b add missing arg to docker file 2023-12-13 11:06:05 +02:00
Efstratios Giannopoulos ddb4fe70bd add dev profile to pom 2023-12-13 11:01:55 +02:00
Efstratios Giannopoulos 967d0e5f91 sync with new models 2023-12-12 16:56:36 +02:00
Efstratios Giannopoulos 685a30b2cd sync with new models 2023-12-11 17:15:33 +02:00
Efstratios Giannopoulos b33611e700 sync with new models 2023-12-07 18:11:03 +02:00
19 changed files with 219 additions and 483 deletions

View File

@ -1,4 +1,4 @@
FROM maven:3.8.6-eclipse-temurin-17-focal
FROM maven:3-eclipse-temurin-21
RUN apt-get update
RUN apt-get install gpg -y
@ -9,6 +9,8 @@ ARG REVISION
ARG MAVEN_GPG_PASSPHRASE
ARG MAVEN_GPG_KEYNAME
ARG PROFILE
ARG DEV_PROFILE_URL_DEPOSIT
ARG DEV_PROFILE_URL
ENV gpg_keyname=$MAVEN_GPG_KEYNAME
ENV gpg_passphrase=$MAVEN_GPG_PASSPHRASE
ENV server_username=$MAVEN_ACCOUNT_USR
@ -24,4 +26,4 @@ WORKDIR /build/
COPY . .
RUN mvn -Drevision=${REVISION} -P${PROFILE} clean deploy
RUN mvn -Drevision=${REVISION} -DdevProfileUrlDeposit=${DEV_PROFILE_URL_DEPOSIT} -DdevProfileUrl=${DEV_PROFILE_URL} -P${PROFILE} clean deploy

37
Dockerfile.Sonar Normal file
View File

@ -0,0 +1,37 @@
FROM maven:3-eclipse-temurin-21
RUN apt-get update \
&& apt-get install gpg -y \
&& apt-get clean
ARG MAVEN_ACCOUNT_USR
ARG MAVEN_ACCOUNT_PSW
ARG REVISION
ARG MAVEN_GPG_PASSPHRASE
ARG MAVEN_GPG_KEYNAME
ARG PROFILE
ARG DEV_PROFILE_URL_DEPOSIT
ARG DEV_PROFILE_URL
ARG ORACLE_URL
ARG ORACLE_TOKEN
ENV gpg_keyname=$MAVEN_GPG_KEYNAME
ENV gpg_passphrase=$MAVEN_GPG_PASSPHRASE
ENV server_username=$MAVEN_ACCOUNT_USR
ENV server_password=$MAVEN_ACCOUNT_PSW
COPY settings.xml /root/.m2/settings.xml
COPY keypair.asc /tmp/keypair.asc
RUN if [ "$PROFILE" = "ossrh" ]; then \
gpg --batch --import /tmp/keypair.asc; \
fi
COPY oracle.local.cite.gr.crt $JAVA_HOME/conf/security
RUN cd $JAVA_HOME/conf/security && keytool -cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias oraclecert -file oracle.local.cite.gr.crt
WORKDIR /build/
COPY . .
RUN mvn -Drevision=${REVISION} -DdevProfileUrlDeposit=${DEV_PROFILE_URL_DEPOSIT} -DdevProfileUrl=${DEV_PROFILE_URL} -P${PROFILE} clean install
RUN mvn sonar:sonar -Dsonar.projectKey=OpenDMP:repository-deposit-base -Dsonar.login=${ORACLE_TOKEN} -Dsonar.host.url=${ORACLE_URL} -Dsonar.projectName='OpenDMP repository-deposit-base'

64
pom.xml
View File

@ -2,20 +2,19 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.4</version>
<relativePath/>
</parent>
<groupId>gr.cite.opendmp</groupId>
<groupId>org.opencdmp</groupId>
<artifactId>repositorydepositbase</artifactId>
<version>${revision}</version>
<packaging>jar</packaging>
<!-- <devProfileId>${devProfileId}</devProfileId>-->
<!-- <devProfileName>${devProfileName}</devProfileName>-->
<!-- <devProfileUrl>${devProfileUrl}</devProfileUrl>-->
<!-- <devProfileUrlDeposit>${devProfileUrlDeposit}</devProfileUrlDeposit>-->
<name>OpenDMP Repository Deposit Base</name>
<description>OpenDMP Repository Deposit Base</description>
<name>OpenCDMP Repository Deposit Base</name>
<description>OpenCDMP Repository Deposit Base</description>
<url>https://code-repo.d4science.org/MaDgiK-CITE/repository-deposit-base</url>
<licenses>
<license>
@ -40,14 +39,34 @@
<properties>
<revision>1.0.0-SNAPSHOT</revision>
<java.version>21</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<dependency>
<groupId>org.opencdmp</groupId>
<artifactId>common-models</artifactId>
<version>0.0.14</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>6.1.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
@ -133,6 +152,23 @@
</plugins>
</build>
</profile>
<profile>
<id>dev</id>
<repositories>
<repository>
<id>dev</id>
<name>Dev Profile</name>
<url>${devProfileUrl}</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>dev</id>
<name>Dev Profile</name>
<url>${devProfileUrlDeposit}</url>
</repository>
</distributionManagement>
</profile>
</profiles>
</project>

View File

@ -5,6 +5,11 @@
<username>${server_username}</username>
<password>${server_password}</password>
</server>
<server>
<id>dev</id>
<username>${server_username}</username>
<password>${server_password}</password>
</server>
</servers>
<profiles>
<profile>

View File

@ -1,49 +0,0 @@
package eu.eudat.depositinterface.enums;
public enum FieldType {
COMBO_BOX("combobox"),
BOOLEAN_DECISION("booleanDecision"),
RADIO_BOX("radiobox"),
INTERNAL_DMP_ENTRIES("internalDmpEntities"),
CHECK_BOX("checkBox"),
FREE_TEXT("freetext"),
TEXT_AREA("textarea"),
RICH_TEXT_AREA("richTextarea"),
UPLOAD("upload"),
TABLE("table"),
DATE_PICKER("datePicker"),
EXTERNAL_DATASETS("externalDatasets"),
DATA_REPOSITORIES("dataRepositories"),
JOURNAL_REPOSITORIES("journalRepositories"),
PUB_REPOSITORIES("pubRepositories"),
LICENSES("licenses"),
TAXONOMIES("taxonomies"),
PUBLICATIONS("publications"),
REGISTRIES("registries"),
SERVICES("services"),
TAGS("tags"),
RESEARCHERS("researchers"),
ORGANIZATIONS("organizations"),
DATASET_IDENTIFIER("datasetIdentifier"),
CURRENCY("currency"),
VALIDATION("validation");
private final String name;
FieldType(String name) {
this.name = name;
}
public String getName() {
return name;
}
public static FieldType fromName(String name) {
for (FieldType fieldType : FieldType.values()) {
if (name.equals(fieldType.getName())) {
return fieldType;
}
}
throw new IllegalArgumentException("View Style Type [" + name + "] is not valid");
}
}

View File

@ -1,129 +0,0 @@
package eu.eudat.depositinterface.models;
import java.io.File;
import java.util.List;
import java.util.Set;
import java.util.UUID;
public class DMPDepositModel {
private UUID id;
private int version;
private String label;
private String description;
private boolean isPublic;
private List<DatasetDepositModel> datasets;
private Set<UserDMPDepositModel> users;
private Set<OrganisationDepositModel> organisations;
private Set<ResearcherDepositModel> researchers;
private GrantDepositModel grant;
private FileEnvelope pdfFile;
private FileEnvelope rdaJsonFile;
private File supportingFilesZip;
private String previousDOI;
private String extraProperties;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public boolean isPublic() {
return isPublic;
}
public void setPublic(boolean aPublic) {
isPublic = aPublic;
}
public List<DatasetDepositModel> getDatasets() {
return datasets;
}
public void setDatasets(List<DatasetDepositModel> datasets) {
this.datasets = datasets;
}
public Set<UserDMPDepositModel> getUsers() {
return users;
}
public void setUsers(Set<UserDMPDepositModel> users) {
this.users = users;
}
public Set<OrganisationDepositModel> getOrganisations() {
return organisations;
}
public void setOrganisations(Set<OrganisationDepositModel> organisations) {
this.organisations = organisations;
}
public Set<ResearcherDepositModel> getResearchers() {
return researchers;
}
public void setResearchers(Set<ResearcherDepositModel> researchers) {
this.researchers = researchers;
}
public GrantDepositModel getGrant() {
return grant;
}
public void setGrant(GrantDepositModel grant) {
this.grant = grant;
}
public FileEnvelope getPdfFile() {
return pdfFile;
}
public void setPdfFile(FileEnvelope pdfFile) {
this.pdfFile = pdfFile;
}
public FileEnvelope getRdaJsonFile() {
return rdaJsonFile;
}
public void setRdaJsonFile(FileEnvelope rdaJsonFile) {
this.rdaJsonFile = rdaJsonFile;
}
public File getSupportingFilesZip() {
return supportingFilesZip;
}
public void setSupportingFilesZip(File supportingFilesZip) {
this.supportingFilesZip = supportingFilesZip;
}
public String getPreviousDOI() {
return previousDOI;
}
public void setPreviousDOI(String previousDOI) {
this.previousDOI = previousDOI;
}
public String getExtraProperties() {
return extraProperties;
}
public void setExtraProperties(String extraProperties) {
this.extraProperties = extraProperties;
}
}

View File

@ -1,46 +0,0 @@
package eu.eudat.depositinterface.models;
import java.util.List;
public class DatasetDepositModel {
private String label;
private String description;
private String profileDefinition;
private String properties;
private List<DatasetFieldsDepositModel> fields;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getProfileDefinition() {
return profileDefinition;
}
public void setProfileDefinition(String profileDefinition) {
this.profileDefinition = profileDefinition;
}
public String getProperties() {
return properties;
}
public void setProperties(String properties) {
this.properties = properties;
}
public List<DatasetFieldsDepositModel> getFields() {
return fields;
}
public void setFields(List<DatasetFieldsDepositModel> fields) {
this.fields = fields;
}
}

View File

@ -1,38 +0,0 @@
package eu.eudat.depositinterface.models;
import java.util.List;
public class DatasetFieldsDepositModel {
private String renderStyleType;
private List<String> schematics;
private Object value;
private boolean multiple;
public String getRenderStyleType() {
return renderStyleType;
}
public void setRenderStyleType(String renderStyleType) {
this.renderStyleType = renderStyleType;
}
public List<String> getSchematics() {
return schematics;
}
public void setSchematics(List<String> schematics) {
this.schematics = schematics;
}
public Object getValue() {
return value;
}
public void setValue(Object value) {
this.value = value;
}
public boolean isMultiple() {
return multiple;
}
public void setMultiple(boolean multiple) {
this.multiple = multiple;
}
}

View File

@ -1,22 +0,0 @@
package eu.eudat.depositinterface.models;
import java.io.File;
public class FileEnvelope {
private String filename;
private File file;
public String getFilename() {
return filename;
}
public void setFilename(String filename) {
this.filename = filename;
}
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
}

View File

@ -1,12 +0,0 @@
package eu.eudat.depositinterface.models;
public class FunderDepositModel {
private String label;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
}

View File

@ -1,30 +0,0 @@
package eu.eudat.depositinterface.models;
import java.util.UUID;
public class GrantDepositModel {
private UUID id;
private String reference;
private FunderDepositModel funder;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public FunderDepositModel getFunder() {
return funder;
}
public void setFunder(FunderDepositModel funder) {
this.funder = funder;
}
}

View File

@ -1,12 +0,0 @@
package eu.eudat.depositinterface.models;
public class OrganisationDepositModel {
private String label;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
}

View File

@ -1,20 +0,0 @@
package eu.eudat.depositinterface.models;
public class ResearcherDepositModel {
private String label;
private String reference;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
}

View File

@ -1,47 +0,0 @@
package eu.eudat.depositinterface.models;
public class UserDMPDepositModel {
public enum UserDMPRoles {
OWNER(0), USER(1);
private int value;
UserDMPRoles(int value) {
this.value = value;
}
public int getValue() {
return value;
}
public static UserDMPRoles fromInteger(int value) {
switch (value) {
case 0:
return OWNER;
case 1:
return USER;
default:
throw new RuntimeException("Unsupported User Dmp Role Message Code");
}
}
}
private UserInfoDepositModel user;
private Integer role;
public UserInfoDepositModel getUser() {
return user;
}
public void setUser(UserInfoDepositModel user) {
this.user = user;
}
public Integer getRole() {
return role;
}
public void setRole(Integer role) {
this.role = role;
}
}

View File

@ -1,20 +0,0 @@
package eu.eudat.depositinterface.models;
public class UserInfoDepositModel {
private String name;
private String email;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}

View File

@ -0,0 +1,30 @@
package org.opencdmp.depositbase.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import org.opencdmp.commonmodels.enums.EnumUtils;
import org.opencdmp.commonmodels.enums.EnumValueProvider;
import java.util.Map;
public enum DepositType implements EnumValueProvider<Short> {
SystemDeposit((short) 0), UserDeposit((short) 1), BothWaysDeposit((short) 2);
private final Short value;
DepositType(Short value) {
this.value = value;
}
@Override
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DepositType> map = EnumUtils.getEnumValueMap(DepositType.class);
public static DepositType of(Short i) {
return map.get(i);
}
}

View File

@ -1,21 +1,19 @@
package eu.eudat.depositinterface.repository;
package org.opencdmp.depositbase.repository;
import eu.eudat.depositinterface.models.DMPDepositModel;
import java.util.List;
import org.opencdmp.commonmodels.models.dmp.DmpModel;
/**
* The RepositoryDeposit interface represents the mechanism of depositing a dmp to any
* repository which mints a persistent digital object identifier (DOI) for each submission,
* which makes the stored dmps easily citeable.
*/
public interface RepositoryDeposit {
public interface DepositClient {
/**
* Returns a string representing the persistent digital object identifier (DOI) which
* was created.
*
* @param repositoryId the id of the repository
* @param dmpDepositModel dmp structure which is to be deposited
* @param repositoryAccessToken access token needed for the authentication to the repository
* if this is null, another authentication mechanism is used for
@ -24,16 +22,15 @@ public interface RepositoryDeposit {
* @return a string representing the persistent digital object identifier (DOI)
* @throws Exception if an error occurs while trying to deposit the dmp
*/
String deposit(String repositoryId, DMPDepositModel dmpDepositModel, String repositoryAccessToken) throws Exception;
String deposit(DmpModel dmpDepositModel, String repositoryAccessToken) throws Exception;
/**
* Returns the access token from the oauth2 flow.
*
* @param repositoryId the id of the repository
* @param code oauth2 authorization code
* @return the access token or null if no oauth2 protocol is not supported for that repository
*/
String authenticate(String repositoryId, String code);
String authenticate(String code);
/**
* Returns the repository's configuration.
@ -55,14 +52,13 @@ public interface RepositoryDeposit {
* repositoryClientSecret - repository's client secret<br>
* redirectUri - redirect uri to argos after the oauth2 flow from the repository<br>
*/
List<RepositoryDepositConfiguration> getConfiguration();
DepositConfiguration getConfiguration();
/**
* Returns the repository's logo if exists.
*
* @param repositoryId the id of the repository
* @return the repository's logo in base64 form
* */
String getLogo(String repositoryId);
String getLogo();
}

View File

@ -1,35 +1,10 @@
package eu.eudat.depositinterface.repository;
package org.opencdmp.depositbase.repository;
public class RepositoryDepositConfiguration {
import org.opencdmp.depositbase.enums.DepositType;
public enum DepositType {
SystemDeposit(0), UserDeposit(1), BothWaysDeposit(2);
public class DepositConfiguration {
private int value;
DepositType(int value) {
this.value = value;
}
public int getValue() {
return value;
}
public static DepositType fromInteger(int value) {
switch (value) {
case 0:
return SystemDeposit;
case 1:
return UserDeposit;
case 2:
return BothWaysDeposit;
default:
throw new RuntimeException("Unsupported Deposit Account Type");
}
}
}
private int depositType;
private DepositType depositType;
private String repositoryId;
private String accessToken;
private String repositoryUrl;
@ -39,12 +14,13 @@ public class RepositoryDepositConfiguration {
private String repositoryClientId;
private String repositoryClientSecret;
private String redirectUri;
private boolean useSharedStorage;
private boolean hasLogo;
public int getDepositType() {
public DepositType getDepositType() {
return depositType;
}
public void setDepositType(int depositType) {
public void setDepositType(DepositType depositType) {
this.depositType = depositType;
}
@ -117,4 +93,12 @@ public class RepositoryDepositConfiguration {
public void setHasLogo(boolean hasLogo) {
this.hasLogo = hasLogo;
}
public boolean isUseSharedStorage() {
return useSharedStorage;
}
public void setUseSharedStorage(boolean useSharedStorage) {
this.useSharedStorage = useSharedStorage;
}
}

View File

@ -0,0 +1,71 @@
package org.opencdmp.depositbase.repository;
import org.opencdmp.commonmodels.models.dmp.DmpModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
* The RepositoryDeposit interface represents the mechanism of depositing a dmp to any
* repository which mints a persistent digital object identifier (DOI) for each submission,
* which makes the stored dmps easily citeable.
*/
public interface DepositController {
/**
* Returns a string representing the persistent digital object identifier (DOI) which
* was created.
*
* @param dmpDepositModel dmp structure which is to be deposited
* @param authToken access token needed for the authentication to the repository
* if this is null, another authentication mechanism is used for
* that repository e.g. api token which will be fetched from the
* repository's configuration
* @return a string representing the persistent digital object identifier (DOI)
* @throws Exception if an error occurs while trying to deposit the dmp
*/
@PostMapping()
String deposit(@RequestBody DmpModel dmpDepositModel, @RequestParam("authToken")String authToken) throws Exception;
/**
* Returns the access token from the oauth2 flow.
*
* @param code oauth2 authorization code
* @return the access token or null if no oauth2 protocol is not supported for that repository
*/
@GetMapping("/authenticate")
String authenticate(@RequestParam("authToken") String code);
/**
* Returns the repository's configuration.
*
* @return List of structure representing the configuration of the repository <br>
* which includes the following fields: <br>
* depositType - an integer representing how the dmp user can deposit in the repository,
* 0 stands for system deposition meaning the dmp is deposited using argos credentials to the
* repository, 1 stands for user deposition in which the argos user specifies his/her own credentials
* to the repository, 2 stands for both ways deposition if the repository allows the deposits of dmps
* to be made from both argos and users accounts<br>
* repositoryId - unique identifier for the repository<br>
* accessToken - access token provided for the system type deposits<br>
* repositoryUrl - repository url<br>
* repositoryAuthorizationUrl - repository's authorization url<br>
* repositoryRecordUrl - repository's record url, this url is used to index dmps that are created<br>
* repositoryAccessTokenUrl - repository's access token url<br>
* repositoryClientId - repository's client id<br>
* repositoryClientSecret - repository's client secret<br>
* redirectUri - redirect uri to argos after the oauth2 flow from the repository<br>
*/
@GetMapping("/configuration")
DepositConfiguration getConfiguration();
/**
* Returns the repository's logo if exists.
*
* @return the repository's logo in base64 form
* */
@GetMapping("/logo")
String getLogo();
}