]> git.argeo.org Git - lgpl/argeo-commons.git/blob - modeshape/FileSystemRepository.java
Prepare next development cycle
[lgpl/argeo-commons.git] / modeshape / FileSystemRepository.java
1 /*
2 * Copyright (C) 2007-2012 Mathieu Baudier
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.modeshape;
17
18 import java.util.UUID;
19
20 import javax.jcr.Repository;
21 import javax.jcr.RepositoryException;
22 import javax.jcr.Session;
23 import javax.jcr.SimpleCredentials;
24
25 import org.argeo.jcr.JcrUtils;
26 import org.modeshape.connector.filesystem.FileSystemSource;
27 import org.modeshape.jcr.JcrConfiguration;
28 import org.modeshape.jcr.JcrEngine;
29
30 public class FileSystemRepository {
31 public void init() {
32 try {
33 // Required in order to load mime type definitions
34 Thread.currentThread().setContextClassLoader(JcrConfiguration.class.getClassLoader());
35 JcrConfiguration config = new JcrConfiguration();
36 config.repositorySource("fsSource")
37 .usingClass(FileSystemSource.class)
38 .setDescription("The repository for our content")
39 .setProperty("workspaceRootPath", "/home/mbaudier/tmp")
40 .setProperty("defaultWorkspaceName", "prod")
41 .setProperty("predefinedWorkspaceNames",
42 new String[] { "staging", "dev" })
43 .setProperty(
44 "rootNodeUuid",
45 UUID.fromString("fd129c12-81a8-42ed-aa4b-820dba49e6f0"))
46 .setProperty("updatesAllowed", "true")
47 .setProperty("creatingWorkspaceAllowed", "false");
48 config.repository("fsRepo").setSource("fsSource");
49
50 JcrEngine jcrEngine = config.build();
51 jcrEngine.start();
52 Repository repository = jcrEngine.getRepository("fsRepo");
53 Session session = repository.login(new SimpleCredentials("demo",
54 "demo".toCharArray()));
55 JcrUtils.debug(session.getRootNode());
56 } catch (RepositoryException e) {
57 e.printStackTrace();
58 }
59 }
60 }