本文整理汇总了Java中org.alfresco.repo.content.metadata.MetadataExtracter.extract方法的典型用法代码示例。如果您正苦于以下问题:Java MetadataExtracter.extract方法的具体用法?Java MetadataExtracter.extract怎么用?Java MetadataExtracter.extract使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.repo.content.metadata.MetadataExtracter
的用法示例。
在下文中一共展示了MetadataExtracter.extract方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractMetadata
import org.alfresco.repo.content.metadata.MetadataExtracter; //导入方法依赖的package包/类
/**
* Extracts the metadata of a "raw" piece of content into a map.
*
* @param context Faces Context
* @param reader Content reader for the source content to extract from
* @param destination Map of metadata to set metadata values into
* @return True if an extracter was found
*/
public static boolean extractMetadata(FacesContext context, ContentReader reader, Map<QName, Serializable> destination)
{
// check that source mimetype is available
String mimetype = reader.getMimetype();
if (mimetype == null)
{
throw new AlfrescoRuntimeException("The content reader mimetype must be set: " + reader);
}
// look for a transformer
MetadataExtracter extracter = getMetadataExtracterRegistry(context).getExtracter(mimetype);
if (extracter == null)
{
// No metadata extracter is not a failure, but we flag it
return false;
}
try
{
// we have a transformer, so do it
extracter.extract(reader, destination);
return true;
}
catch (Throwable e)
{
// it failed
logger.warn("Metadata extraction failed: \n" +
" reader: " + reader + "\n" +
" extracter: " + extracter);
return false;
}
}