added scripts

This commit is contained in:
lucio 2024-08-06 11:04:44 +02:00
parent 3631e00a90
commit ba412f8154
6 changed files with 21 additions and 29 deletions

View File

@ -12,7 +12,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-bom</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.0.1-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@ -27,15 +27,15 @@
</parent>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
</properties>
<dependencies>
<dependency>
<groupId>org.gcube.data.access</groupId>
<artifactId>storagehub-script-utils</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0)</version>
<version>[2.0.0-SNAPSHOT,3.0.0)</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -10,8 +10,10 @@ import javax.jcr.NodeIterator;
import javax.jcr.PathNotFoundException;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
import javax.jcr.version.VersionHistory;
import org.apache.jackrabbit.api.JackrabbitSession;
import org.gcube.common.storagehub.model.NodeConstants;
import org.gcube.common.storagehub.model.Path;
import org.gcube.common.storagehub.model.Paths;
import org.gcube.common.storagehub.model.items.Item;
@ -33,27 +35,17 @@ public class GeneralScript implements AbstractScript{
try {
log.info("script started");
Node home = session.getNode("/Home/emmanuel.blondel");
long start = System.currentTimeMillis();
stringBuilder.append("\n").append("cleaning trash of ").append(home.getName());
Node trashNode = null;
stringBuilder.append("\nversion of the trash is " ).append(home.getProperty("hl:version").getLong());
NodeIterator it = home.getNodes();
while (it.hasNext()) {
Node node = it.nextNode();
stringBuilder.append("\n").append(node.getPath());
}
Node home = session.getNodeByIdentifier("cbf7b63b-172d-49bd-a671-4d39a39cd216");
Node contentNode = home.getNode("jcr:content");
VersionHistory history = contentNode.getSession().getWorkspace().getVersionManager().getVersionHistory(contentNode.getPath());
//contentNode.restore("1.0", true);
history.removeVersion("1.1");
stringBuilder.append("node updated \n");
session.save();
}catch (Exception e) {
StringWriter writer = new StringWriter();
PrintWriter sw = new PrintWriter(writer, true);

View File

@ -92,8 +92,8 @@ public class MongoToMinIOPortingSharedFolder implements AbstractScript{
for (StorageBackendFactory factory : factories) {
if (factory.getName() == Constants.MONGO_STORAGE)
mongo = factory.create(file.getContent().getPayloadBackend());
if (factory.getName() == Constants.DEFAULT_MINIO_STORAGE) {
minio = factory.create(new PayloadBackend(Constants.DEFAULT_MINIO_STORAGE, null));
if (factory.getName() == Constants.DEFAULT_S3_STORAGE) {
minio = factory.create(new PayloadBackend(Constants.DEFAULT_S3_STORAGE, null));
}
}

View File

@ -98,8 +98,8 @@ public class MongoToMinIOPortingVREFolders implements AbstractScript{
for (StorageBackendFactory factory : factories) {
if (factory.getName() == Constants.MONGO_STORAGE)
mongo = factory.create(file.getContent().getPayloadBackend());
if (factory.getName() == Constants.DEFAULT_MINIO_STORAGE) {
minio = factory.create(new PayloadBackend(Constants.DEFAULT_MINIO_STORAGE, null));
if (factory.getName() == Constants.DEFAULT_S3_STORAGE) {
minio = factory.create(new PayloadBackend(Constants.DEFAULT_S3_STORAGE, null));
}
}

View File

@ -93,8 +93,8 @@ public class MongoToMinioPortingNotShared implements AbstractScript{
for (StorageBackendFactory factory : factories) {
if (factory.getName() == Constants.MONGO_STORAGE)
mongo = factory.create(file.getContent().getPayloadBackend());
if (factory.getName() == Constants.DEFAULT_MINIO_STORAGE) {
minio = factory.create(new PayloadBackend(Constants.DEFAULT_MINIO_STORAGE, null));
if (factory.getName() == Constants.DEFAULT_S3_STORAGE) {
minio = factory.create(new PayloadBackend(Constants.DEFAULT_S3_STORAGE, null));
}
}

View File

@ -130,7 +130,7 @@ public class UpdateNodeType implements AbstractScript{
}
private void registerNodeType(StringBuilder stringBuilder, JackrabbitSession session) throws Exception{
StringReader reader = new StringReader(addPayloadBackendInFolders);
StringReader reader = new StringReader(addVersionToHomes);
NodeType[] nodeTypes = CndImporter.registerNodeTypes(reader, session, true);
if (nodeTypes.length>0)