Source:
<code>public Owner updateOwner(@PathParam("owner_key") @Verify(Owner.class) String key, Owner owner) { Owner toUpdate = findOwner(key); EventBuilder eventBuilder = eventFactory.getEventBuilder(Target.OWNER, Type.MODIFIED) .setOldEntity(toUpdate); log.debug("Updating owner: {}", key); if (owner.getDisplayName() != null) { toUpdate.setDisplayName(owner.getDisplayName()); } if (owner.getParentOwner() != null) { toUpdate.setParentOwner(owner.getParentOwner()); } if (owner.getDefaultServiceLevel() != null) { if (owner.getDefaultServiceLevel().equals("")) { toUpdate.setDefaultServiceLevel(null); } else { serviceLevelValidator.validate(toUpdate, owner.getDefaultServiceLevel()); toUpdate.setDefaultServiceLevel(owner.getDefaultServiceLevel()); } } if (owner.getAutobindDisabled() != null) { toUpdate.setAutobindDisabled(owner.getAutobindDisabled()); } if (owner.getContentAccessMode() != null) { StringTokenizer st = new StringTokenizer(toUpdate.getContentAccessModeList(), ","); boolean allowed = false; while (st.hasMoreElements()) { if (st.nextElement().equals(owner.getContentAccessMode()) || "".equals(owner.getContentAccessMode())) { allowed = true; break; } } if (allowed) { String before = toUpdate.getContentAccessMode(); String after = owner.getContentAccessMode(); toUpdate.setContentAccessMode(owner.getContentAccessMode()); if (!after.equals(before)) { toUpdate.setContentAccessModeDirty(true); } } else { throw new BadRequestException( i18n.tr("The content access mode is not allowed for this owner.")); } } ownerCurator.merge(toUpdate); if (toUpdate.isContentAccessModeDirty()) { try { ownerManager.refreshOwnerForContentAccess(toUpdate); } catch (Exception e) { <START> throw new BadRequestException( <END> i18n.tr("The content access mode is not allowed for this owner.")); } } Event e = eventBuilder.setNewEntity(toUpdate).buildEvent(); sink.queueEvent(e); return toUpdate; }</code><technical_language>Embed caught exception in newly thrown exception</technical_language>

Target:
public Owner updateOwner(@PathParam("owner_key") @Verify(Owner.class) String key, Owner owner) { Owner toUpdate = findOwner(key); EventBuilder eventBuilder = eventFactory.getEventBuilder(Target.OWNER, Type.MODIFIED) .setOldEntity(toUpdate); log.debug("Updating owner: {}", key); if (owner.getDisplayName() != null) { toUpdate.setDisplayName(owner.getDisplayName()); } if (owner.getParentOwner() != null) { toUpdate.setParentOwner(owner.getParentOwner()); } if (owner.getDefaultServiceLevel() != null) { if (owner.getDefaultServiceLevel().equals("")) { toUpdate.setDefaultServiceLevel(null); } else { serviceLevelValidator.validate(toUpdate, owner.getDefaultServiceLevel()); toUpdate.setDefaultServiceLevel(owner.getDefaultServiceLevel()); } } if (owner.getAutobindDisabled() != null) { toUpdate.setAutobindDisabled(owner.getAutobindDisabled()); } if (!ContentAccessCertServiceAdapter.DEFAULT_CONTENT_ACCESS_MODE .equals(owner.contentAccessMode()) && config.getBoolean(ConfigProperties.STANDALONE)) { throw new BadRequestException( i18n.tr("The owner content access mode cannot be set directly in standalone mode.")); } if (owner.getContentAccessMode() != null) { if (toUpdate.isAllowedContentAccessMode(owner.contentAccessMode())) { String before = toUpdate.getContentAccessMode(); String after = owner.getContentAccessMode(); toUpdate.setContentAccessMode(owner.getContentAccessMode()); if (!after.equals(before)) { toUpdate.setContentAccessModeDirty(true); } } else { throw new BadRequestException( i18n.tr("The content access mode is not allowed for this owner.")); } } ownerCurator.merge(toUpdate); if (toUpdate.isContentAccessModeDirty()) { ownerManager.refreshOwnerForContentAccess(toUpdate); } Event e = eventBuilder.setNewEntity(toUpdate).buildEvent(); sink.queueEvent(e); return toUpdate; }