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);
   }
 }
  /** 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);
      }
    }
  }
  /**
   * Gets a repository item for updates from the given asset editor information.
   *
   * <p>Sometimes, the repository item is embedded into a RepositoryVersionItem instance, so this
   * utility method is used to fetch a mutable repository item no matter were it comes from.
   *
   * <p>This method may be called from {@link #preUpdateAsset(AssetEditorInfo, Collection)
   * preUpdateAsset}.
   *
   * @param pEditorInfo The asset editor information.
   * @return An editable instance of a repository item found in the given asset editor information.
   */
  protected MutableRepositoryItem getItemForUpdate(AssetEditorInfo pEditorInfo) {
    Object theAsset = pEditorInfo.getAssetWrapper().getAsset();

    // Depending on the asset type, this could be a MutableRepositoryItem or
    // GenericSecuredRepositoryVersionItem
    if (theAsset instanceof GenericSecuredRepositoryVersionItem) {
      GenericSecuredRepositoryVersionItem itemVersion =
          (GenericSecuredRepositoryVersionItem) theAsset;
      RepositoryItem item = itemVersion.getRepositoryItem();
      return item instanceof MutableRepositoryItem ? (MutableRepositoryItem) item : null;
    } else {
      return theAsset instanceof MutableRepositoryItem ? (MutableRepositoryItem) theAsset : null;
    }
  }
  /** Sets creation date and creator properties to a recently created asset. */
  @Override
  public void preAddAsset(AssetEditorInfo pEditorInfo, Collection pUpdates) {
    super.preAddAsset(pEditorInfo, pUpdates);
    // Get the current item being created
    MutableRepositoryItem currentItem =
        (MutableRepositoryItem) pEditorInfo.getAssetWrapper().getAsset();

    String currentUserId = getUserProfile().getRepositoryId();

    // Set control/review fields
    Timestamp timestamp = new Timestamp(System.currentTimeMillis());
    currentItem.setPropertyValue(BaseAssetProperty.LAST_MODIFIED_DATE, timestamp);
    currentItem.setPropertyValue(BaseAssetProperty.LAST_MODIFIED_BY, currentUserId);
    currentItem.setPropertyValue(BaseAssetProperty.CREATION_DATE, timestamp);
    currentItem.setPropertyValue(BaseAssetProperty.CREATED_BY, currentUserId);
  }