use of org.modeshape.jcr.ModeShapeEngine in project kylo by Teradata.
the class ModeShapeEngineConfig method modeShapeEngine.
@Bean(destroyMethod = "shutdown")
public ModeShapeEngine modeShapeEngine(@Qualifier("springApplicationContext") SpringApplicationContext springApplicationContext) {
ModeShapeEngine engine = new ModeShapeEngine();
log.info("Starting ModeShape engine...");
engine.start();
log.info("ModeShape engine started");
return engine;
}
use of org.modeshape.jcr.ModeShapeEngine in project kylo by Teradata.
the class JcrNotebooksApp method main.
public static void main(String... args) throws RepositoryException, IOException {
ModeShapeEngine engine = new ModeShapeEngine();
engine.start();
Repository repository = null;
String repositoryName = null;
URL url = JcrNotebooksApp.class.getClassLoader().getResource("sandbox/notebook-test-repository.json");
RepositoryConfiguration config = RepositoryConfiguration.read(url);
// Verify the configuration for the repository ...
Problems problems = config.validate();
if (problems.hasErrors()) {
System.err.println("Problems starting the engine.");
System.err.println(problems);
System.exit(-1);
}
// Deploy the repository ...
repository = engine.deploy(config);
repositoryName = config.getName();
Session session = null;
JcrTools tools = new JcrTools();
tools.setDebug(true);
// get the repository
repository = engine.getRepository(repositoryName);
Project p;
session = repository.login("default");
// Create the '/files' node that is an 'nt:folder' ...
Node root = session.getRootNode();
/*
Node filesNode = root.addNode("notebooks", "nt:folder");
InputStream stream =
new BufferedInputStream(new FileInputStream("/Users/th186036/filesystemconnector/hello.txt"));
// Create an 'nt:file' node at the supplied path ...
Node fileNode = filesNode.addNode("hello.txt", "nt:file");
// Upload the file to that node ...
Node contentNode = fileNode.addNode("jcr:content", "nt:resource");
Binary binary = session.getValueFactory().createBinary(stream);
contentNode.setProperty("jcr:data", binary);
session.save();
*/
session = repository.login("default");
Node project = JcrUtil.getOrCreateNode(root, "Project1", JcrProject.NODE_TYPE);
List<Node> nodes = JcrUtil.getNodesOfType(root, JcrProject.NODE_TYPE);
logger.debug("Node list {}", nodes);
// List<JcrEntity> fileNodes = JcrUtil.getChildrenMatchingNodeType(root, JcrProject.NODE_TYPE, JcrEntity.class, null);
// logger.debug("Node list {}", nodes );
logger.debug("Modeshape subgraph");
tools.printSubgraph(root);
if (session != null) {
session.logout();
}
logger.info("Shutting down engine ...");
try {
engine.shutdown().get();
logger.info("Success!");
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations