List of usage examples for javax.naming.directory AttributeModificationException AttributeModificationException
public AttributeModificationException(String explanation)
From source file:de.fiz.ddb.aas.auxiliaryoperations.ThreadOrganisationUpdate.java
private void updateOrg() throws NameNotFoundException, AASUnauthorizedException, AttributeModificationException, ExecutionException {// w w w. j a va 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); } } } }