]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - argeo/modeshape/FileSystemRepository.java
2 * Copyright (C) 2007-2012 Mathieu Baudier
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org
.argeo
.modeshape
;
18 import java
.util
.UUID
;
20 import javax
.jcr
.Repository
;
21 import javax
.jcr
.RepositoryException
;
22 import javax
.jcr
.Session
;
23 import javax
.jcr
.SimpleCredentials
;
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
;
30 public class FileSystemRepository
{
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" })
45 UUID
.fromString("fd129c12-81a8-42ed-aa4b-820dba49e6f0"))
46 .setProperty("updatesAllowed", "true")
47 .setProperty("creatingWorkspaceAllowed", "false");
48 config
.repository("fsRepo").setSource("fsSource");
50 JcrEngine jcrEngine
= config
.build();
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
) {