Skip to content

Commit

Permalink
[Backport 4.2.x] Move datastorage providers to maven modules and incl…
Browse files Browse the repository at this point in the history
…ude them in the build on demand.

Backport geonetwork#7302
  • Loading branch information
josegar74 committed Dec 13, 2024
1 parent 0217f74 commit 9a7ea77
Show file tree
Hide file tree
Showing 40 changed files with 1,204 additions and 47 deletions.
29 changes: 1 addition & 28 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -391,29 +391,6 @@
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.apache.jclouds</groupId>
<artifactId>jclouds-all</artifactId>
<version>2.5.0</version>
</dependency>

<dependency>
<groupId>org.apache.chemistry.opencmis</groupId>
<artifactId>chemistry-opencmis-client-api</artifactId>
<version>1.1.0</version>
</dependency>

<dependency>
<groupId>org.apache.chemistry.opencmis</groupId>
<artifactId>chemistry-opencmis-client-impl</artifactId>
<version>1.1.0</version>
<exclusions>
<exclusion>
<groupId>xml-resolver</groupId>
<artifactId>xml-resolver</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.tmatesoft.svnkit</groupId>
Expand Down Expand Up @@ -593,11 +570,7 @@
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.12.261</version>
</dependency>

<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/config-spring-geonetwork.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,5 +251,5 @@
s3 - AWS S3 storage (see config-store/config-s3.xml for more details)
cmis - CMIS storage (see config-store/config-cmis.xml for more details)
-->
<import resource="config-store/config-${geonetwork.store.type:default}.xml"/>
<import resource="classpath*:/config-store/config-${geonetwork.store.type:default}.xml"/>
</beans>
12 changes: 12 additions & 0 deletions datastorages/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Data storage

Extensions for data storage (used for storage resources such as record attachments and thumbnails).

Core provides the default implementation for a data directory:

* org.fao.geonet.resource.FileResources

For more information see:

* org.fao.geonet.resource.Resources

11 changes: 11 additions & 0 deletions datastorages/cmis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# CMIS Data storage

Extension for data storage (used for storage resources such as record attachments and thumbnails).

* cmis: content management interoperability services

This data storage is based on the Apache Chemistry project which has been retired.

Reference:

* https://chemistry.apache.org/java/opencmis.html
208 changes: 208 additions & 0 deletions datastorages/cmis/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (C) 2001-2023 Food and Agriculture Organization of the
~ United Nations (FAO-UN), United Nations World Food Programme (WFP)
~ and United Nations Environment Programme (UNEP)
~
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation; either version 2 of the License, or (at
~ your option) any later version.
~
~ This program is distributed in the hope that it will be useful, but
~ WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program; if not, write to the Free Software
~ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
~
~ Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
~ Rome - Italy. email: [email protected]
-->

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>gn-datastorages</artifactId>
<groupId>org.geonetwork-opensource.datastorage</groupId>
<version>4.2.12-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>gn-datastorage-cmis</artifactId>
<name>CMIS datastorage</name>

<dependencies>
<dependency>
<groupId>org.geonetwork-opensource</groupId>
<artifactId>gn-core</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.chemistry.opencmis</groupId>
<artifactId>chemistry-opencmis-client-api</artifactId>
</dependency>

<dependency>
<groupId>org.apache.chemistry.opencmis</groupId>
<artifactId>chemistry-opencmis-client-impl</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>test-jar</id>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>

<profiles>
<profile>
<id>run-static-analysis</id>
<activation>
<property>
<name>!skipTests</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
<!-- Profile to release datastorage bundle -->
<profile>
<id>release</id>
<activation>
<property>
<!-- include when making a release -->
<name>release</name>
</property>
</activation>
<build>
<plugins>
<!-- stage jars for assembly -->
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>stage-libs</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<!-- libs to include are managed here rather than in assembly -->
<configuration>
<silent>true</silent>
<includeScope>runtime</includeScope>
<excludeScope>provided</excludeScope>
<excludeGroupIds>com.google.code.findbugs</excludeGroupIds>
<excludeTransitive>false</excludeTransitive>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
<!-- generate html conrtents-->
<plugin>
<groupId>com.ruleoftech</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
<executions>
<execution>
<id>readme</id>
<phase>process-resources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputDirectory>${project.basedir}/src/main/assembly</inputDirectory>
<outputDirectory>${project.build.directory}/html</outputDirectory>
</configuration>
</execution>
<execution>
<id>licenses</id>
<phase>process-resources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputDirectory>${project.basedir}/../../</inputDirectory>
<outputDirectory>${project.build.directory}/html/license</outputDirectory>
</configuration>
</execution>
</executions>
<configuration>
<recursiveInput>false</recursiveInput>
<transformRelativeMarkdownLinks>true</transformRelativeMarkdownLinks>
<headerHtmlFile>${project.basedir}/../../release/src/markdown/html/header.html</headerHtmlFile>
<footerHtmlFile>${project.basedir}/../../release/src/markdown/html/footer.html</footerHtmlFile>
<pegdownExtensions>TABLES,FENCED_CODE_BLOCKS</pegdownExtensions>
<defaultTitle>true</defaultTitle>
</configuration>
</plugin>
<!-- assemble into zip for release -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>release-zip</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${project.artifactId}-${project.version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<properties>
<rootProjectDir>${basedir}/..</rootProjectDir>
</properties>
</project>
27 changes: 27 additions & 0 deletions datastorages/cmis/src/main/assembly/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# CMIS data storage provider library

To install the CMIS data storage provider in GeoNetwork:

1. Copy the `lib` folder jar files into to `{GEONETWORK_DIR}/WEB-INF/lib` folder.

2. Define the following environmental variables:

- Use CMIS data storage provider:

```bash
export GEONETWORK_STORE_TYPE=cmis
```

- Setup CMIS connection (check with your setup):

```bash
export CMIS_REPOSITORY_ID=-default-
export CMIS_USERNAME=username
export CMIS_PASSWORD=password
export CMIS_SERVICES_BASE_URL=http://localhost:8080/alfresco
export CMIS_BASE_REPOSITORY_PATH=geonetwork
export CMIS_BINDING_TYPE=browser
export CMIS_BROWSER_URL=/api/-default-/public/cmis/versions/1.1/browser
```

3. Start GeoNetwork
31 changes: 31 additions & 0 deletions datastorages/cmis/src/main/assembly/assembly.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>bin</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.build.directory}/lib</directory>
<outputDirectory>/lib</outputDirectory>
</fileSet>
</fileSets>

<files>
<file>
<source>${project.build.directory}/${project.artifactId}-${project.version}.jar</source>
<outputDirectory>/lib</outputDirectory>
</file>

<file>
<source>${project.build.directory}/html/README.html</source>
<outputDirectory>/</outputDirectory>
</file>

<file>
<source>${project.build.directory}/html/license/LICENSE.html</source>
<outputDirectory>/license</outputDirectory>
</file>
</files>
</assembly>
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public ResourceHolder getResource(final ServiceContext context, final String met

@Override
public ResourceHolder getResourceInternal(String metadataUuid, MetadataResourceVisibility visibility, String resourceId, Boolean approved) throws Exception {
int metadataId = getAndCheckMetadataId(metadataUuid, approved);
int metadataId = AbstractStore.getAndCheckMetadataId(metadataUuid, approved);
checkResourceId(resourceId);

try {
Expand Down Expand Up @@ -483,7 +483,7 @@ protected boolean tryDelResource(final ServiceContext context, final String meta
@Override
public MetadataResource getResourceDescription(final ServiceContext context, final String metadataUuid,
final MetadataResourceVisibility visibility, final String filename, Boolean approved) throws Exception {
int metadataId = getAndCheckMetadataId(metadataUuid, approved);
int metadataId = AbstractStore.getAndCheckMetadataId(metadataUuid, approved);
final String key = getKey(context, metadataUuid, metadataId, visibility, filename);

try {
Expand All @@ -496,7 +496,7 @@ public MetadataResource getResourceDescription(final ServiceContext context, fin

@Override
public MetadataResourceContainer getResourceContainerDescription(final ServiceContext context, final String metadataUuid, Boolean approved) throws Exception {
int metadataId = getAndCheckMetadataId(metadataUuid, approved);
int metadataId = AbstractStore.getAndCheckMetadataId(metadataUuid, approved);

final String key = getMetadataDir(context, metadataId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ protected Path findImagePath(final String imageName, final Path logosDir) {
for (CmisObject object : children) {
if (object instanceof Document) {
String ext = FilenameUtils.getExtension(object.getName());
if (IMAGE_EXTENSIONS.contains(ext.toLowerCase())) {
if (Resources.IMAGE_EXTENSIONS.contains(ext.toLowerCase())) {
//Todo not sure if name will be correct.
return getKeyPath(((Document) object).getName());
}
Expand Down Expand Up @@ -285,7 +285,7 @@ protected Path locateResource(@Nullable final Path resourcesDir, final ServletCo
final String suffix = FilenameUtils.getExtension(key);

// find a different format and convert it to our desired format
if (IMAGE_WRITE_SUFFIXES.contains(suffix.toLowerCase())) {
if (Resources.IMAGE_WRITE_SUFFIXES.contains(suffix.toLowerCase())) {
final String suffixless = FilenameUtils.removeExtension(key);
final String suffixlessKeyFilename = FilenameUtils.getName(suffixless);
final String suffixlessKeyFolder = getKey(Paths.get(FilenameUtils.getFullPath(suffixless)));
Expand All @@ -298,7 +298,7 @@ protected Path locateResource(@Nullable final Path resourcesDir, final ServletCo
Document object = entry.getValue();
String cmisFilePath = entry.getKey();
final String ext = FilenameUtils.getExtension(object.getName()).toLowerCase();
if (IMAGE_READ_SUFFIXES.contains(ext)) {
if (Resources.IMAGE_READ_SUFFIXES.contains(ext)) {
try (ResourceHolder in = new CMISResourceHolder(object.getName(), true);
ResourceHolder out = new CMISResourceHolder(key, true)) {
try (InputStream inS = IO.newInputStream(in.getPath());
Expand Down
Loading

0 comments on commit 9a7ea77

Please sign in to comment.