/** Does the actual synonym mapping property validation. */ protected void doValidatePropertyUpdate(AssetEditorInfo editorInfo, PropertyUpdate update) { String value = (String) update.getPropertyValue(); if (value.indexOf(ARROW) != -1) { String[] words = StringUtils.split(value, ARROW); if (words == null || words.length != 2) { editorInfo .getAssetService() .addError(update.getPropertyName(), ERROR_INVALID_EXPLICIT_SYNONYM_MAPPING); } } else { String[] words = StringUtils.split(value, SEPARATOR); if (words == null || words.length <= 1) { editorInfo .getAssetService() .addError(update.getPropertyName(), ERROR_INVALID_SYNONYM_MAPPING); } } }
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); } }