Alfresco Custom Metadata Extractor

时间:2012-07-31 11:35:10

标签: alfresco

我开发了一个自定义元数据提取器来提取音频和视频文件的详细元数据。提取器扩展了AbstractMappingMetadataExtracter,它需要将提取的字段映射到自定义类型。提取器类名为AudioMetadataExtractor,相应的属性文件包含映射。以下是类

的代码
public class AudioMetadataExtractor extends AbstractBaseMetadataExtractor {

public static ArrayList<String> SUPPORTED_MIMETYPES = addMimeTypes(new String[] { MimeTypes.MIMETYPE_MP3, MimeTypes.MIMETYPE_WMA });

public AudioMetadataExtractor() {
    this(SUPPORTED_MIMETYPES);
}

public AudioMetadataExtractor(ArrayList<String> supportedMimeTypes) {
    super(supportedMimeTypes);
}


@Override
protected Map<String, Serializable> extractRaw(ContentReader reader) throws Throwable {

    Map<String, Serializable> rawProperties = newRawMap();

    File file = TempFileProvider.createTempFile("DCM", "MINFO");
    reader.getContent(file);

    MediaInfoJNA mediaInfoLib = new MediaInfoJNA();
    mediaInfoLib.Open(file.getAbsolutePath());

    String album = mediaInfoLib.Get(StreamKind.General, 0, "Album", MediaInfoJNA.InfoKind.Text, MediaInfoJNA.InfoKind.Name);
    System.out.println("Album1 " + album);
    String title = mediaInfoLib.Get(StreamKind.General, 0, "Title", MediaInfoJNA.InfoKind.Text, MediaInfoJNA.InfoKind.Name);
    System.out.println("Title " + title);
    String duration = mediaInfoLib.Get(StreamKind.General, 0, "Duration", MediaInfoJNA.InfoKind.Text, MediaInfoJNA.InfoKind.Name);
    System.out.println("Duration " + duration);

    putRawValue("album", album, rawProperties);

    mediaInfoLib.Close();

    return rawProperties;
}
}

提取器的配置如下

<bean id="metadata.extractor.AudioAsset" class="com.diipl.moviebeam.dcm.alfresco.metadata.AudioMetadataExtractor" parent="baseMetadataExtracter">
    <property name="inheritDefaultMapping">
        <value>true</value>
    </property>
</bean>

问题:上传新文件时,正在调用提取器,我可以看到所有sysout都有正确的值。但是,属性未填充任何值。但是如果我在文件上运行“Extract Common Metadata”操作,则会调用提取器并且字段会获得正确的值。

0 个答案:

没有答案