/** Do the mapping validation on updated synonym mappings. */ @Override public void validateUpdateAsset(AssetEditorInfo pEditorInfo, Collection pUpdates) { super.validateUpdateAsset(pEditorInfo, pUpdates); PropertyUpdate mappingPropUpdate = BaseAssetService.findPropertyUpdate(SynonymProperty.MAPPING, pUpdates); doValidateAccessPrivileges(pEditorInfo, pUpdates); if (mappingPropUpdate != null) { doValidatePropertyUpdate(pEditorInfo, mappingPropUpdate); } }
protected void doValidateAccessPrivileges(AssetEditorInfo editorInfo, Collection pUpdates) { PropertyUpdate mappingPropUpdate = BaseAssetService.findPropertyUpdate(SynonymProperty.SYNONYM_LIST, pUpdates); boolean isQueryParserSynonym = false; if (mappingPropUpdate != null) { String fileName = ""; String updatedProperty = StringUtils.defaultIfEmpty((String) mappingPropUpdate.getPropertyValue(), fileName); String tokens[] = StringUtils.split(updatedProperty, '/'); try { RepositoryItem synonym = searchRepository.getItem( tokens[tokens.length - 1], SearchRepositoryItemDescriptor.SYNONYM_LIST); if (synonym != null && synonym .getPropertyValue(SynonymListProperty.FILENAME) .equals(QUERY_PARSER_SYNONYMS)) { isQueryParserSynonym = true; } } catch (Exception ex) { if (isLoggingError()) { logError("Cannot check privileges", ex); } } } mappingPropUpdate = BaseAssetService.findPropertyUpdate(SynonymProperty.MAPPING, pUpdates); if (mappingPropUpdate != null) { RepositoryItem currentItem = (RepositoryItem) editorInfo.getAssetWrapper().getAsset(); RepositoryItem synonym = (RepositoryItem) currentItem.getPropertyValue(SearchRepositoryItemDescriptor.SYNONYM_LIST); if (synonym != null && synonym.getPropertyValue(SynonymListProperty.FILENAME).equals(QUERY_PARSER_SYNONYMS)) { isQueryParserSynonym = true; } } if (isQueryParserSynonym && isNotPriviledged()) { editorInfo .getAssetService() .addError(SynonymProperty.MAPPING, ERROR_INSUFFICIENT_PRIVILEDGES); } }