Tika tika = new Tika();
String mimeType = tika.detect(f);
LOG.info("Detected MIME type: "+ mimeType);
// extract metadata: first get a parser
MetadataParser parser = CFG.getParser(mimeType);
if (null == parser) {
LOG.warn("Unknown content type " + mimeType + " no metadata found, listing all tags found in file.");
MetadataParserTika mpt = new MetadataParserTika();
mpt.listMetadata(f);
} else {
PropertyMapper mapper = CFG.getPropertyMapper(mimeType);
if (null == mapper)
throw new MapperException("Unknown mime type (no configuration): " + mimeType);
String typeId = mapper.getMappedTypeId();
if (null == typeId)
throw new MapperException("No CMIS type configured for mime type" + mimeType);
// Session available? if yes do conversion
TypeDefinition td = null;
if (null!= session) {
session.getTypeDefinition(typeId);
if (null == td)
throw new MapperException("CMIS type " + typeId + " does not exist on server.");
}
LOG.info("Detected MIME type: "+ mimeType + " is mapped to CMIS type id: " + td.getId());
parser.extractMetadata(f, td);
Map<String, Object> properties = parser.getCmisProperties();
for (String key : properties.keySet()) {
LOG.info("Found metadata tag " + key + "mapped to " + properties.get(key));
}
}
} catch (Exception e) {