Skip to content

Commit

Permalink
#23934 Setting title as part of the metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
nollymar authored and nollymar committed May 16, 2023
1 parent b6b4fcb commit 1433885
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public enum BasicMetadataFields {
VERSION_KEY ("version"),
NAME_META_KEY ("name"),
TITLE_META_KEY ("title"),
DC_TITLE_META_KEY ("dcTitle"),
PATH_META_KEY ("path"),
CONTENT_TYPE_META_KEY ("contentType"),
SHA256_META_KEY ("sha256"),
Expand Down
8 changes: 8 additions & 0 deletions dotCMS/src/main/java/com/dotcms/tika/TikaUtils.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.dotcms.tika;

import static com.dotcms.storage.model.BasicMetadataFields.DC_TITLE_META_KEY;
import static com.dotcms.storage.model.BasicMetadataFields.TITLE_META_KEY;

import com.dotcms.business.CloseDBIfOpened;
import com.dotcms.contenttype.model.field.Field;
import com.dotcms.contenttype.model.type.BaseContentType;
Expand Down Expand Up @@ -384,6 +387,11 @@ public Map<String, Object> getForcedMetaDataMap(final File binFile,
//Creating the meta data map to use by our content
metaMap.putAll(this.buildMetaDataMap());
metaMap.put(FileAssetAPI.CONTENT_FIELD, content);

//From Tika 2.x the title is mapped to dcTitle (https://cwiki.apache.org/confluence/display/TIKA/Migrating+to+Tika+2.0.0)
if(!metaMap.containsKey(TITLE_META_KEY.key()) && metaMap.containsKey(DC_TITLE_META_KEY.key())){
metaMap.put(TITLE_META_KEY.key(), metaMap.get(DC_TITLE_META_KEY.key()));
}
} catch (IOException ioExc) {
if (this.isZeroByteFileException(ioExc.getCause())) {
logWarning(binFile, ioExc.getCause());
Expand Down

0 comments on commit 1433885

Please sign in to comment.