List of usage examples for javax.naming Name toString
public String toString()
From source file:se.inera.axel.shs.broker.directory.internal.LdapDirectoryAdminService.java
private void save11Address(Organization organization, Address address) { Name dn = build11Dn(organization, address); DirContextAdapter context = null;//from w w w . j av a 2 s . c o m boolean isNew = false; try { context = (DirContextAdapter) ldapTemplate.lookupContext(dn); } catch (NameNotFoundException e) { isNew = true; context = new DirContextAdapter(dn); } AddressMapper.mapToContext(address, context); if (isNew) { ldapTemplate.bind(context); log.debug("address {} created in directory", dn.toString()); } else { ldapTemplate.modifyAttributes(context); log.debug("address {} updated in directory", dn.toString()); } }
From source file:com.dattack.naming.AbstractContext.java
@Override public void bind(final Name name, final Object object) throws NamingException { ensureContextNotClosed();/*from w w w. j av a 2 s .c om*/ if (object == null) { return; } if (name.isEmpty()) { throw new InvalidNameException("Cannot bind to an empty name"); } final Name prefix = name.getPrefix(1); if (subContexts.containsKey(prefix)) { subContexts.get(prefix).bind(name.getSuffix(1), object); return; } if (objectTable.containsKey(name) || subContexts.containsKey(name) || env.containsKey(name.toString())) { throw new NameAlreadyBoundException( String.format("Name %s already bound. Use rebind() to override", name.toString())); } if (object instanceof Context) { subContexts.put(name, (Context) object); } else { objectTable.put(name, object); } }
From source file:se.inera.axel.shs.broker.directory.internal.LdapDirectoryAdminService.java
private void save12Address(Organization organization, Address address) { Name dn = buildDn(organization); DirContextAdapter context = null;/*ww w. j a va 2 s . c om*/ try { context = (DirContextAdapter) ldapTemplate.lookupContext(dn); } catch (NameNotFoundException e) { throw new IllegalArgumentException("organization for address non-exist"); } dn = buildDn(organization, address); boolean isNew = false; try { context = (DirContextAdapter) ldapTemplate.lookupContext(dn); } catch (NameNotFoundException e) { isNew = true; context = new DirContextAdapter(dn); } AddressMapper.mapToContext(address, context); if (isNew) { ldapTemplate.bind(context); log.debug("address {} created in directory", dn.toString()); } else { ldapTemplate.modifyAttributes(context); log.debug("address {} updated in directory", dn.toString()); } }
From source file:se.inera.axel.shs.broker.directory.internal.LdapDirectoryAdminService.java
private void saveProduct12(Organization organization, ProductType product) { Name dn = buildDn(organization); DirContextAdapter context = null;/* w w w . j a v a 2 s . c o m*/ try { context = (DirContextAdapter) ldapTemplate.lookupContext(dn); } catch (NameNotFoundException e) { throw new IllegalArgumentException("organization for product non-exist"); } dn = buildDn(organization, product); boolean isNew = false; try { context = (DirContextAdapter) ldapTemplate.lookupContext(dn); } catch (NameNotFoundException e) { isNew = true; context = new DirContextAdapter(dn); } ProductTypeMapper.mapToContext(organization, product, context); if (isNew) { ldapTemplate.bind(context); log.debug("product {} created in directory", dn.toString()); } else { ldapTemplate.modifyAttributes(context); log.debug("product {} updated in directory", dn.toString()); } }
From source file:se.inera.axel.shs.broker.directory.internal.LdapDirectoryAdminService.java
@Override public void saveAgreement(Organization organization, Agreement agreement) { Name dn = buildDn(organization); DirContextAdapter context = null;/*w w w.j ava 2 s. c om*/ try { context = (DirContextAdapter) ldapTemplate.lookupContext(dn); } catch (NameNotFoundException e) { throw new IllegalArgumentException("organization for agreement non-exist"); } dn = buildDn(organization, agreement); boolean isNew = false; try { context = (DirContextAdapter) ldapTemplate.lookupContext(dn); } catch (NameNotFoundException e) { isNew = true; context = new DirContextAdapter(dn); } AgreementMapper.mapToContext(organization, agreement, context); if (isNew) { ldapTemplate.bind(context); log.debug("agreement {} created in directory", dn.toString()); } else { ldapTemplate.modifyAttributes(context); log.debug("agreement {} updated in directory", dn.toString()); } }
From source file:naming.resources.ProxyDirContext.java
/** * Retrieves all of the attributes associated with a named object. * //from www.j ava2s . co m * @return the set of attributes associated with name. * Returns an empty attribute set if name has no attributes; never null. * @param name the name of the object from which to retrieve attributes * @exception NamingException if a naming exception is encountered */ public Attributes getAttributes(Name name) throws NamingException { CacheEntry entry = cacheLookup(name.toString()); if (entry != null) { return entry.attributes; } Attributes attributes = dirContext.getAttributes(parseName(name)); if (!(attributes instanceof ResourceAttributes)) { attributes = new ResourceAttributes(attributes); } return attributes; }
From source file:naming.resources.ProxyDirContext.java
/** * Retrieves the named object. If name is empty, returns a new instance * of this context (which represents the same naming context as this * context, but its environment may be modified independently and it may * be accessed concurrently)./* w w w.java 2 s.c o m*/ * * @param name the name of the object to look up * @return the object bound to name * @exception NamingException if a naming exception is encountered */ public Object lookup(Name name) throws NamingException { CacheEntry entry = cacheLookup(name.toString()); if (entry != null) { if (entry.resource != null) { // Check content caching. return entry.resource; } else { return entry.context; } } Object object = dirContext.lookup(parseName(name)); if (object instanceof InputStream) return new Resource((InputStream) object); else return object; }
From source file:naming.resources.ProxyDirContext.java
/** * Unbinds the named object. Removes the terminal atomic name in name * from the target context--that named by all but the terminal atomic * part of name.// w w w . j a v a 2 s . c o m * <p> * This method is idempotent. It succeeds even if the terminal atomic * name is not bound in the target context, but throws * NameNotFoundException if any of the intermediate contexts do not exist. * * @param name the name to bind; may not be empty * @exception NameNotFoundException if an intermediate context does not * exist * @exception NamingException if a naming exception is encountered */ public void unbind(Name name) throws NamingException { dirContext.unbind(parseName(name)); cacheUnload(name.toString()); }
From source file:naming.resources.ProxyDirContext.java
/** * Destroys the named context and removes it from the namespace. Any * attributes associated with the name are also removed. Intermediate * contexts are not destroyed.//from w ww . j a va 2 s.c om * <p> * This method is idempotent. It succeeds even if the terminal atomic * name is not bound in the target context, but throws * NameNotFoundException if any of the intermediate contexts do not exist. * * In a federated naming system, a context from one naming system may be * bound to a name in another. One can subsequently look up and perform * operations on the foreign context using a composite name. However, an * attempt destroy the context using this composite name will fail with * NotContextException, because the foreign context is not a "subcontext" * of the context in which it is bound. Instead, use unbind() to remove * the binding of the foreign context. Destroying the foreign context * requires that the destroySubcontext() be performed on a context from * the foreign context's "native" naming system. * * @param name the name of the context to be destroyed; may not be empty * @exception NameNotFoundException if an intermediate context does not * exist * @exception NotContextException if the name is bound but does not name * a context, or does not name a context of the appropriate type */ public void destroySubcontext(Name name) throws NamingException { dirContext.destroySubcontext(parseName(name)); cacheUnload(name.toString()); }
From source file:naming.resources.ProxyDirContext.java
/** * Binds a name to an object. All intermediate contexts and the target * context (that named by all but terminal atomic component of the name) * must already exist.//from www . jav a 2s.co m * * @param name the name to bind; may not be empty * @param obj the object to bind; possibly null * @exception NameAlreadyBoundException if name is already bound * @exception InvalidAttributesException if object did not supply all * mandatory attributes * @exception NamingException if a naming exception is encountered */ public void bind(Name name, Object obj) throws NamingException { dirContext.bind(parseName(name), obj); cacheUnload(name.toString()); }