List of usage examples for javax.naming NameNotFoundException NameNotFoundException
public NameNotFoundException(String explanation)
From source file:de.fiz.ddb.aas.auxiliaryoperations.ThreadOrganisationSetApprove.java
public ThreadOrganisationSetApprove(OIDs pOIDs, AasPrincipal performer) throws IllegalArgumentException, ExecutionException, AASUnauthorizedException { this(performer); //check mandatory fields if (pOIDs == null) { throw new IllegalArgumentException("Illegal argument: OIDs = " + pOIDs); }/* w w w.ja v a2 s . c om*/ ThreadOrganisationRead threadOrgOnWorkDirRead = new ThreadOrganisationRead(pOIDs, performer); try { this._organisation = threadOrgOnWorkDirRead.call(); this._oldStatus = this._organisation.getStatus(); } catch (NameNotFoundException ex) { throw new ExecutionException(new NameNotFoundException( "OriganOrganization with ID '" + pOIDs + "' was not found. Message: " + ex.getMessage())); } }
From source file:io.pivotal.poc.gemfire.gtx.jndi.SimpleNamingContext.java
/** * Look up the object with the given name. * <p>Note: Not intended for direct use by applications. * Will be used by any standard InitialContext JNDI lookups. * @throws javax.naming.NameNotFoundException if the object could not be found *//*from w ww . j ava 2s . c o m*/ @Override public Object lookup(String lookupName) throws NameNotFoundException { String name = this.root + lookupName; if (logger.isDebugEnabled()) { logger.debug("Static JNDI lookup: [" + name + "]"); } if ("".equals(name)) { return new SimpleNamingContext(this.root, this.boundObjects, this.environment); } Object found = this.boundObjects.get(name); if (found == null) { if (!name.endsWith("/")) { name = name + "/"; } for (String boundName : this.boundObjects.keySet()) { if (boundName.startsWith(name)) { return new SimpleNamingContext(name, this.boundObjects, this.environment); } } throw new NameNotFoundException( "Name [" + this.root + lookupName + "] not bound; " + this.boundObjects.size() + " bindings: [" + StringUtils.collectionToDelimitedString(this.boundObjects.keySet(), ",") + "]"); } return found; }
From source file:NonSerializableFactory.java
/** Remove a binding from the NonSerializableFactory map. //from ww w . j a va2s . c o m @param key the key into the NonSerializableFactory map to remove. @throws NameNotFoundException thrown if key does not exist in the NonSerializableFactory map */ public static void unbind(String key) throws NameNotFoundException { if (wrapperMap.remove(key) == null) throw new NameNotFoundException(key + " was not found in the NonSerializableFactory map"); }
From source file:NonSerializableFactory.java
/** Remove a binding from the NonSerializableFactory map. /*from w ww .j a v a 2 s . c o m*/ @param name the name for the key into NonSerializableFactory map to remove. The key is obtained as name.toString(). @throws NameNotFoundException thrown if key does not exist in the NonSerializableFactory map */ public static void unbind(Name name) throws NameNotFoundException { String key = name.toString(); if (wrapperMap.remove(key) == null) throw new NameNotFoundException(key + " was not found in the NonSerializableFactory map"); }
From source file:de.micromata.genome.util.runtime.jndi.SimpleNamingContext.java
/** * Look up the object with the given name. * <p>//from ww w. j ava 2 s . c o m * Note: Not intended for direct use by applications. Will be used by any standard InitialContext JNDI lookups. * * @param lookupName the lookup name * @return the object * @throws NameNotFoundException the name not found exception */ public Object lookupImpl(String lookupName) throws NameNotFoundException { String name = this.root + lookupName; name = fixJavaCompName(name); if (LOG.isDebugEnabled()) { LOG.debug("LsEnv; Static JNDI lookup: [" + name + "]"); } if ("".equals(name)) { return new SimpleNamingContext(this.root, this.boundObjects, this.environment); } Object found = this.boundObjects.get(name); if (found == null) { String sname = name; if (!sname.endsWith("/")) { sname = sname + "/"; } for (String boundName : this.boundObjects.keySet()) { if (boundName.startsWith(sname)) { return new SimpleNamingContext(sname, this.boundObjects, this.environment); } } throw new NameNotFoundException( "Name [" + this.root + lookupName + "] not bound; " + this.boundObjects.size() + " bindings: [" + collectionToDelimitedString(this.boundObjects.keySet(), ",") + "]"); } return found; }
From source file:de.fiz.ddb.aas.auxiliaryoperations.ThreadOrganisationUpdate.java
private void updateOrg() throws NameNotFoundException, AASUnauthorizedException, AttributeModificationException, ExecutionException {/*from w ww . j av a 2 s.c om*/ boolean vChange = false; InitialLdapContext vCtx = null; try { if (this._oldOrganisation == null) { LOG.log(Level.WARNING, "No such organization ''{0}'' with oid: ''{1}''.", new Object[] { this._organisation.getDisplayName(), this._organisation.getOIDs() }); throw new NameNotFoundException("No such organization '" + this._organisation.getDisplayName() + "' with oid: '" + this._organisation.getOIDs() + "'."); } GeoAdresse vGeoAdresse; String vLocalDispalyName = null; if (_submit != null) { // hier ist "GeoLocationDisplayName" breits ausgefhrt try { vGeoAdresse = _submit.get(10, TimeUnit.SECONDS); if (vGeoAdresse.getRequestStatus() == GeoRequestStatus.OK) { this._organisation.getAddress().setLatitude(vGeoAdresse.getLatitude()); this._organisation.getAddress().setLongitude(vGeoAdresse.getLongitude()); this._organisation.getAddress() .setLocationDisplayName(vGeoAdresse.getLocationDisplayName()); } else { LOG.log(Level.WARNING, "GeoRequestStatus: {0}, (organization id: {1})", new Object[] { vGeoAdresse.getRequestStatus(), this._organisation.getOIDs() }); } } catch (InterruptedException ex) { LOG.log(Level.WARNING, "Geocoding request exeption for organization id: " + this._organisation.getOIDs(), ex); } catch (TimeoutException ex) { LOG.log(Level.WARNING, "Geocoding request exeption for organization id: " + this._organisation.getOIDs(), ex); } } else if (_submitGeoLocDisplayName != null) { try { vLocalDispalyName = _submitGeoLocDisplayName.get(5, TimeUnit.SECONDS); this._organisation.getAddress().setLocationDisplayName(vLocalDispalyName); //LOG.info("LocalDisplayName='" + vLocalDispalyName + "'" + vLocalDispalyName + "'"); } catch (InterruptedException ex) { LOG.log(Level.WARNING, this._organisation.getOIDs() + " without location display name: " + ex.getMessage()); } catch (ExecutionException ex) { LOG.log(Level.WARNING, this._organisation.getOIDs() + " without location display name: " + ex.getMessage()); } catch (TimeoutException ex) { LOG.log(Level.WARNING, this._organisation.getOIDs() + " without location display name: " + ex.getMessage()); } } LOG.info("newOIDs: '" + this._organisation.getOIDs() + "'"); LOG.info("oldOIDs: '" + this._oldOrganisation.getOIDs() + "'"); if (this._organisation.getOrgRDN() == null) { // -- Ansonsten eine nicht gesetzte RDN kann zum Knall fhren... this._organisation.setOrgRDN(this._oldOrganisation.getOrgRDN()); } else if (!this._organisation.getOrgRDN().equals(this._oldOrganisation.getOrgRDN())) { // -- Hier ist etwas faul... LOG.log(Level.WARNING, "The organization ''{0}'' has RDN: ''{1}'', but there exist an organization ''{0}'' with RDN: ''{2}''!", new Object[] { this._organisation.getId(), this._organisation.getOrgRDN(), this._oldOrganisation.getOrgRDN() }); throw new NameNotFoundException("No such organization '" + this._organisation.getDisplayName() + "' with oid: '" + this._organisation.getOIDs() + "'."); } if (this.isPrivilegesUpdate()) { Set<PrivilegeEnum> removePrivileges = this.privilegeDiff(this._organisation.getPrivilegesSet(), this._oldOrganisation.getPrivilegesSet()); Set<PrivilegeEnum> addPrivileges = this.privilegeDiff(this._oldOrganisation.getPrivilegesSet(), this._organisation.getPrivilegesSet()); if (!removePrivileges.isEmpty() || !addPrivileges.isEmpty()) { vChange = true; for (PrivilegeEnum p : removePrivileges) { ThreadSinglePrivilegeDelete threadSinglePrivilegeDelete = new ThreadSinglePrivilegeDelete(p, this._organisation, this._performer); threadSinglePrivilegeDelete.call(); } for (PrivilegeEnum p : addPrivileges) { ThreadSinglePrivilegeCreate threadSinglePrivilegeCreate = new ThreadSinglePrivilegeCreate(p, this._organisation, this._performer); threadSinglePrivilegeCreate.call(); } } } Attributes orgAttributes = new BasicAttributes(true); Attributes orgRemoveAttributes = new BasicAttributes(true); if (vChange = this.convertOrganizationToLdapOrgAttrsForUpdate(this._organisation, this._oldOrganisation, orgAttributes, orgRemoveAttributes, getPerformer())) { // -- If any changes, the status is set to 'revised' // but not if status will be explicitly changed or by a update operation on Licenses directory if (!isChangeOfStatus() && !isUpdatingOfLicensedOrgs()) { if ((ConstEnumOrgStatus.approved.equals(this._organisation.getStatus()))) { // -- ...then go retrospectively into "revised" status: this._organisation.setStatus(ConstEnumOrgStatus.revised); orgAttributes.put(Constants.ldap_ddbOrg_Status, String.valueOf(this._organisation.getStatus().name())); } } } // --------------------------------------------------------------------- if (vChange) { // -- Save changes to the corresponding directory: StringBuilder vOrgEntryDN = (isUpdatingOfLicensedOrgs() ? this.getLicensedOrgsDN(this._organisation.getOIDs()) : this.getOrgDN(this._organisation.getOIDs())); LOG.log(Level.INFO, "DEBUG-Info: destination OrgEntryDN = '" + vOrgEntryDN + "'"); vCtx = LDAPConnector.getSingletonInstance().takeCtx(); if (orgRemoveAttributes.size() > 0) { vCtx.modifyAttributes(vOrgEntryDN.toString(), DirContext.REMOVE_ATTRIBUTE, orgRemoveAttributes); } vCtx.modifyAttributes(vOrgEntryDN.toString(), DirContext.REPLACE_ATTRIBUTE, orgAttributes); } else { throw new AttributeModificationException( "Not modified: oid = '" + this._organisation.getOIDs() + "'"); } } catch (RejectedExecutionException ex) { LOG.log(Level.SEVERE, "RejectedExecutionException\n{0}", ex); throw new ExecutionException(ex.getMessage(), ex.getCause()); } catch (IllegalAccessException ex) { LOG.log(Level.SEVERE, "Connection-Error\n{0}", ex); throw new ExecutionException(ex.getMessage(), ex.getCause()); } catch (NameNotFoundException ex) { LOG.log(Level.WARNING, null, ex); throw ex; } catch (AttributeModificationException ex) { LOG.log(Level.WARNING, "AttributeModificationException\n{0}", ex.getMessage()); // !!!!AttributeModificationException extends NamingExeption: //throw ex; throw new AttributeModificationException(ex.getMessage()); } catch (NamingException ne) { LOG.log(Level.SEVERE, "NamingException\n{0}", ne); throw new ExecutionException(ne.getMessage(), ne.getCause()); } finally { if (vCtx != null) { try { LDAPConnector.getSingletonInstance().putCtx(vCtx); } catch (Exception ex) { LOG.log(Level.SEVERE, "Exception", ex); } } } }
From source file:de.fiz.ddb.aas.utils.LDAPEngineUtility.java
/** * get attribute values of given resource and attributes. * //from w w w. j av a2s . co m * @param scope * scope * @param id * id of resource * @param attributeName * attribute-name to retrieve * * @return String attribute value * @throws NamingException * @throws IllegalAccessException */ public Map<String, String> getResourceAttributes(Scope scope, String id, String[] attributeNames) throws NamingException, IllegalAccessException { Map<String, String> returnMap = new HashMap<String, String>(); String baseDn = null; String filter = getIdFilter(scope, id); int levelScope = 0; InitialLdapContext ctx = null; NamingEnumeration<SearchResult> results = null; if (scope == Scope.ORGANIZATION) { baseDn = LDAPConnector.getSingletonInstance().getInstitutionBaseDN(); levelScope = SearchControls.SUBTREE_SCOPE; } else if (scope == Scope.PERSON) { baseDn = LDAPConnector.getSingletonInstance().getPersonBaseDN(); levelScope = SearchControls.ONELEVEL_SCOPE; } try { ctx = LDAPConnector.getSingletonInstance().takeCtx(); results = query(ctx, baseDn, filter, attributeNames, levelScope); if (results.hasMore()) { SearchResult searchResult = results.next(); if (results.hasMore()) { throw new IllegalAccessException("found more than one object with id=" + id); } Attributes attributes = searchResult.getAttributes(); for (int i = 0; i < attributeNames.length; i++) { Attribute attribute = attributes.get(attributeNames[i]); if (attribute == null) { returnMap.put(attributeNames[i], (String) null); } else { returnMap.put(attributeNames[i], (String) attribute.get()); } } return returnMap; } else { throw new NameNotFoundException("id not found"); } } finally { if (ctx != null) { try { LDAPConnector.getSingletonInstance().putCtx(ctx); } catch (IllegalAccessException ex) { LOG.log(Level.SEVERE, null, ex); } } if (results != null) { try { results.close(); } catch (NamingException e) { LOG.log(Level.WARNING, null, e); } } } }
From source file:edu.mayo.informatics.lexgrid.convert.directConversions.claml.ClaML2LG.java
private String getMetaAttributeValueFromName(List<Meta> meta, String attributeName) throws NameNotFoundException { for (Meta currentMeta : meta) { String foundName = currentMeta.getName(); if (foundName.equals(attributeName)) { return currentMeta.getValue(); }/*from ww w .j a v a 2 s . com*/ } //if it doesn't find it, throw an Exception throw new NameNotFoundException("Could not find a Meta Element with value: " + attributeName); }
From source file:de.fiz.ddb.aas.utils.LDAPEngineUtility.java
/** * set modification-properties in LDAP.//from w w w .j a va 2 s .c o m * * @param isCreate * if also createProperties should be set. * @param performer * performer. * @param id * id to set properties for. * @param scope * scope. * * @return * @throws */ public void setModificationPropertiesInLdap(boolean isCreate, AasPrincipal performer, String id, Scope scope) throws NamingException, IllegalAccessException { String propertiesAttName = null; if (scope == Scope.PERSON) { propertiesAttName = Constants.ldap_ddbPerson_Properties; } else if (scope == Scope.ORGANIZATION) { propertiesAttName = Constants.ldap_ddbOrg_Properties; } else { throw new IllegalAccessException("scope does not match"); } Map<String, String> attributes = getResourceAttributes(scope, id, new String[] { propertiesAttName, Constants.ldap_ddb_EntryDN }); DdbProperties properties = null; String entryDn = null; if (attributes != null && StringUtils.isNotBlank(attributes.get(Constants.ldap_ddb_EntryDN))) { if (StringUtils.isNotBlank(attributes.get(propertiesAttName))) { properties = serializer.deserialize(attributes.get(propertiesAttName)); } properties = PropertiesHelper.setModificationProperties(properties, isCreate, performer); entryDn = attributes.get(Constants.ldap_ddb_EntryDN); } else { throw new NameNotFoundException("entry with id=" + id + " not found"); } InitialLdapContext ctx = null; try { ctx = LDAPConnector.getSingletonInstance().takeCtx(); Attributes saveAttributes = new BasicAttributes(true); saveAttributes.put(new BasicAttribute(propertiesAttName, serializer.serialize(properties))); ctx.modifyAttributes(entryDn, DirContext.REPLACE_ATTRIBUTE, saveAttributes); } finally { if (ctx != null) { try { LDAPConnector.getSingletonInstance().putCtx(ctx); } catch (IllegalAccessException ex) { LOG.log(Level.SEVERE, null, ex); } } } }
From source file:org.apache.naming.NamingContext.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./* www.j a v a 2s. 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 { checkWritable(); while ((!name.isEmpty()) && (name.get(0).length() == 0)) name = name.getSuffix(1); if (name.isEmpty()) throw new NamingException(sm.getString("namingContext.invalidName")); NamingEntry entry = (NamingEntry) bindings.get(name.get(0)); if (entry == null) { throw new NameNotFoundException(sm.getString("namingContext.nameNotBound", name.get(0))); } if (name.size() > 1) { if (entry.type == NamingEntry.CONTEXT) { ((Context) entry.value).unbind(name.getSuffix(1)); } else { throw new NamingException(sm.getString("namingContext.contextExpected")); } } else { bindings.remove(name.get(0)); } }