added scripts
This commit is contained in:
parent
3631e00a90
commit
ba412f8154
8
pom.xml
8
pom.xml
|
@ -12,7 +12,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.distribution</groupId>
|
<groupId>org.gcube.distribution</groupId>
|
||||||
<artifactId>gcube-bom</artifactId>
|
<artifactId>gcube-bom</artifactId>
|
||||||
<version>3.0.0-SNAPSHOT</version>
|
<version>3.0.1-SNAPSHOT</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -27,15 +27,15 @@
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.data.access</groupId>
|
<groupId>org.gcube.data.access</groupId>
|
||||||
<artifactId>storagehub-script-utils</artifactId>
|
<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>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -10,8 +10,10 @@ import javax.jcr.NodeIterator;
|
||||||
import javax.jcr.PathNotFoundException;
|
import javax.jcr.PathNotFoundException;
|
||||||
import javax.jcr.Property;
|
import javax.jcr.Property;
|
||||||
import javax.jcr.PropertyIterator;
|
import javax.jcr.PropertyIterator;
|
||||||
|
import javax.jcr.version.VersionHistory;
|
||||||
|
|
||||||
import org.apache.jackrabbit.api.JackrabbitSession;
|
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.Path;
|
||||||
import org.gcube.common.storagehub.model.Paths;
|
import org.gcube.common.storagehub.model.Paths;
|
||||||
import org.gcube.common.storagehub.model.items.Item;
|
import org.gcube.common.storagehub.model.items.Item;
|
||||||
|
@ -33,27 +35,17 @@ public class GeneralScript implements AbstractScript{
|
||||||
try {
|
try {
|
||||||
log.info("script started");
|
log.info("script started");
|
||||||
|
|
||||||
Node home = session.getNode("/Home/emmanuel.blondel");
|
Node home = session.getNodeByIdentifier("cbf7b63b-172d-49bd-a671-4d39a39cd216");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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 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) {
|
}catch (Exception e) {
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
PrintWriter sw = new PrintWriter(writer, true);
|
PrintWriter sw = new PrintWriter(writer, true);
|
||||||
|
|
|
@ -92,8 +92,8 @@ public class MongoToMinIOPortingSharedFolder implements AbstractScript{
|
||||||
for (StorageBackendFactory factory : factories) {
|
for (StorageBackendFactory factory : factories) {
|
||||||
if (factory.getName() == Constants.MONGO_STORAGE)
|
if (factory.getName() == Constants.MONGO_STORAGE)
|
||||||
mongo = factory.create(file.getContent().getPayloadBackend());
|
mongo = factory.create(file.getContent().getPayloadBackend());
|
||||||
if (factory.getName() == Constants.DEFAULT_MINIO_STORAGE) {
|
if (factory.getName() == Constants.DEFAULT_S3_STORAGE) {
|
||||||
minio = factory.create(new PayloadBackend(Constants.DEFAULT_MINIO_STORAGE, null));
|
minio = factory.create(new PayloadBackend(Constants.DEFAULT_S3_STORAGE, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,8 +98,8 @@ public class MongoToMinIOPortingVREFolders implements AbstractScript{
|
||||||
for (StorageBackendFactory factory : factories) {
|
for (StorageBackendFactory factory : factories) {
|
||||||
if (factory.getName() == Constants.MONGO_STORAGE)
|
if (factory.getName() == Constants.MONGO_STORAGE)
|
||||||
mongo = factory.create(file.getContent().getPayloadBackend());
|
mongo = factory.create(file.getContent().getPayloadBackend());
|
||||||
if (factory.getName() == Constants.DEFAULT_MINIO_STORAGE) {
|
if (factory.getName() == Constants.DEFAULT_S3_STORAGE) {
|
||||||
minio = factory.create(new PayloadBackend(Constants.DEFAULT_MINIO_STORAGE, null));
|
minio = factory.create(new PayloadBackend(Constants.DEFAULT_S3_STORAGE, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,8 +93,8 @@ public class MongoToMinioPortingNotShared implements AbstractScript{
|
||||||
for (StorageBackendFactory factory : factories) {
|
for (StorageBackendFactory factory : factories) {
|
||||||
if (factory.getName() == Constants.MONGO_STORAGE)
|
if (factory.getName() == Constants.MONGO_STORAGE)
|
||||||
mongo = factory.create(file.getContent().getPayloadBackend());
|
mongo = factory.create(file.getContent().getPayloadBackend());
|
||||||
if (factory.getName() == Constants.DEFAULT_MINIO_STORAGE) {
|
if (factory.getName() == Constants.DEFAULT_S3_STORAGE) {
|
||||||
minio = factory.create(new PayloadBackend(Constants.DEFAULT_MINIO_STORAGE, null));
|
minio = factory.create(new PayloadBackend(Constants.DEFAULT_S3_STORAGE, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ public class UpdateNodeType implements AbstractScript{
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerNodeType(StringBuilder stringBuilder, JackrabbitSession session) throws Exception{
|
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);
|
NodeType[] nodeTypes = CndImporter.registerNodeTypes(reader, session, true);
|
||||||
if (nodeTypes.length>0)
|
if (nodeTypes.length>0)
|
||||||
|
|
Loading…
Reference in New Issue