solved issue on export
This commit is contained in:
parent
38874c9529
commit
76639ed5f1
|
@ -1,4 +1,4 @@
|
|||
FROM d4science/smartgears-distribution:4.0.0-SNAPSHOT-java17-tomcat10.1.19
|
||||
FROM d4science/smartgears-distribution:4.0.1-SNAPSHOT-java17-tomcat10.1.19
|
||||
COPY ./target/storagehub.war /tomcat/webapps/
|
||||
COPY ./docker/jackrabbit/bootstrap.properties /app/jackrabbit/
|
||||
#COPY ./docker/jackrabbit/bootstrap.properties /app/jackrabbit/
|
||||
COPY ./docker/storagehub.xml /tomcat/conf/Catalina/localhost/
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
FROM d4science/smartgears-distribution:4.0.0-SNAPSHOT-java17-tomcat10.1.19
|
||||
FROM smartgears-distribution:4.0.1-SNAPSHOT-java17-tomcat10.1.19
|
||||
COPY ./target/storagehub.war /tomcat/webapps/
|
||||
COPY ./docker/jackrabbit /app/jackrabbit
|
||||
COPY ./docker/storagehub.xml /tomcat/conf/Catalina/localhost/
|
||||
COPY ./docker/logback.xml /etc/
|
||||
COPY ./docker/container.ini /etc/
|
||||
RUN mkdir -p /etc/config/StorageHub
|
||||
COPY ./docker/storage-settings.properties /etc/config/StorageHub/
|
||||
RUN mkdir -p /etc/config/storagehub
|
||||
COPY ./docker/storage-settings.properties /etc/config/storagehub/
|
|
@ -1,7 +1,7 @@
|
|||
version: '3.7'
|
||||
services:
|
||||
storagehub:
|
||||
image: d4science/staragehub:latest
|
||||
image: d4science/storagehub:latest
|
||||
ports:
|
||||
- '${APP_PORT}:8080'
|
||||
volumes:
|
||||
|
|
|
@ -17,7 +17,7 @@ location = pisa
|
|||
|
||||
[authorization]
|
||||
factory = org.gcube.smartgears.security.defaults.DefaultAuthorizationProviderFactory
|
||||
factory.endpoint = https://accounts.dev.d4science.org/auth/realms/d4science/protocol/openid-connect/token
|
||||
factory.endpoint = https://accounts.cloud-dev.d4science.org/auth/realms/d4science/protocol/openid-connect/token
|
||||
credentials.class = org.gcube.smartgears.security.SimpleCredentials
|
||||
credentials.clientID = node-whn-test-uno-d-d4s.d4science.org
|
||||
credentials.secret = 979bd3bc-5cc4-11ec-bf63-0242ac130002
|
|
@ -40,6 +40,7 @@
|
|||
<AccessManager class="org.apache.jackrabbit.core.security.DefaultAccessManager" />
|
||||
<LoginModule class="org.apache.jackrabbit.core.security.authentication.DefaultLoginModule">
|
||||
<param name="adminId" value="admin" />
|
||||
<param name="adminPassword" value="admin" />
|
||||
</LoginModule>
|
||||
</Security>
|
||||
<!-- location of workspaces root directory and name of default workspace -->
|
||||
|
|
|
@ -4,10 +4,6 @@
|
|||
<param-name>admin-username</param-name>
|
||||
<param-value>admin</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>admin-pwd</param-name>
|
||||
<param-value>admin</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>resolver-basepath</param-name>
|
||||
<param-value>https://data-d.d4science.org/shub</param-value>
|
||||
|
|
17
pom.xml
17
pom.xml
|
@ -22,7 +22,7 @@
|
|||
<packaging>war</packaging>
|
||||
<properties>
|
||||
<webappDirectory>${project.basedir}/src/main/webapp/WEB-INF</webappDirectory>
|
||||
<jackrabbit.version>2.20.7</jackrabbit.version>
|
||||
<jackrabbit.version>2.22.0</jackrabbit.version>
|
||||
<jackson.version>2.15.3</jackson.version>
|
||||
<slf4j.version>2.0.12</slf4j.version>
|
||||
<tika.version>2.6.0</tika.version>
|
||||
|
@ -130,6 +130,8 @@
|
|||
<artifactId>jackrabbit-core</artifactId>
|
||||
<version>${jackrabbit.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- <dependency> <groupId>org.apache.jackrabbit</groupId>
|
||||
<artifactId>jackrabbit-jcr-server</artifactId>
|
||||
<version>${jackrabbit.version}</version> </dependency> -->
|
||||
|
@ -222,10 +224,11 @@
|
|||
<groupId>org.glassfish.jersey.ext.cdi</groupId>
|
||||
<artifactId>jersey-cdi1x-servlet</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.jboss.weld.se/weld-se-core -->
|
||||
<!--
|
||||
https://mvnrepository.com/artifact/org.jboss.weld.servlet/weld-servlet-core -->
|
||||
<dependency>
|
||||
<groupId>org.jboss.weld.se</groupId>
|
||||
<artifactId>weld-se-core</artifactId>
|
||||
<groupId>org.jboss.weld.servlet</groupId>
|
||||
<artifactId>weld-servlet-core</artifactId>
|
||||
<version>5.1.2.Final</version>
|
||||
</dependency>
|
||||
|
||||
|
@ -339,11 +342,7 @@
|
|||
<artifactId>aws-java-sdk-s3</artifactId>
|
||||
<version>1.12.683</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/io.minio/minio
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
|
|
|
@ -55,12 +55,12 @@ public class StorageHubApplicationManager implements ApplicationManager {
|
|||
Path importPath = Paths.get(shubSpecificConf.toString(), "import");
|
||||
Path mainFileImportPath = Paths.get(importPath.toString(), "data.json");
|
||||
if (importPath.toFile().exists() && mainFileImportPath.toFile().exists()) {
|
||||
Session session = null;
|
||||
JackrabbitSession session = null;
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
DumpData data = mapper.readValue(mainFileImportPath.toFile(), DumpData.class);
|
||||
|
||||
session = repository.getRepository().login();
|
||||
session = (JackrabbitSession) repository.getRepository().login(Constants.JCR_CREDENTIALS);
|
||||
|
||||
dh.importData((JackrabbitSession) session, data);
|
||||
session.save();
|
||||
|
|
|
@ -260,7 +260,8 @@ public class Utils {
|
|||
try {
|
||||
destinationNode = params.getSession().getNodeByIdentifier(params.getParentId());
|
||||
destinationItem = (FolderItem) new Node2ItemConverter().getItem(destinationNode, Excludes.ALL);
|
||||
}catch (RepositoryException e) {
|
||||
}catch (RepositoryException e) {
|
||||
logger.error("id not found",e);
|
||||
throw new IdNotFoundException(params.getParentId());
|
||||
}
|
||||
String uniqueName = Utils.checkExistanceAndGetUniqueName(params.getSession(), destinationNode, params.getName());
|
||||
|
|
|
@ -50,9 +50,13 @@ public class DataHandler {
|
|||
|
||||
List<String> groups = groupHandler.getGroups(session);
|
||||
|
||||
logger.debug("found users {} ",usersData);
|
||||
logger.debug("found groups {} ",groups);
|
||||
|
||||
List<GroupData> groupsData = new ArrayList<GroupData>(groups.size());
|
||||
for (String group : groups) {
|
||||
Item vreFolderItem = vreManager.getVRE(group).getVreFolder();
|
||||
logger.debug("serching for group {}",group);
|
||||
Item vreFolderItem = vreManager.getVreFolderItemByGroupName(session, group, null).getVreFolder();
|
||||
String owner = vreFolderItem.getOwner();
|
||||
List<ACL> acls = aclHandler.get(vreFolderItem, session);
|
||||
|
||||
|
@ -91,7 +95,7 @@ public class DataHandler {
|
|||
logger.warn("error adding user {} to group {}", member, g.getName(), t);
|
||||
}
|
||||
|
||||
Item vreFolderItem = vreManager.getVRE(g.getName()).getVreFolder();
|
||||
Item vreFolderItem = vreManager.getVreFolderItemByGroupName(session, g.getName(), null).getVreFolder();
|
||||
|
||||
for (ACL acl : g.getAcls()) {
|
||||
aclHandler.update(acl.getPricipal(), (Node)vreFolderItem.getRelatedNode(), acl.getAccessTypes().get(0), session);
|
||||
|
|
|
@ -55,7 +55,7 @@ public class Item2NodeConverter {
|
|||
String primaryType= ClassHandler.instance().getNodeType(item.getClass());
|
||||
Node newNode = null;
|
||||
if (uuid==null)
|
||||
parentNode.addNode(Text.escapeIllegalJcrChars(item.getName()), primaryType);
|
||||
newNode = parentNode.addNode(Text.escapeIllegalJcrChars(item.getName()), primaryType);
|
||||
else ((NodeImpl)parentNode).addNodeWithUuid(item.getName(), primaryType, uuid);
|
||||
fillNode(newNode, item);
|
||||
return newNode;
|
||||
|
|
|
@ -10,15 +10,9 @@ import javax.jcr.Node;
|
|||
import javax.jcr.RepositoryException;
|
||||
|
||||
import org.apache.jackrabbit.api.JackrabbitSession;
|
||||
import org.apache.jackrabbit.api.security.user.Group;
|
||||
import org.apache.jackrabbit.api.security.user.User;
|
||||
import org.apache.jackrabbit.api.security.user.UserManager;
|
||||
import org.gcube.common.security.ContextBean;
|
||||
import org.gcube.common.security.ContextBean.Type;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.security.secrets.Secret;
|
||||
import org.gcube.common.storagehub.model.exceptions.BackendGenericError;
|
||||
import org.gcube.common.storagehub.model.exceptions.InvalidCallParameters;
|
||||
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
||||
import org.gcube.common.storagehub.model.items.Item;
|
||||
import org.gcube.data.access.storagehub.Constants;
|
||||
|
@ -53,7 +47,7 @@ public class VREManager {
|
|||
ExecutorService executor = Executors.newFixedThreadPool(5);
|
||||
|
||||
|
||||
public synchronized VRE getVRE(String completeName) {
|
||||
private synchronized VRE getVRE(String completeName) {
|
||||
logger.trace("requesting VRE {}",completeName);
|
||||
if (vreMap.containsKey(completeName))
|
||||
return vreMap.get(completeName);
|
||||
|
@ -73,30 +67,19 @@ public class VREManager {
|
|||
|
||||
}
|
||||
|
||||
public synchronized VRE getVreFolderItem(JackrabbitSession ses, String userId, List<String> excludes ) throws RepositoryException, StorageHubException{
|
||||
Secret secret = SecretManagerProvider.get();
|
||||
ContextBean bean = new ContextBean(secret.getContext());
|
||||
public String retrieveGroupNameFromContext(String context) throws StorageHubException{
|
||||
ContextBean bean = new ContextBean(context);
|
||||
if (!bean.is(Type.VRE)) throw new BackendGenericError("the current scope is not a VRE");
|
||||
String entireScopeName= bean.toString().replaceAll("^/(.*)/?$", "$1").replaceAll("/", "-");
|
||||
return getVreFolderItemByGroupName(ses, entireScopeName, userId, excludes);
|
||||
return entireScopeName;
|
||||
}
|
||||
|
||||
|
||||
public synchronized VRE getVreFolderItemByGroupName(JackrabbitSession ses, String groupName, String userId, List<String> excludes ) throws RepositoryException, StorageHubException{
|
||||
UserManager um = ses.getUserManager();
|
||||
Group groupAuth = um.getAuthorizable(groupName, Group.class);
|
||||
User userAuth = um.getAuthorizable(userId, User.class);
|
||||
|
||||
if (groupAuth == null || userAuth == null || !groupAuth.isMember(userAuth))
|
||||
throw new InvalidCallParameters("error getting VRE with user "+userId+" for group "+groupName);
|
||||
|
||||
|
||||
public synchronized VRE getVreFolderItemByGroupName(JackrabbitSession ses, String groupName, List<String> excludes ) throws RepositoryException, StorageHubException{
|
||||
VRE vre = this.getVRE(groupName);
|
||||
if (vre!=null) return vre;
|
||||
else {
|
||||
|
||||
Node vreFolderNode = groupHandler.getFolderNodeRelatedToGroup(ses, groupName);
|
||||
|
||||
Item vreFolder = node2Item.getItem(vreFolderNode, excludes);
|
||||
return this.putVRE(vreFolder);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.gcube.data.access.storagehub.repository.StoragehubRepository;
|
|||
public class JCRRepositoryCheck implements HealthCheck{
|
||||
|
||||
|
||||
StoragehubRepository repository = StoragehubRepository.repository;
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -22,7 +22,7 @@ public class JCRRepositoryCheck implements HealthCheck{
|
|||
@Override
|
||||
public HealthCheckResponse check() {
|
||||
try {
|
||||
Session session = repository.getRepository().login();
|
||||
Session session = StoragehubRepository.repository.getRepository().login();
|
||||
if (session != null) session.logout();
|
||||
return HealthCheckResponse.builder(getName()).up().build();
|
||||
}catch (LoginException e) { }
|
||||
|
|
|
@ -19,9 +19,6 @@ import org.gcube.data.access.storagehub.Constants;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
|
||||
@ApplicationScoped
|
||||
public class JackrabbitRepositoryImpl implements StoragehubRepository {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(JackrabbitRepositoryImpl.class);
|
||||
|
|
|
@ -206,7 +206,6 @@ public class ItemsCreator extends Impersonable{
|
|||
log.debug("UPLOAD: call started");
|
||||
ses = repository.getRepository().login(Constants.JCR_CREDENTIALS);
|
||||
|
||||
|
||||
URLConnection connectionURL = new URI(url).toURL().openConnection();
|
||||
|
||||
long fileLength = connectionURL.getContentLengthLong();
|
||||
|
|
|
@ -176,8 +176,8 @@ public class UserManager {
|
|||
log.error(she.getErrorMessage(), she);
|
||||
GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
|
||||
} catch (RepositoryException re) {
|
||||
log.error("jcr error creating item", re);
|
||||
GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error creating item", re));
|
||||
log.error("jcr error removing item", re);
|
||||
GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error removing item", re));
|
||||
} finally {
|
||||
if (session != null)
|
||||
session.logout();
|
||||
|
|
|
@ -10,6 +10,8 @@ import javax.jcr.Session;
|
|||
|
||||
import org.apache.jackrabbit.api.JackrabbitSession;
|
||||
import org.gcube.common.gxrest.response.outbound.GXOutboundErrorResponse;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.security.secrets.Secret;
|
||||
import org.gcube.common.storagehub.model.Excludes;
|
||||
import org.gcube.common.storagehub.model.Paths;
|
||||
import org.gcube.common.storagehub.model.exceptions.BackendGenericError;
|
||||
|
@ -43,6 +45,7 @@ import org.gcube.data.access.storagehub.handlers.vres.VRE;
|
|||
import org.gcube.data.access.storagehub.handlers.vres.VREManager;
|
||||
import org.gcube.data.access.storagehub.query.sql2.evaluators.Evaluators;
|
||||
import org.gcube.data.access.storagehub.repository.StoragehubRepository;
|
||||
import org.gcube.data.access.storagehub.services.delegates.UserManagerDelegate;
|
||||
import org.gcube.data.access.storagehub.storage.backend.impl.GCubeVolatileStorageBackendFactory;
|
||||
import org.gcube.smartgears.annotations.ManagedBy;
|
||||
import org.gcube.smartgears.utils.InnerMethodName;
|
||||
|
@ -104,6 +107,9 @@ public class WorkspaceManager extends Impersonable {
|
|||
@Inject
|
||||
PublicLinkHandler publicLinkHandler;
|
||||
|
||||
@Inject
|
||||
UserManagerDelegate userHandler;
|
||||
|
||||
@RequestScoped
|
||||
@QueryParam("exclude")
|
||||
private List<String> excludes = Collections.emptyList();
|
||||
|
@ -209,7 +215,15 @@ public class WorkspaceManager extends Impersonable {
|
|||
Item vreItem = null;
|
||||
try {
|
||||
ses = (JackrabbitSession) repository.getRepository().login(Constants.JCR_CREDENTIALS);
|
||||
vreItem = vreManager.getVreFolderItem(ses, currentUser, excludes).getVreFolder();
|
||||
|
||||
Secret secret = SecretManagerProvider.get();
|
||||
|
||||
String groupName= vreManager.retrieveGroupNameFromContext(secret.getContext());
|
||||
|
||||
if (!userHandler.getGroupsPerUser(ses, currentUser).contains(groupName))
|
||||
throw new InvalidCallParameters("error getting VRE with user "+currentUser+" for group "+groupName);
|
||||
|
||||
vreItem = vreManager.getVreFolderItemByGroupName(ses, groupName, excludes).getVreFolder();
|
||||
} catch (RepositoryException re) {
|
||||
log.error("jcr error getting vrefolder", re);
|
||||
GXOutboundErrorResponse.throwException(new BackendGenericError(re));
|
||||
|
@ -233,7 +247,15 @@ public class WorkspaceManager extends Impersonable {
|
|||
try {
|
||||
ses = (JackrabbitSession) repository.getRepository().login(Constants.JCR_CREDENTIALS);
|
||||
|
||||
VRE vre = vreManager.getVreFolderItem(ses, currentUser, excludes);
|
||||
Secret secret = SecretManagerProvider.get();
|
||||
|
||||
String groupName= vreManager.retrieveGroupNameFromContext(secret.getContext());
|
||||
|
||||
if (!userHandler.getGroupsPerUser(ses, currentUser).contains(groupName))
|
||||
throw new InvalidCallParameters("error getting VRE with user "+currentUser+" for group "+groupName);
|
||||
|
||||
VRE vre = vreManager.getVreFolderItemByGroupName(ses, groupName, excludes);
|
||||
|
||||
log.trace("VRE retrieved {}", vre.getVreFolder().getTitle());
|
||||
recentItems = vre.getRecents();
|
||||
log.trace("recents retrieved {}", vre.getVreFolder().getTitle());
|
||||
|
|
|
@ -73,6 +73,10 @@ public class ScriptManager {
|
|||
@Inject
|
||||
ItemHandler itemHandler;
|
||||
|
||||
@Inject
|
||||
DataHandler dataHandler;
|
||||
|
||||
|
||||
@Inject
|
||||
PathUtil pathUtil;
|
||||
|
||||
|
@ -116,10 +120,9 @@ public class ScriptManager {
|
|||
return status;
|
||||
}
|
||||
|
||||
@POST
|
||||
@GET
|
||||
@Path("export")
|
||||
@AuthorizationControl(allowedRoles = {INFRASTRUCTURE_MANAGER_ROLE})
|
||||
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ScriptStatus export() {
|
||||
InnerMethodName.set("export");
|
||||
|
@ -135,8 +138,8 @@ public class ScriptManager {
|
|||
|
||||
JackrabbitSession session = null;
|
||||
try {
|
||||
session = (JackrabbitSession) repository.getRepository().login();
|
||||
DumpData dd = new DataHandler().exportData(session);
|
||||
session = (JackrabbitSession) repository.getRepository().login(Constants.JCR_CREDENTIALS);
|
||||
DumpData dd = dataHandler.exportData(session);
|
||||
ObjectMapper om = new ObjectMapper();
|
||||
status.setSuccess(om.writeValueAsString(dd));
|
||||
log.info("""
|
||||
|
|
|
@ -40,7 +40,6 @@ import org.gcube.data.access.storagehub.PathUtil;
|
|||
import org.gcube.data.access.storagehub.Utils;
|
||||
import org.gcube.data.access.storagehub.handlers.TrashHandler;
|
||||
import org.gcube.data.access.storagehub.handlers.items.builders.FolderCreationParameters;
|
||||
import org.gcube.data.access.storagehub.repository.StoragehubRepository;
|
||||
import org.gcube.data.access.storagehub.services.GroupManager;
|
||||
import org.gcube.data.access.storagehub.services.interfaces.ACLManagerInterface;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -63,12 +62,9 @@ public class GroupManagerDelegate {
|
|||
@Inject
|
||||
ACLManagerInterface aclManagerDelegate;
|
||||
|
||||
private final StoragehubRepository repository = StoragehubRepository.repository;
|
||||
|
||||
public List<String> getGroups(JackrabbitSession session) throws RepositoryException {
|
||||
List<String> groups = new ArrayList<>();
|
||||
session = (JackrabbitSession) repository.getRepository().login(Constants.JCR_CREDENTIALS);
|
||||
|
||||
|
||||
Iterator<Authorizable> result = session.getUserManager().findAuthorizables(new Query() {
|
||||
@Override
|
||||
public <T> void build(QueryBuilder<T> builder) {
|
||||
|
|
Loading…
Reference in New Issue