new script added
This commit is contained in:
parent
9cf1354379
commit
d567786ff6
|
@ -0,0 +1,37 @@
|
|||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.jackrabbit.api.JackrabbitSession;
|
||||
import org.gcube.data.access.storagehub.scripting.AbstractScript;
|
||||
import org.gcube.data.access.storagehub.scripting.ScriptParameter;
|
||||
import org.gcube.data.access.storagehub.scripting.ScriptUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class RetoreJackrabbitBackup implements AbstractScript{
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(RetoreJackrabbitBackup.class);
|
||||
|
||||
@Override
|
||||
public String run(JackrabbitSession session, ScriptParameter prameters, ScriptUtil scriptUtil) {
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
try {
|
||||
try(InputStream is = new URI("https://data-dev.d4science.net/VoyH").toURL().openStream()){
|
||||
session.importXML("/", is, 1);
|
||||
}
|
||||
session.save();
|
||||
}catch (Throwable e) {
|
||||
log.error("error getting jcr backup",e);
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter sw = new PrintWriter(writer, true);
|
||||
e.printStackTrace(sw);
|
||||
return writer.toString();
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.jcr.nodetype.NodeType;
|
||||
import javax.jcr.nodetype.NodeTypeIterator;
|
||||
import javax.jcr.nodetype.PropertyDefinition;
|
||||
|
||||
import org.apache.jackrabbit.api.JackrabbitSession;
|
||||
import org.gcube.data.access.storagehub.scripting.AbstractScript;
|
||||
import org.gcube.data.access.storagehub.scripting.ScriptParameter;
|
||||
import org.gcube.data.access.storagehub.scripting.ScriptUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class RetrieveRegisteredNodeTypes implements AbstractScript{
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(RetrieveRegisteredNodeTypes.class);
|
||||
|
||||
@Override
|
||||
public String run(JackrabbitSession session, ScriptParameter prameters, ScriptUtil scriptUtil) throws Exception {
|
||||
StringBuilder sbuilder = new StringBuilder();
|
||||
NodeTypeIterator nodeTypeIt = session.getWorkspace().getNodeTypeManager().getAllNodeTypes();
|
||||
while(nodeTypeIt.hasNext()){
|
||||
NodeType node = nodeTypeIt.nextNodeType();
|
||||
sbuilder.append("\n").append(node.getName()).append(" > ").append(Arrays.asList(node.getDeclaredSupertypeNames()).stream().collect(Collectors.joining(" , ")));
|
||||
log.info("Registered "+node.getName());
|
||||
for (PropertyDefinition def: node.getDeclaredPropertyDefinitions()){
|
||||
sbuilder.append("\n").append(" - ").append(def.getName());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return sbuilder.toString();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue