@Override public void setNamespace(String prefix, String uri) { try { namespaceRegistry.registerNamespace(prefix, uri); } catch (RepositoryException e) { // ignore } }
public void addNamespace(String prefix, String uri) throws NamespaceException, UnsupportedRepositoryOperationException, RepositoryException { registry.registerNamespace(prefix, uri); } }
@Override public void setNamespace(String prefix, String uri) { try { namespaceRegistry.registerNamespace(prefix, uri); } catch (RepositoryException e) { // ignore } }
@Override public void setNamespace(String prefix, String uri) { try { namespaceRegistry.registerNamespace(prefix, uri); } catch (RepositoryException e) { // ignore } }
private void registerNamespace(String prefix, String uri) throws Exception { NamespaceRegistry nsRegistry = new ReadWriteNamespaceRegistry(root) { @Override protected Root getWriteRoot() { return root; } }; nsRegistry.registerNamespace(prefix, uri); }
public void addNamespaces(NamespaceMapping nsm) throws NamespaceException, UnsupportedRepositoryOperationException, RepositoryException { Map m = nsm.getPrefixToURIMapping(); for (Iterator i = m.entrySet().iterator(); i.hasNext();) { Map.Entry e = (Map.Entry) i.next(); String prefix = (String) e.getKey(); String uri = (String) e.getValue(); registry.registerNamespace(prefix, uri); } }
/** {@inheritDoc} */ public void registerNamespace(String prefix, String uri) throws RepositoryException, RemoteException { try { registry.registerNamespace(prefix, uri); } catch (RepositoryException ex) { throw getRepositoryException(ex); } }
public void addNamespaces(NamespaceMapping nsm) throws NamespaceException, UnsupportedRepositoryOperationException, RepositoryException { Map m = nsm.getPrefixToURIMapping(); for (Iterator i = m.values().iterator(); i.hasNext();) { Map.Entry e = (Map.Entry) i.next(); String prefix = (String) e.getKey(); String uri = (String) e.getKey(); registry.registerNamespace(prefix, uri); } }
public void addNamespaces(NamespaceMapping nsm) throws NamespaceException, UnsupportedRepositoryOperationException, RepositoryException { Map m = nsm.getPrefixToURIMapping(); for (Iterator i = m.entrySet().iterator(); i.hasNext();) { Map.Entry e = (Map.Entry) i.next(); String prefix = (String) e.getKey(); String uri = (String) e.getValue(); registry.registerNamespace(prefix, uri); } }
public void createNamespace(String prefix, String uri) throws WorkflowException, MappingException, RepositoryException { try { NamespaceRegistry nsreg = session.getWorkspace().getNamespaceRegistry(); nsreg.registerNamespace(prefix, uri); } catch (NamespaceException ex) { log.error(ex.getMessage() + " For: " + prefix + ":" + uri); throw new WorkflowException("Cannot create new namespace", ex); } }
@FixFor("MODE-2278") @Test(expected = NamespaceException.class) public void shouldNotAllowColonInPrefix() throws Exception { registry.registerNamespace("invalid", "http://invalid"); //as per http://www.w3.org/TR/REC-xml-names, the prefix has to be a valid NCName registry.registerNamespace("invalid:prefix", "http://invalid/prefix"); } }
@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"); }
@Test public void testAddNodeWithExpandedName() throws RepositoryException { Session session = getAdminSession(); session.getWorkspace().getNamespaceRegistry().registerNamespace("foo", "http://foo"); Node node = getNode(TEST_PATH); Node added = node.addNode("{http://foo}new"); assertEquals("foo:new", added.getName()); session.save(); added = session.getNode(TEST_PATH + "/{http://foo}new"); assertEquals("foo:new", added.getName()); }
@Test public void testRegisterNamespaceWithPrivilege() throws Exception { modify(null, PrivilegeConstants.JCR_NAMESPACE_MANAGEMENT.toString(), true); try { Workspace testWsp = testSession.getWorkspace(); testWsp.getNamespaceRegistry().registerNamespace(getNewNamespacePrefix(testWsp), getNewNamespaceURI(testWsp)); } finally { modify(null, PrivilegeConstants.JCR_NAMESPACE_MANAGEMENT.toString(), false); } }
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"); } }
private void registerCustomPrivileges(Session session) throws RepositoryException { final JackrabbitWorkspace workspace = (JackrabbitWorkspace) session.getWorkspace(); final NamespaceRegistry registry = workspace.getNamespaceRegistry(); registry.registerNamespace("test", "http://www.example.org/"); final PrivilegeManager privilegeManager = workspace.getPrivilegeManager(); privilegeManager.registerPrivilege("test:privilege", false, null); privilegeManager.registerPrivilege( "test:aggregate", false, new String[]{"jcr:read", "test:privilege"}); }
@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 } }
@Override @Before public void beforeEach() throws Exception { super.beforeEach(); session.getWorkspace().getNamespaceRegistry().registerNamespace(TestLexicon.Namespace.PREFIX, TestLexicon.Namespace.URI); }
@Override protected void createSourceContent(Session session) throws Exception { JackrabbitWorkspace workspace = (JackrabbitWorkspace) session.getWorkspace(); NamespaceRegistry registry = workspace.getNamespaceRegistry(); registry.registerNamespace("test", "http://www.example.org/"); PrivilegeManager privilegeManager = workspace.getPrivilegeManager(); privilegeManager.registerPrivilege("test:privilege", false, null); privilegeManager.registerPrivilege("test:aggregate", false, new String[] { "jcr:read", "test:privilege" }); privilegeManager.registerPrivilege("test:privilege2", true, null); privilegeManager.registerPrivilege("test:aggregate2", true, new String[] { "test:aggregate", "test:privilege2" }); }