This commit is contained in:
lucio 2023-05-05 15:58:13 +02:00
parent 09879535d2
commit a1b69aee6a
22 changed files with 147 additions and 176 deletions

View File

@ -14,6 +14,7 @@
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">

View File

@ -1,8 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8

View File

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -23,7 +26,10 @@
<wb-module deploy-name="storagehub">
@ -47,7 +53,10 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -71,7 +80,10 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -95,12 +107,17 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
<dependent-module archiveName="storagehub-script-utils-1.0.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/storagehub-scripting-util/storagehub-scripting-util">
<dependent-module archiveName="common-authorization-3.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/authorization-common-library/authorization-common-library">
<dependency-type>uses</dependency-type>
</dependent-module>
@ -124,7 +141,10 @@
<property name="context-root" value="storagehub"/>
@ -148,7 +168,10 @@
<property name="java-output-path" value="/storagehub-webapp_BRANCH/target/classes"/>
@ -172,7 +195,10 @@
</wb-module>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="java" version="1.8"/>
<installed facet="jst.web" version="3.0"/>
<installed facet="jst.jaxrs" version="2.0"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="java" version="1.8"/>
</faceted-project>

View File

@ -8,5 +8,5 @@ FROM smartgears-distribution:4.0.0-java11-tomcat9
COPY ./docker/container.ini /etc/
RUN unzip /tomcat/webapps/storagehub.war -d /tomcat/webapps/storagehub
RUN rm /tomcat/webapps/storagehub.war
COPY ./docker/storage-settings.properties /tomcat/webapps/storagehub/classes/META-INF
COPY ./docker/storage-settings.properties /tomcat/webapps/storagehub/WEB-INF/classes/
RUN sed -i "s/{{adminId}}/$REPOUSER/g; s/{{adminPwd}}/$REPOPWD/g" /tomcat/webapps/storagehub/WEB-INF/web.xml

View File

@ -23,17 +23,16 @@ services:
- '8081:8080'
minio:
image: minio/minio
command:
minio server minio_data:/data
environment:
- "MINIO_ACCESS_KEY=SHUBTEST"
- "MINIO_SECRET_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCY"
ports:
- '9000'
- "9000:9000"
- "9001:9001"
volumes:
- 'minio_data:/data'
- minio_storage:/data
environment:
MINIO_ROOT_USER: SHUBTEST
MINIO_ROOT_PASSWORD: wJalrXUtnFEMI/K7MDENG/bPxRfiCY
command: server --console-address ":9001" /data
volumes:
minio_data:
driver: local
minio_storage: {}

View File

@ -1,44 +1,25 @@
<configuration scan="true" debug="false">
<configuration scan="true" debug="true">
<!-- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> -->
<!-- <encoder> -->
<!-- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> -->
<!-- </encoder> -->
<!-- </appender> -->
<!-- <root level="debug"> -->
<!-- <appender-ref ref="STDOUT" /> -->
<!-- </root> -->
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/tomcat/logs/ghn.log</file>
<append>true</append>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{0}: %msg%n
</pattern>
</encoder>
<rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOGFILE}/ghn.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>Ï
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<logger name="org.gcube" level="DEBUG" />
<logger name="org.gcube.smartgears" level="TRACE" />
<logger name="org.gcube.smartgears.handlers" level="TRACE"/>
<logger name="org.gcube.common.events" level="WARN" />
<logger name="org.gcube.data.publishing" level="ERROR" />
<logger name="org.gcube.documentstore" level="ERROR" />
<logger name="org.gcube.common.core.publisher.is.legacy" level="TRACE" />
<logger name="org.gcube.data.access" level="TRACE" />
<!-- <logger name="org.gcube" level="DEBUG" /> -->
<!-- <logger name="org.gcube.smartgears" level="TRACE" /> -->
<!-- <logger name="org.gcube.smartgears.handlers" level="TRACE"/> -->
<!-- <logger name="org.gcube.common.events" level="WARN" /> -->
<!-- <logger name="org.gcube.data.publishing" level="ERROR" /> -->
<!-- <logger name="org.gcube.documentstore" level="ERROR" /> -->
<!-- <logger name="org.gcube.common.core.publisher.is.legacy" level="TRACE" /> -->
<!-- <logger name="org.gcube.data.access" level="TRACE" /> -->
<root level="TRACE">
<appender-ref ref="FILE" />
<root level="WARN">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -1,10 +1,10 @@
default.bucketName=storagehub-dev
default.key=SHUBTEST
default.secret=wJalrXUtnFEMI/K7MDENG/bPxRfiCY
default.url=https://localhost:9000/
default.url=http://minio:9000
default.createBucket=true
volatile.bucketName=storagehub-volatile-dev
volatile.key=SHUBTEST
volatile.secret=wJalrXUtnFEMI/K7MDENG/bPxRfiCY
volatile.url=https://localhost:9000/
volatile.url=http://minio:9000
volatile.createBucket=true

108
pom.xml
View File

@ -1,29 +1,23 @@
<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>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId>
<version>1.1.0</version>
<relativePath />
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.data.access</groupId>
<artifactId>storagehub</artifactId>
<version>1.5.0-SNAPSHOT</version>
<name>storagehub</name>
<scm>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/storagehub.git</connection>
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/storagehub.git</developerConnection>
<url>https://code-repo.d4science.org/gCubeSystem/storagehub</url>
</scm>
<packaging>war</packaging>
<properties>
<webappDirectory>${project.basedir}/src/main/webapp/WEB-INF</webappDirectory>
<jackrabbit.version>2.20.7</jackrabbit.version>
@ -37,10 +31,9 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<enunciate.version>2.14.0</enunciate.version>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<!-- <maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target> -->
</properties>
<dependencyManagement>
<dependencies>
<dependency>
@ -57,95 +50,73 @@
</dependency>
</dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.tika/tika-parsers -->
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-smartgears</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-smartgears-app</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>authorization-control-library</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>common-authorization</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-encryption</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope-maps</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>storagehub-model</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.data.access</groupId>
<artifactId>storagehub-script-utils</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0)</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.13.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15on -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.62</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>gxJRS</artifactId>
</dependency>
<!-- JCR dependencies -->
<dependency>
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
@ -163,26 +134,21 @@
</dependency>
<!-- <dependency> <groupId>org.apache.jackrabbit</groupId> <artifactId>jackrabbit-jcr-server</artifactId>
<version>${jackrabbit.version}</version> </dependency> -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.tika/tika-core -->
<dependency>
<groupId>org.apache.tika</groupId>
@ -194,58 +160,44 @@
<artifactId>tika-parsers-standard-package</artifactId>
<version>${tika.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-parser-microsoft-module</artifactId>
<version>${tika.version}</version>
</dependency>
<!-- needed to manage strange image types -->
<dependency>
<groupId>com.twelvemonkeys.imageio</groupId>
<artifactId>imageio-jpeg</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>com.twelvemonkeys.imageio</groupId>
<artifactId>imageio-bmp</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>com.twelvemonkeys.imageio</groupId>
<artifactId>imageio-core</artifactId>
<version>3.3.2</version>
</dependency>
<!-- jersey & weld -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.interceptor/javax.interceptor-api -->
<dependency>
<groupId>javax.interceptor</groupId>
<artifactId>javax.interceptor-api</artifactId>
<version>1.2.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.enterprise/cdi-api -->
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
@ -254,14 +206,12 @@
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.inject/jersey-hk2 -->
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>2.30.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
@ -279,74 +229,60 @@
<artifactId>weld-servlet-core</artifactId>
<version>3.1.0.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jboss/jandex -->
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jandex</artifactId>
<version>2.2.2.Final</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-common -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901.jdbc4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>16.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.17</version>
<version>1.22</version>
</dependency>
<dependency>
<groupId>org.tukaani</groupId>
<artifactId>xz</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-simple</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
@ -359,30 +295,30 @@
<version>10.8.2.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>com.vlkan.rfos</groupId>
<artifactId>rotating-fos</artifactId>
<version>0.9.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- enunciate deps -->
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-to-slf4j -->
<!-- https://mvnrepository.com/artifact/org.slf4j/log4j-over-slf4j -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>2.0.7</version>
</dependency>
<!-- enunciate deps
<dependency>
<groupId>com.webcohesion.enunciate</groupId>
<artifactId>enunciate-core-annotations</artifactId>
@ -394,35 +330,29 @@
<artifactId>enunciate-rt-util</artifactId>
<version>${enunciate.version}</version>
<scope>provided</scope>
</dependency>
</dependency> -->
<!-- Storage dependencies -->
<dependency>
<groupId>org.gcube.contentmanagement</groupId>
<artifactId>storage-manager-core</artifactId>
<version>[4.0.0-SNAPSHOT,5.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.contentmanagement</groupId>
<artifactId>storage-manager-wrapper</artifactId>
<version>[4.0.0-SNAPSHOT,5.0.0-SNAPSHOT)</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.minio/minio -->
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>8.3.3</version>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>storagehub-client-library</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
@ -436,15 +366,11 @@
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
@ -512,14 +438,12 @@
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<!-- Enunciate Maven plugin -->
<!-- Enunciate Maven plugin
<plugin>
<groupId>com.webcohesion.enunciate</groupId>
<artifactId>enunciate-maven-plugin</artifactId>
<version>${enunciate.version}</version>
<configuration>
</configuration>
<configuration></configuration>
<executions>
<execution>
<id>assemble</id>
@ -528,8 +452,7 @@
</goals>
</execution>
</executions>
</plugin>
</plugin> -->
<!-- Copy Enunciate Documentation from your-application/docs to your-application.war -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -556,5 +479,4 @@
</plugin>
</plugins>
</build>
</project>

View File

@ -17,7 +17,6 @@ import org.gcube.common.storagehub.model.exceptions.StorageHubException;
import org.gcube.data.access.storagehub.types.LinkType;
import org.gcube.data.access.storagehub.types.PublicLink;
import org.gcube.smartgears.ContextProvider;
import org.gcube.smartgears.provider.ProviderFactory;
@Singleton
public class PublicLinkHandler {

View File

@ -15,8 +15,6 @@ import javax.jcr.version.VersionManager;
import org.apache.jackrabbit.JcrConstants;
import org.gcube.common.storagehub.model.NodeConstants;
import org.gcube.common.storagehub.model.exceptions.BackendGenericError;
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -42,9 +42,9 @@ public class ContentHandlerFactory {
public ContentHandler create(String mimetype) throws Exception{
Class<? extends ContentHandler> handlerClass = handlerMap.get(mimetype);
if (handlerClass!=null)
return handlerClass.newInstance();
return handlerClass.getDeclaredConstructor().newInstance();
else
return defaultHandler.newInstance();
return defaultHandler.getDeclaredConstructor().newInstance();
}
}

View File

@ -179,6 +179,7 @@ public class ItemHandler {
ArchiveEntry entry;
while ((entry = input.getNextEntry()) != null) {
String entirePath = entry.getName();
log.debug("reading new entry ------> ", entirePath);
if (entry.isDirectory()) {
log.debug("creating directory with entire path {} ", entirePath);
createPath(entirePath, directoryNodeMap, parentDirectoryNode, params.getSession(), params.getUser());
@ -201,7 +202,7 @@ public class ItemHandler {
fileNode = createFileItemInternally(params.getSession(), parentNode, input, name, "",fileDetail, params.getUser(), false);
}
fileNodes.add(fileNode);
}catch(Exception e) {
}catch(Throwable e) {
log.warn("error getting file {}",entry.getName(),e);
}
}
@ -394,7 +395,7 @@ public class ItemHandler {
handler.getContent().setPayloadBackend(info.getPayloadBackend());
log.debug("UPLOAD: content payload seta as {} ", handler.getContent().getPayloadBackend());
return handler;
}catch (Exception e) {
}catch (Throwable e) {
throw new BackendGenericError(e);
}

View File

@ -7,13 +7,16 @@ import org.gcube.common.storagehub.model.items.nodes.PayloadBackend;
import org.gcube.data.access.storagehub.handlers.plugins.StorageBackendHandler;
import org.gcube.data.access.storagehub.storage.backend.impl.GcubeMinIoStorageBackendFactory;
import org.gcube.data.access.storagehub.storage.backend.impl.S3Backend;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ReadinessChecker
public class DefaultStorageCheck implements HealthCheck{
private static Logger log = LoggerFactory.getLogger(DefaultStorageCheck.class);
PayloadBackend defaultPayload = StorageBackendHandler.getDefaultPayloadForFolder();
@Override
public String getName() {
return String.format("default storage (%s)",defaultPayload.getStorageName());
@ -22,11 +25,14 @@ public class DefaultStorageCheck implements HealthCheck{
@Override
public HealthCheckResponse check() {
try {
if (((S3Backend)new GcubeMinIoStorageBackendFactory().create(defaultPayload)).isAlive())
GcubeMinIoStorageBackendFactory storageFactory =new GcubeMinIoStorageBackendFactory();
storageFactory.init();
if (((S3Backend)storageFactory.create(defaultPayload)).isAlive())
return HealthCheckResponse.builder(getName()).up().build();
else
return HealthCheckResponse.builder(getName()).down().withMessage("error contacting storage").build();
} catch (Exception e) {
log.error("error checking defaultStorage",e);
return HealthCheckResponse.builder(getName()).down().withMessage(e.getMessage()).build();
}

View File

@ -151,7 +151,7 @@ public class ScriptManager {
}
if (AbstractScript.class.isAssignableFrom(clazz)) {
AbstractScript scriptInstance = (AbstractScript) clazz.newInstance();
AbstractScript scriptInstance = (AbstractScript) clazz.getDeclaredConstructor().newInstance();
ApplicationContext appContext = ContextProvider.get();
String serverHost = appContext.container().configuration().hostname();

View File

@ -54,8 +54,9 @@ public class GcubeMinIoStorageBackendFactory implements StorageBackendFactory {
Map<String, Object> params = new HashMap<String, Object>();
prop.forEach((k,v) -> { if (k.toString().startsWith(PROP_PREFIX)) params.put(k.toString().replace(PROP_PREFIX, ""), v.toString());});
return new Metadata(params);
prop.forEach((k,v) -> { if (k.toString().startsWith(PROP_PREFIX)) params.put(k.toString().replace(PROP_PREFIX, ""), v);});
return new Metadata(params);
} catch (IOException ex) {
throw new RuntimeException("error initializing MinIO", ex);

View File

@ -6,7 +6,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.common.storagehub.model.exceptions.StorageIdNotFoundException;
import org.gcube.common.storagehub.model.items.nodes.Content;
import org.gcube.common.storagehub.model.items.nodes.PayloadBackend;
@ -50,16 +49,20 @@ public class S3Backend extends StorageBackend{
String accessKey = (String)parameters.get("key");
String secret = (String)parameters.get("secret");
String url = (String)parameters.get("url");
boolean createBucket = Boolean.getBoolean((String)parameters.get("createBucket"));
boolean createBucket = Boolean.valueOf((String)parameters.get("createBucket"));
log.debug("parameters are: backetName = {}, url = {}, createBucket = {}",this.bucketName, url, createBucket);
try {
client =
MinioClient.builder()
.endpoint(url)
.credentials(accessKey, secret)
.build();
if (createBucket && !client.bucketExists(BucketExistsArgs.builder().bucket(this.bucketName).build()))
if (createBucket && !client.bucketExists(BucketExistsArgs.builder().bucket(this.bucketName).build())) {
client.makeBucket(MakeBucketArgs.builder().bucket(this.bucketName).build());
log.debug("bucket {} created",this.bucketName);
}
} catch (Exception e) {
log.error("error initializing s3",e);
@ -67,6 +70,19 @@ public class S3Backend extends StorageBackend{
}
}
public boolean isAlive() {
boolean toReturn = true;
try {
client.bucketExists(BucketExistsArgs.builder().bucket(this.bucketName).build());
}catch (Exception e) {
log.error("error checking aliveness",e);
toReturn = false;
}
log.debug("the S3 backend is {} Alive",toReturn?"":"not");
return toReturn;
}
@Override
public MetaInfo onCopy(Content content, String newParentPath, String newName) {

View File

@ -75,7 +75,7 @@
[nthl:readersSet] > nt:base
+ * (nthl:accountingEntryRead)
[nthl:workspaceItem] > mix:referenceable, mix:title, mix:lastModified, nt:hierarchyNode, mix:lockable, mix:shareable
[nthl:workspaceItem] > mix:referenceable, mix:title, mix:lastModified, nt:hierarchyNode, mix:lockable
- hl:portalLogin (String)
- hl:lastAction (String) mandatory
- hl:oldRemotePath (String)

View File

@ -6,6 +6,7 @@ import java.net.URL;
import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.common.security.secrets.AccessTokenSecret;
import org.gcube.common.security.secrets.UmaTokenSecret;
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
import org.junit.Test;
import org.slf4j.Logger;
@ -37,7 +38,7 @@ public class CreateUsers {
}
public void setTokenAndScope() {
AccessTokenSecret secret = new AccessTokenSecret("eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJSSklZNEpoNF9qdDdvNmREY0NlUDFfS1l0akcxVExXVW9oMkQ2Tzk1bFNBIn0.eyJleHAiOjE2NDQyNDM4ODUsImlhdCI6MTY0NDI0MzU4NSwiYXV0aF90aW1lIjoxNjQ0MjQzNTg1LCJqdGkiOiI1NWQ4ZDc5OS1kNTIzLTQ0YmEtYTRkMC1iZjIyYzVlMTg4NzQiLCJpc3MiOiJodHRwczovL2FjY291bnRzLmRldi5kNHNjaWVuY2Uub3JnL2F1dGgvcmVhbG1zL2Q0c2NpZW5jZSIsImF1ZCI6IiUyRmdjdWJlIiwic3ViIjoiNGMxMWRlODQtZGRjOS00ZGQxLWI5N2EtZWE4MmQyZDEzOGE2IiwidHl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.SGuGXnY63WJ45tdypywaopO--FCxY6ZWAX74MGVw_zdNMMQI5zgtGfhZQewFWQ6HhVINDStXqvdSDluhF9JwFXCUGvxB2BipfKQYsAQnm3I4K3kgMl26kuQIL5Im-apw2XWvImTgLshX1AzpyqzFR1Jpf_p65GCMpcHLEwo_nTGLkrZNtfRdtqakZ8S8lowGaV2J2mNf4AHhtARSLJF3GqwynF5pPUXR2iOMUrjw_FLnIuPMfAjk_jHMeYKIxXNBLsoEpELju3pr2gEkv1ZRH9bZkyg7_3hW4mGzxq_Ea9w1FBVJOlkp6vypuISLNyJZcVOnBa4Dg1KRxxlp3aZ6vA");
SecretManagerProvider.instance.set(secret);
}

View File

@ -30,8 +30,8 @@ public class CreateUsers {
private static Logger log = LoggerFactory.getLogger(CreateUsers.class);
private String user ="lucio.lelii";
private String user2 ="pippo.test";
private String user ="pippo.test";
private String user2 ="lucio.lelii";
private String vreWA ="vre-write-all";
private String vreRO ="vre-read-only";
private String vreWO ="vre-write-owner";
@ -53,6 +53,14 @@ public class CreateUsers {
SecretManagerProvider.instance.set(secret);
}
@Test
public void initialiseEnvironment() throws Exception {
this.createUser();
this.createAndAddUserToVREs();
this.createUser2AndAddItToVres();
}
@Test
public void createAccountforManging() throws Exception{
client.createUserAccount("service-account-sg4-test-client");
@ -72,6 +80,15 @@ public class CreateUsers {
System.out.println(SecretManagerProvider.instance.get().getHTTPAuthorizationHeaders());
}
@Test
public void getFolderACLsOnrROVRE() throws Exception {
client.impersonate(user);
FolderContainer vre = (FolderContainer) client.getVREFolders().getContainers().stream().filter(f -> f.get().getTitle().equals(vreWA)).findFirst().get();
FolderContainer folder = (FolderContainer) vre.list().getContainers().stream().findFirst().get();
System.out.println(folder.get().getTitle()+" "+folder.getAcls());
}
@Test
public void createUser() throws Exception{
client.createUserAccount(user);
@ -85,7 +102,7 @@ public class CreateUsers {
}
@Test
public void addUserToVREs() throws Exception{
public void createAndAddUserToVREs() throws Exception{
client.getVreFolderManager(vreWA).createVRE(AccessType.WRITE_ALL, user);
client.getVreFolderManager(vreWA).setAdmin(user);
client.getVreFolderManager(vreRO).createVRE(AccessType.READ_ONLY, user);
@ -95,7 +112,7 @@ public class CreateUsers {
}
@Test
public void createUser2() throws Exception{
public void createUser2AndAddItToVres() throws Exception{
client.impersonate(user);
client.createUserAccount(user2);
client.getVreFolderManager(vreWA).addUser(user2);

View File

@ -5,7 +5,7 @@
</encoder>
</appender>
<root level="trace">
<root level="TRACE">
<appender-ref ref="STDOUT"/>
</root>