use of javax.jcr.Workspace in project sling by apache.
the class NodeTypeDefinitionScanner method registerNodeTypes.
/**
* Registers node types found in classpath in JCR repository.
* @param session Session
* @param nodeTypeResources List of classpath resource URLs pointing to node type definitions
*/
private void registerNodeTypes(Session session, List<String> nodeTypeResources) throws RepositoryException {
ClassLoader classLoader = getClass().getClassLoader();
Workspace workspace = session.getWorkspace();
NodeTypeManager nodeTypeManager = workspace.getNodeTypeManager();
NamespaceRegistry namespaceRegistry = workspace.getNamespaceRegistry();
ValueFactory valueFactory = session.getValueFactory();
// try registering node types multiple times because the exact order is not known
int iteration = 0;
List<String> remainingNodeTypeResources = new ArrayList<String>(nodeTypeResources);
while (!remainingNodeTypeResources.isEmpty()) {
registerNodeTypesAndRemoveSucceeds(remainingNodeTypeResources, classLoader, nodeTypeManager, namespaceRegistry, valueFactory, false);
iteration++;
if (iteration >= MAX_ITERATIONS) {
break;
}
}
if (!remainingNodeTypeResources.isEmpty()) {
registerNodeTypesAndRemoveSucceeds(remainingNodeTypeResources, classLoader, nodeTypeManager, namespaceRegistry, valueFactory, true);
}
}
use of javax.jcr.Workspace in project sling by apache.
the class WorkspaceCreator method deactivate.
@SuppressWarnings("unused")
@Deactivate
private void deactivate() {
Session s = null;
try {
s = repo.loginAdministrative(null);
Workspace w = s.getWorkspace();
deleteWorkspace(w, "ws3");
deleteWorkspace(w, "ws2");
deleteWorkspace(w, "ws1");
} catch (Exception e) {
// ignore
} finally {
if (s != null) {
s.logout();
}
}
}
use of javax.jcr.Workspace in project camel by apache.
the class JcrRouteDifferentWorkspaceTestSupport method setUp.
@Override
@Before
public void setUp() throws Exception {
deleteDirectory(REPO_PATH);
super.setUp();
Session session = getRepository().login(new SimpleCredentials("user", "pass".toCharArray()));
Workspace workspace = session.getWorkspace();
workspace.createWorkspace(CUSTOM_WORKSPACE_NAME);
session.save();
session.logout();
}
use of javax.jcr.Workspace in project jackrabbit by apache.
the class RootCollection method removeMember.
/**
* Calls {@link Workspace#deleteWorkspace(String)} for the workspace with
* the name as indicated by the specified member.
*
* @see DavResource#removeMember(org.apache.jackrabbit.webdav.DavResource)
*/
@Override
public void removeMember(DavResource member) throws DavException {
Workspace wsp = getRepositorySession().getWorkspace();
String name = Text.getName(member.getResourcePath());
try {
wsp.deleteWorkspace(name);
} catch (RepositoryException e) {
throw new JcrDavException(e);
}
}
use of javax.jcr.Workspace in project jackrabbit by apache.
the class NamespaceRegistryReadMethodsTest method setUp.
public void setUp() throws Exception {
isReadOnly = true;
super.setUp();
session = getHelper().getReadOnlySession();
Workspace ws = session.getWorkspace();
nsr = ws.getNamespaceRegistry();
}
Aggregations