@Override public void runTest() throws RepositoryException { for (int i = 0; i < 10000; i++) { for (String prefix : registry.getPrefixes()) { registry.getURI(prefix); } } }
public String getURI(String prefix) throws NamespaceException { try { return nsReg.getURI(prefix); } catch (RepositoryException e) { // should never get here... throw new NamespaceException("internal error: failed to resolve namespace prefix", e); } } };
public String getURI(String prefix) throws NamespaceException { try { return registry.getURI(prefix); } catch (RepositoryException e) { if (!(e instanceof NamespaceException)) { e = new NamespaceException( "Failed to resolve namespace prefix: " + prefix, e); } throw (NamespaceException) e; } } }
public NamespacesProperty(NamespaceRegistry nsReg) throws RepositoryException { super(JCR_NAMESPACES, false); if (nsReg != null) { for (String prefix : nsReg.getPrefixes()) { value.put(prefix, nsReg.getURI(prefix)); } } }
public String getURI(String prefix) throws NamespaceException { try { return nsReg.getURI(prefix); } catch (RepositoryException e) { // should never get here... throw new NamespaceException("internal error: failed to resolve namespace prefix", e); } } };
public String getURI(String prefix) throws NamespaceException { try { return registry.getURI(prefix); } catch (RepositoryException e) { if (!(e instanceof NamespaceException)) { e = new NamespaceException( "Failed to resolve namespace prefix: " + prefix, e); } throw (NamespaceException) e; } } }
/** {@inheritDoc} */ public String getURI(String prefix) throws RepositoryException, RemoteException { try { return registry.getURI(prefix); } catch (RepositoryException ex) { throw getRepositoryException(ex); } }
public JcrTypeVersion(Session session, String type) throws RepositoryException { this.session = session; info = new JcrTypeInfo(session, type); draft = false; if (type.indexOf(':') > 0) { String prefix = type.substring(0, type.indexOf(':')); uri = session.getWorkspace().getNamespaceRegistry().getURI(prefix); } else { uri = "internal"; } }
private String getUri(String prefix) throws RepositoryException { if ("system".equals(prefix)) { return "internal"; } NamespaceRegistry nsReg = getJcrSession().getWorkspace().getNamespaceRegistry(); return nsReg.getURI(prefix); } }
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; }
/** * {@inheritDoc} */ public Map<String, String> getRegisteredNamespaces(SessionInfo sessionInfo) throws RepositoryException { SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo); NamespaceRegistry nsReg = sInfo.getSession().getWorkspace().getNamespaceRegistry(); Map<String, String> namespaces = new HashMap<String, String>(); for (String prefix : nsReg.getPrefixes()) { namespaces.put(prefix, nsReg.getURI(prefix)); } return namespaces; }
/** * {@inheritDoc} */ public String getNamespaceURI(SessionInfo sessionInfo, String prefix) throws NamespaceException, RepositoryException { SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo); return sInfo.getSession().getWorkspace().getNamespaceRegistry().getURI(prefix); }
/** * {@inheritDoc} */ public String getNamespaceURI(SessionInfo sessionInfo, String prefix) throws NamespaceException, RepositoryException { SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo); return sInfo.getSession().getWorkspace().getNamespaceRegistry().getURI(prefix); }
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); }
/** * @see info.magnolia.repository.Provider#registerNamespace(java.lang.String, java.lang.String, javax.jcr.Workspace) */ @Override public void registerNamespace(String namespacePrefix, String uri, Workspace workspace) throws RepositoryException { try { workspace.getNamespaceRegistry().getURI(namespacePrefix); } catch (NamespaceException e) { log.debug(e.getMessage()); log.info("Registering prefix [{}] with URI {}", namespacePrefix, uri); workspace.getNamespaceRegistry().registerNamespace(namespacePrefix, uri); } }
private static Function<FedoraEvent, FedoraEvent> filterAndDerefResourceTypes(final Session session) { final NamespaceRegistry registry = getNamespaceRegistry(session); return evt -> { final Set<String> resourceTypes = evt.getResourceTypes().stream() .flatMap(dynamicTypes).map(type -> type.split(":")) .filter(pair -> pair.length == 2).map(uncheck(pair -> new String[]{registry.getURI(pair[0]), pair[1]})) .filter(pair -> !filteredNamespaces.contains(pair[0])).map(pair -> pair[0] + pair[1]).collect(toSet()); return new FedoraEventImpl(evt.getTypes(), evt.getPath(), resourceTypes, evt.getUserID(), FedoraSessionUserUtil.getUserURI(evt.getUserID()), evt.getDate(), evt.getInfo()); }; }
@Test( expected = NamespaceException.class ) public void shouldNotAllowUnregisteredPrefix() throws Exception { registry.getURI("bogus"); }
@Test @FixFor( "MODE-1687" ) public void shouldRegisterBothUsedAndUnusedNamespacesFromCNDFile() throws Exception { startRepositoryWithConfigurationFrom("config/repo-config-node-types.json"); NamespaceRegistry namespaceRegistry = session.getWorkspace().getNamespaceRegistry(); assertEquals("http://www.modeshape.org/examples/cars/1.0", namespaceRegistry.getURI("car")); assertEquals("http://www.modeshape.org/examples/aircraft/1.0", namespaceRegistry.getURI("air")); assertEquals("http://www.test1.com", namespaceRegistry.getURI("test1")); assertEquals("http://www.test2.com", namespaceRegistry.getURI("test2")); }
@Test public void shouldProvideNamespaceRegistry() throws Exception { NamespaceRegistry registry = workspace.getNamespaceRegistry(); assertThat(registry, is(notNullValue())); assertThat(registry.getURI(JcrLexicon.Namespace.PREFIX), is(JcrLexicon.Namespace.URI)); }
protected void assertThatNamespacePrefixIsNotRegistered( String prefix ) throws Exception { try { registry.getURI(prefix); fail("Should not have found namespace mapping with prefix \"" + prefix + "\""); } catch (NamespaceException e) { // good } for (String existingPrefix : registry.getPrefixes()) { assertThat(existingPrefix, is(not(prefix))); } }