/** * Forwards the method call to the underlying workspace. */ public NamespaceRegistry getNamespaceRegistry() throws RepositoryException { return workspace.getNamespaceRegistry(); }
ContextWorkspace(ModuleRegistration module) throws RepositoryException { this.module = module; upstreamWorkspace = session.getWorkspace(); upstreamRegistry = upstreamWorkspace.getNamespaceRegistry(); } public Session getSession() {
@Override public NamespaceRegistry apply(final Node n) { try { checkNotNull(n, "null has no Namespace Registry associated with it!"); return (org.modeshape.jcr.api.NamespaceRegistry)n.getSession().getWorkspace().getNamespaceRegistry(); } catch (final RepositoryException e) { throw new IllegalStateException(e); } }
/** * @see info.magnolia.repository.Provider#unregisterNamespace(java.lang.String, javax.jcr.Workspace) */ @Override public void unregisterNamespace(String prefix, Workspace workspace) throws RepositoryException { workspace.getNamespaceRegistry().unregisterNamespace(prefix); }
static boolean isNamespaceRegistered(Session session) throws RepositoryException { Workspace ws = session.getWorkspace(); //no need to set it up again, skip it if it has. String uris[] = ws.getNamespaceRegistry().getURIs(); for (String uri : uris) { if (RulesRepository.DROOLS_URI.equals(uri)) { return true; } } return false; }
private String getUri(String prefix) { if ("system".equals(prefix)) { return "internal"; } try { NamespaceRegistry nsReg = getJcrSession().getWorkspace().getNamespaceRegistry(); return nsReg.getURI(prefix); } catch (RepositoryException ex) { log.error(ex.getMessage()); } return null; }
void initialize(Workspace workspace) throws NamespaceException, RepositoryException, ParseException { try { String cndString = JcrCompactNodeTypeDefWriter.compactNodeTypeDef(workspace, namespace); this.cndReader = new HippoCompactNodeTypeDefReader(new StringReader(cndString), cndName, workspace.getNamespaceRegistry()); } catch (IOException ex) { log.error("cannot autogenerate cnd", ex); } initialize(); }
public void setUp() throws Exception { isReadOnly = true; super.setUp(); session = getHelper().getReadOnlySession(); Workspace ws = session.getWorkspace(); nsr = ws.getNamespaceRegistry(); }
/** * Sets up the fixture for the tests. */ protected void setUp() throws Exception { isReadOnly = true; super.setUp(); session = getHelper().getReadOnlySession(); nsr = session.getWorkspace().getNamespaceRegistry(); }
public EditmodelWorkflowImpl(Session userSession, Session rootSession, Node subject) throws RemoteException, RepositoryException { this.rootSession = rootSession; this.subject = rootSession.getNodeByIdentifier(subject.getIdentifier()); this.prefix = this.subject.getParent().getName(); NamespaceRegistry nsReg = rootSession.getWorkspace().getNamespaceRegistry(); this.uri = nsReg.getURI(prefix); }
private void registerImportedNamespaces( Node outputNode, CndImporter cndImporter ) throws RepositoryException { NamespaceRegistry namespaceRegistry = outputNode.getSession().getWorkspace().getNamespaceRegistry(); for (Namespace namespace : cndImporter.getNamespaces()) { super.registerNamespace(namespace.getPrefix(), namespace.getNamespaceUri(), namespaceRegistry); } }
@NotNull private String getNewNamespaceURI(Workspace wsp) throws RepositoryException { String uri = "http://jackrabbit.apache.org/uri"; List<String> uris = Arrays.asList(wsp.getNamespaceRegistry().getURIs()); int i = 0; while (uris.contains(uri)) { uri = "http://jackrabbit.apache.org/uri_" + i++; } return uri; }
/** * {@inheritDoc} */ public void unregisterNamespace(SessionInfo sessionInfo, String uri) throws NamespaceException, UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException { Session session = getSessionInfoImpl(sessionInfo).getSession(); NamespaceRegistry nsReg = session.getWorkspace().getNamespaceRegistry(); nsReg.unregisterNamespace(nsReg.getPrefix(uri)); }
@NotNull private String getNewNamespacePrefix(Workspace wsp) throws RepositoryException { String prefix = "prefix"; List<String> pfcs = Arrays.asList(wsp.getNamespaceRegistry().getPrefixes()); int i = 0; while (pfcs.contains(prefix)) { prefix = "prefix" + i++; } return prefix; }
private static String getUnknownURI(Session session, String uriHint) throws RepositoryException { String uri = uriHint; int index = 0; List<String> uris = Arrays.asList(session.getWorkspace().getNamespaceRegistry().getURIs()); while (uris.contains(uri)) { uri = uriHint + index; index++; } return uri; }
/** {@inheritDoc} */ public RemoteNamespaceRegistry getNamespaceRegistry() throws RepositoryException, RemoteException { try { NamespaceRegistry registry = workspace.getNamespaceRegistry(); return getFactory().getRemoteNamespaceRegistry(registry); } catch (RepositoryException ex) { throw getRepositoryException(ex); } }
@Before public void setUp() throws Exception { super.setUp(); session = MgnlContext.getJCRSession(WEBSITE); session.getWorkspace().getNamespaceRegistry().registerNamespace("yes", "urn:yes:1.0"); session.getWorkspace().getNamespaceRegistry().registerNamespace("no", "urn:no:1.0"); Node foo = session.getRootNode().addNode("foo", NT_UNSTRUCTURED); foo.setProperty("yes:prop", "yes"); foo.setProperty("no:prop", "no"); }
@Before public void setUp() throws Exception { super.setUp(); Session session = MgnlContext.getJCRSession(WEBSITE); session.getWorkspace().getNamespaceRegistry().registerNamespace("unwanted", "urn:unwanted:1.0"); Node foo = session.getRootNode().addNode("foo", NT_UNSTRUCTURED); foo.setProperty("unwanted:prop", "val1"); Node bar = foo.addNode("unwanted:bar", NT_UNSTRUCTURED); bar.setProperty("unwanted:prop", "val2"); }
public void testRepositoryLevelPrivileges() throws RepositoryException { // EXERCISE : setup the permissions such that test-session can register a // - new namespace|node type|privilege (note: workspace management not yet supported) // EXERCISE: refactory the test to verify that granting these privs at 'childPath' doesn;t have the desired effect. JackrabbitSession s = (JackrabbitSession) createTestSession(); NamespaceRegistry nsRegistry = s.getWorkspace().getNamespaceRegistry(); nsRegistry.registerNamespace("jr", "http://jackrabbit.apache.org"); } }
@Test public void testRegisterNamespace() throws Exception { try { Workspace testWsp = testSession.getWorkspace(); testWsp.getNamespaceRegistry().registerNamespace(getNewNamespacePrefix(testWsp), getNewNamespaceURI(testWsp)); fail("Namespace registration should be denied."); } catch (AccessDeniedException e) { // success } }