Java Code Examples for javax.naming.Name#add()
The following examples show how to use
javax.naming.Name#add() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SelectorContext.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Strips the URL header. * @param name The name * @return the parsed name * @throws NamingException if there is no "java:" header or if no * naming context has been bound to this thread */ protected Name parseName(Name name) throws NamingException { if (!initialContext && !name.isEmpty() && name.get(0).startsWith(prefix)) { if (name.get(0).equals(prefix)) { return name.getSuffix(1); } else { Name result = name.getSuffix(1); result.add(0, name.get(0).substring(prefixLength)); return result; } } else { if (initialContext) { return name; } else { throw new NamingException( sm.getString("selectorContext.noJavaUrl")); } } }
Example 2
Source File: SelectorContext.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Strips the URL header. * * @return the parsed name * @exception NamingException if there is no "java:" header or if no * naming context has been bound to this thread */ protected Name parseName(Name name) throws NamingException { if (!initialContext && !name.isEmpty() && name.get(0).startsWith(prefix)) { if (name.get(0).equals(prefix)) { return name.getSuffix(1); } else { Name result = name.getSuffix(1); result.add(0, name.get(0).substring(prefixLength)); return result; } } else { if (initialContext) { return name; } else { throw new NamingException( sm.getString("selectorContext.noJavaUrl")); } } }
Example 3
Source File: SelectorContext.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Strips the URL header. * * @return the parsed name * @exception NamingException if there is no "java:" header or if no * naming context has been bound to this thread */ protected Name parseName(Name name) throws NamingException { if (!initialContext && !name.isEmpty() && name.get(0).startsWith(prefix)) { if (name.get(0).equals(prefix)) { return name.getSuffix(1); } else { Name result = name.getSuffix(1); result.add(0, name.get(0).substring(prefixLength)); return result; } } else { if (initialContext) { return name; } else { throw new NamingException( sm.getString("selectorContext.noJavaUrl")); } } }
Example 4
Source File: LocalContext.java From unitime with Apache License 2.0 | 6 votes |
@Override public String getNameInNamespace() throws NamingException { LocalContext ancestor = iParent; if (ancestor == null) return ""; Name name = parse(""); name.add(iName); while (ancestor != null && ancestor.iName != null) { name.add(0, ancestor.iName); ancestor = ancestor.iParent; } return name.toString(); }
Example 5
Source File: LdifScript.java From scriptella-etl with Apache License 2.0 | 5 votes |
/** * Adds/modifies ctx using entry information. * * @param ctx directory context to use for change. * @param e entry with change description. * @throws NamingException if operation with directory failed. */ static void modify(DirContext ctx, final Entry e) throws NamingException { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Processing " + e); } Attributes atts = e.getAttributes(); final String rootDn = ctx.getNameInNamespace(); if (atts != null) { //If add entry ctx.createSubcontext(getRelativeDN(rootDn, e.getDn()), e.getAttributes()); } else if (e.isChangeDelete()) { ctx.destroySubcontext(getRelativeDN(rootDn, e.getDn())); } else if (e.isChangeModDn() || e.isChangeModRdn()) { Name newRdn; if (e.getNewSuperior() != null) { //If new superior newRdn = getRelativeDN(rootDn, e.getNewSuperior()); } else { //otherwise use DN as a base newRdn = getRelativeDN(rootDn, e.getDn()); newRdn.remove(newRdn.size() - 1); } newRdn.add(e.getNewRdn()); ctx.addToEnvironment("java.naming.ldap.deleteRDN", String.valueOf(e.isDeleteOldRdn())); ctx.rename(getRelativeDN(rootDn, e.getDn()), newRdn); ctx.removeFromEnvironment("java.naming.ldap.deleteRDN");//a better solution to use the previous value } else { List<ModificationItem> items = e.getModificationItems(); ctx.modifyAttributes(getRelativeDN(rootDn, e.getDn()), items.toArray(new ModificationItem[items.size()])); } }
Example 6
Source File: OpenEjbContainer.java From tomee with Apache License 2.0 | 5 votes |
@Override protected Name getName(Name name) throws NamingException { String first = name.get(0); if (!first.startsWith("java:")) { throw new NameNotFoundException("Name must be in java: namespace"); } first = first.substring("java:".length()); name = name.getSuffix(1); return name.add(0, first); }
Example 7
Source File: LDAPUserRegistry.java From alfresco-repository with GNU Lesser General Public License v3.0 | 3 votes |
/** * Converts a given DN into one suitable for use through JNDI. In particular, escapes special characters such as '/' * which have special meaning to JNDI. * * @param dn * the dn * @return the name * @throws InvalidNameException * the invalid name exception */ public static Name jndiName(String dn) throws InvalidNameException { Name n = new CompositeName(); n.add(dn); return n; }