01-03-2012 09:34 AM
<type name="img:imagen">
<title>Imagen</title>
<parent>cm:content</parent>
<properties>
<property name="img:descripcion">
<title>Descripción</title>
<description>Breve descripción de la imagen.</description>
<type>d:text</type>
<mandatory>true</mandatory>
<default></default>
</property>
<property name="img:medidaX">
<title>Ancho de la imagen</title>
<description>Ancho de la imagen</description>
<type>d:text</type>
<mandatory>true</mandatory>
<default></default>
</property>
<property name="img:medidaY">
<title>Altura de la imagen</title>
<description>Altura de la imagen</description>
<type>d:text</type>
<mandatory>true</mandatory>
<default></default>
</property>
<property name="img:resolucion">
<title>Resolución</title>
<description>Resolución de la imagen.</description>
<type>d:text</type>
<mandatory>false</mandatory>
<default></default>
</property>
<!– property name="img:fecha">
<title>Fecha de la imagen</title>
<description>Fecha de la imagen</description>
<type>d:datetime</type>
<mandatory>false</mandatory>
<default></default>
</property –>
<property name="img:latitud">
<title>Latitud de la imagen</title>
<description>Latitud de la imagen</description>
<type>d:text</type>
<mandatory>false</mandatory>
<default></default>
</property>
<property name="img:longitud">
<title>Longitud de la imagen</title>
<description>Longitud de la imagen</description>
<type>d:text</type>
<mandatory>false</mandatory>
<default></default>
</property>
<property name="img:tiempoExposicion">
<title>Tiempo de exposición</title>
<description>Tiempo de exposición</description>
<type>d:text</type>
<mandatory>false</mandatory>
<default></default>
</property>
<property name="img:apertura">
<title>Valor de apertura de la imagen</title>
<description>Valor de apertura de la imagen</description>
<type>d:text</type>
<mandatory>false</mandatory>
<default></default>
</property>
<property name="img:velocidadISO">
<title>Tasa de velocidad ISO de la imagen</title>
<description>Tasa de velocidad ISO de la imagen</description>
<type>d:text</type>
<mandatory>false</mandatory>
<default></default>
</property>
<property name="img:flash">
<title>Con Flash</title>
<description>Con Flash</description>
<type>d:text</type>
<mandatory>false</mandatory>
<default></default>
</property>
<property name="img:modoMedida">
<title>Modo de medida de la imagen</title>
<description>Modo de medida de la imagen</description>
<type>d:text</type>
<mandatory>false</mandatory>
<default></default>
</property>
<property name="img:programaExposicion">
<title>Programa de exposición de la imagen</title>
<description>Programa de exposición de la imagen</description>
<type>d:text</type>
<mandatory>false</mandatory>
<default></default>
</property>
<property name="img:longitudFocal">
<title>Longitud focal de la imagen</title>
<description>Longitud focal de la imagen</description>
<type>d:text</type>
<mandatory>false</mandatory>
<default></default>
</property>
<property name="img:software">
<title>Software de la imagen</title>
<description>Software de la imagen</description>
<type>d:text</type>
<mandatory>false</mandatory>
<default></default>
</property>
<property name="img:copyright">
<title>Copyright de la imagen</title>
<description>Copyright de la imagen</description>
<type>d:text</type>
<mandatory>false</mandatory>
<default></default>
</property>
</properties>
<!–associations>
</associations–>
<mandatory-aspects>
<aspect>cm:taggable</aspect>
</mandatory-aspects>
</type>
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package com.metadataExtraction;
import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.content.metadata.TikaPoweredMetadataExtracter;
import org.alfresco.service.namespace.QName;
import org.apache.log4j.Logger;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.metadata.XMPDM;
import org.apache.tika.parser.Parser;
import org.apache.tika.parser.image.ImageParser;
/**
* Extracts the following values from img files:
* <pre>
* <b>descripcion:</b> – {img}:descripcion
* <b>medidaX:</b> – {img}:medidaX
* <b>medidaY:</b> – {img}:medidaY
* <b>resolucion:</b> – {img}:resolucion
* <b>fecha:</b> – {img}:fecha
* <b>latitud:</b> – {img}:latitud
* <b>longitud:</b> – {img}:longitud
* <b>tiempoExposicion:</b> – {img}:tiempoExposicion
* <b>apertura:</b> – {img}:apertura
* <b>velocidadISO:</b> – {img}:velocidadISO
* <b>flash:</b> – {img}:flash
* <b>modoMedida:</b> – {img}:modoMedida
* <b>programaExposicion:</b> – {img}:programaExposicion
* <b>longitudFocal:</b> – {img}:longitudFocal
* <b>software:</b> – {img}:software
* <b>copyright:</b> – {img}:copyright
* </pre>
*
*
* Uses Apache Tika
*
* @author Nick Burch
* @author Roy Wetherall
*/
public class ImgMetadataExtracter extends TikaPoweredMetadataExtracter
{
private Logger logger = Logger.getLogger(ImgMetadataExtracter.class);
private static final String KEY_IMG_MEDIDAX = "medidaX";
private static final String KEY_IMG_MEDIDAY = "medidaY";
private static final String KEY_IMG_RESOLUCION = "resolucion";
private static final String KEY_IMG_FECHA = "fecha";
private static final String KEY_IMG_LATITUD = "latitud";
private static final String KEY_IMG_LONGITUD = "longitud";
private static final String KEY_IMG_TIEMPO_EXPOSICION = "tiempoExposicion";
private static final String KEY_IMG_APERTURA = "apertura";
private static final String KEY_IMG_VELOCIDAD_ISO = "velocidadISO";
private static final String KEY_IMG_FLASH = "flash";
private static final String KEY_IMG_MODO_MEDIDA = "modoMedida";
private static final String KEY_IMG_PROGRAMA_EXPOSICION = "programaExposicion";
private static final String KEY_IMG_LONGITUD_FOCAL = "longitudFocal";
private static final String KEY_IMG_SOFTWARE = "software";
private static final String KEY_IMG_COPYRIGHT = "copyright";
private static final String CUSTOM_PREFIX = "img:";
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
/*
medidaX
medidaY
resolucion
fecha
latitud
longitud
tiempoExposicion
apertura
velocidadISO
flash
modoMedida
programaExposicion
longitudFocal
software
copyright
*/
public static String[] SUPPORTED_MIMETYPES = new String[] {
MimetypeMap.MIMETYPE_IMAGE_GIF,
MimetypeMap.MIMETYPE_IMAGE_JPEG,
MimetypeMap.MIMETYPE_IMAGE_PNG,
MimetypeMap.MIMETYPE_IMAGE_RGB,
MimetypeMap.MIMETYPE_IMAGE_SVG,
MimetypeMap.MIMETYPE_OPENDOCUMENT_GRAPHICS,
MimetypeMap.MIMETYPE_OPENDOCUMENT_IMAGE,
};
public ImgMetadataExtracter()
{
// super(SUPPORTED_MIMETYPES);
super(new HashSet<String>(Arrays.asList(SUPPORTED_MIMETYPES)));
logger.debug("Initializing ImgMetadataExtracter logger constructor");
}
@Override
protected Map<String, Serializable> extractSpecific(Metadata metadata, Map<String, Serializable> properties, Map<String,String> headers) {
// putRawValue(KEY_IMG_MEDIDAX, metadata.get(XMPDM.ALBUM), properties);
// putRawValue(KEY_SONG_TITLE, metadata.get(Metadata.TITLE), properties);
// putRawValue(KEY_ARTIST, metadata.get(TIFF.ARTIST), properties);
putRawValue(KEY_IMG_MEDIDAX, metadata.get(Metadata.IMAGE_WIDTH), properties);
putRawValue(KEY_IMG_MEDIDAY, metadata.get(Metadata.IMAGE_LENGTH), properties);
putRawValue(KEY_IMG_RESOLUCION, metadata.get(Metadata.RESOLUTION_HORIZONTAL), properties);
// putRawValue(KEY_IMG_FECHA, getDateOrNull(metadata.get(Metadata.CREATION_DATE)), properties);
// putRawValue(KEY_IMG_FECHA, getDateOrNull(metadata.get(Metadata.ORIGINAL_DATE)), properties);
// putRawValue(KEY_IMG_FECHA, metadata.get(Metadata.ORIGINAL_DATE), properties);
putRawValue(KEY_IMG_LATITUD, metadata.get(Metadata.LATITUDE), properties);
putRawValue(KEY_IMG_LONGITUD, metadata.get(Metadata.ALTITUDE), properties);
putRawValue(KEY_IMG_TIEMPO_EXPOSICION, metadata.get(Metadata.EXPOSURE_TIME), properties);
// putRawValue(KEY_IMG_APERTURA, metadata.get(TIFF.ALBUM), properties);
putRawValue(KEY_IMG_VELOCIDAD_ISO, metadata.get(Metadata.ISO_SPEED_RATINGS), properties);
putRawValue(KEY_IMG_FLASH, metadata.get(Metadata.FLASH_FIRED), properties);
// putRawValue(KEY_IMG_MODO_MEDIDA, metadata.get(TIFF.ALBUM), properties);
// putRawValue(KEY_IMG_PROGRAMA_EXPOSICION, metadata.get(Tiff.ALBUM), properties);
putRawValue(KEY_IMG_LONGITUD_FOCAL, metadata.get(Metadata.FOCAL_LENGTH), properties);
putRawValue(KEY_IMG_SOFTWARE, metadata.get(Metadata.SOFTWARE), properties);
// putRawValue(KEY_IMG_COPYRIGHT, metadata.get(XMPDM.COPYRIGHT), properties);
putRawValue(KEY_IMG_COPYRIGHT, "probando copyright", properties);
putRawValue(CUSTOM_PREFIX+KEY_IMG_COPYRIGHT, "probando copyright 2", properties);
putRawValue("a", getDateOrNull(metadata.get(Metadata.CREATION_DATE)), properties);
putRawValue("b", getDateOrNull(metadata.get(Metadata.ORIGINAL_DATE)), properties);
putRawValue(KEY_AUTHOR, metadata.get(Metadata.AUTHOR), properties);
putRawValue(KEY_TITLE, metadata.get(Metadata.TITLE), properties);
putRawValue(KEY_COMMENTS, metadata.get(Metadata.COMMENTS), properties);
logger.debug("Poniendo datos?");
logger.debug("KEY_IMG_MEDIDAX: "+KEY_IMG_MEDIDAX);
logger.debug("Metadata.IMAGE_WIDTH.toString(): "+Metadata.IMAGE_WIDTH.toString());
logger.debug("metadata.get(Metadata.IMAGE_WIDTH): "+metadata.get(Metadata.IMAGE_WIDTH));
logger.debug("properties: "+properties.toString());
// logger.debug("headers: "+headers.toString());
// Handle user-defined properties dynamically
// logger.debug("headers: "+headers.values().toString());
// logger.debug("headers");
// for (String key : headers.keySet())
// {
// logger.debug("key: "+key);
// logger.debug("get key: "+headers.get(key));
// }
logger.debug("Map");
Map<String, Set<QName>> mapping = super.getMapping();
for (String key : mapping.keySet())
{
logger.debug("key: "+key);
if (metadata.get(CUSTOM_PREFIX + key) != null)
{
logger.debug("dentro if key");
putRawValue(key, metadata.get(CUSTOM_PREFIX + key), properties);
}
}
logger.debug("Fi for Map");
logger.debug(metadata.get(Metadata.TITLE));
logger.debug(metadata.get(Metadata.CREATION_DATE));
logger.debug(metadata.get(Metadata.CREATOR));
logger.debug(metadata.get(Metadata.DATE));
logger.debug(metadata.get(Metadata.DESCRIPTION));
return properties;
}
@Override
protected Parser getParser() {
// TODO Auto-generated method stub
// return new TiffParser();
// return new JpegParser();
return new ImageParser();
}
private Date getDateOrNull(String dateString)
{
if (dateString != null && dateString.length() != 0)
{
try {
return dateFormat.parse(dateString);
} catch(ParseException e) {}
}
return null;
}
}
Tiene muchas lineas de prueba y loggers, para ver que es lo que se esta ejecutando.#
# MP3MetadataExtracter - default mapping
#
# author: Derek Hulley
# Namespaces
namespace.prefix.cm=http://www.alfresco.org/model/content/1.0
namespace.prefix.img=http://www.alfresco.es/model/pruebaimg/1.0
#namespace.prefix.img=img
# Mappings
medidaX=img:medidaX
medidaY=img:medidaY
resolucion=img:resolucion
#fecha=img:fecha
latitud=img:latitud
longitud=img:longitud
tiempoExposicion=img:tiempoExposicion
apertura=img:apertura
velocidadISO=img:velocidadISO
flash=img:flash
modoMedida=img:modoMedida
programaExposicion=img:programaExposicion
longitudFocal=img:longitudFocal
software=img:software
copyright=img:copyright
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<!–
This sample show how to modify the mappings properties of the new V2.1 Metadata Extractors.
In this example, in addition to the default mappings, the field 'user1' is mapped to
'cm:description'. The available source properties is described on the Javadocs of the
extracter class.
–>
<beans>
<bean id="extracter.OpenDocument" class="org.alfresco.repo.content.metadata.OpenDocumentMetadataExtracter" parent="baseMetadataExtracter" >
<property name="inheritDefaultMapping">
<value>true</value>
</property>
<property name="mappingProperties">
<props>
<prop key="namespace.prefix.cm">http://www.alfresco.org/model/content/1.0</prop>
<prop key="user1">cm:description</prop>
</props>
</property>
</bean>
<bean id="extracter.Img" class="com.metadataExtraction.ImgMetadataExtracter" parent="baseMetadataExtracter" >
<property name="inheritDefaultMapping">
<value>true</value>
</property>
<property name="mappingProperties">
<props>
<prop key="namespace.prefix.img">http://www.alfresco.es/model/pruebaimg/1.0</prop>
<prop key="medidaX">img:medidaX</prop>
<prop key="medidaY">img:medidaY</prop>
<prop key="resolucion">img:resolucion</prop>
<prop key="latitud">img:latitud</prop>
<prop key="longitud">img:longitud</prop>
<prop key="tiempoExposicion">img:tiempoExposicion</prop>
<prop key="apertura">img:apertura</prop>
<prop key="velocidadISO">img:velocidadISO</prop>
<prop key="flash">img:flash</prop>
<prop key="modoMedida">img:modoMedida</prop>
<prop key="programaExposicion">img:programaExposicion</prop>
<prop key="longitudFocal">img:longitudFocal</prop>
<prop key="software">img:software</prop>
<prop key="copyright">img:copyright</prop>
</props>
</property>
</bean>
</beans>
15:17:41,519 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] Poniendo datos?
15:17:41,519 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] KEY_IMG_MEDIDAX: medidaX
15:17:41,519 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] Metadata.IMAGE_WIDTH.toString(): org.apache.tika.metadata.Property@3416beee
15:17:41,519 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] metadata.get(Metadata.IMAGE_WIDTH): null
15:17:41,519 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] properties: {flash=null, b=null, a=null, resolucion=null, copyright=probando copyright, tiempoExposicion=null, author=null, software=null, velocidadISO=null, title=null, latitud=null, longitudFocal=null, longitud=null, img:copyright=probando copyright 2, medidaY=null, comments=null, medidaX=null}
15:17:41,519 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] Map
15:17:41,519 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: flash
15:17:41,519 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: resolucion
15:17:41,519 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: copyright
15:17:41,519 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: tiempoExposicion
15:17:41,519 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: software
15:17:41,519 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: velocidadISO
15:17:41,519 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: apertura
15:17:41,520 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: programaExposicion
15:17:41,520 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: latitud
15:17:41,520 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: longitudFocal
15:17:41,520 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: longitud
15:17:41,520 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: modoMedida
15:17:41,520 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: medidaY
15:17:41,520 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: medidaX
15:17:41,520 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] Fin for Map
15:17:41,520 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter]
15:17:41,520 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter]
15:17:41,520 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter]
15:17:41,520 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter]
15:17:41,520 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter]
01-04-2012 02:52 AM
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package com.metadataExtraction;
import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.content.metadata.TikaPoweredMetadataExtracter;
import org.alfresco.service.namespace.QName;
import org.apache.log4j.Logger;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.metadata.TIFF;
import org.apache.tika.parser.Parser;
import org.apache.tika.parser.jpeg.JpegParser;
/**
* Extracts the following values from img files:
* <pre>
* <b>descripcion:</b> – {img}:descripcion
* <b>medidaX:</b> – {img}:medidaX
* <b>medidaY:</b> – {img}:medidaY
* <b>resolucion:</b> – {img}:resolucion
* <b>fecha:</b> – {img}:fecha
* <b>latitud:</b> – {img}:latitud
* <b>longitud:</b> – {img}:longitud
* <b>tiempoExposicion:</b> – {img}:tiempoExposicion
* <b>apertura:</b> – {img}:apertura
* <b>velocidadISO:</b> – {img}:velocidadISO
* <b>flash:</b> – {img}:flash
* <b>modoMedida:</b> – {img}:modoMedida
* <b>programaExposicion:</b> – {img}:programaExposicion
* <b>longitudFocal:</b> – {img}:longitudFocal
* <b>software:</b> – {img}:software
* <b>copyright:</b> – {img}:copyright
* </pre>
*
*
* Uses Apache Tika
*
* @author Nick Burch
* @author Roy Wetherall
*/
public class ImgMetadataExtracter extends TikaPoweredMetadataExtracter
{
private Logger logger = Logger.getLogger(ImgMetadataExtracter.class);
private static final String KEY_IMG_MEDIDAX = "medidaX";
private static final String KEY_IMG_MEDIDAY = "medidaY";
private static final String KEY_IMG_RESOLUCION = "resolucion";
private static final String KEY_IMG_FECHA = "fecha";
private static final String KEY_IMG_LATITUD = "latitud";
private static final String KEY_IMG_LONGITUD = "longitud";
private static final String KEY_IMG_TIEMPO_EXPOSICION = "tiempoExposicion";
private static final String KEY_IMG_APERTURA = "apertura";
private static final String KEY_IMG_VELOCIDAD_ISO = "velocidadISO";
private static final String KEY_IMG_FLASH = "flash";
private static final String KEY_IMG_MODO_MEDIDA = "modoMedida";
private static final String KEY_IMG_PROGRAMA_EXPOSICION = "programaExposicion";
private static final String KEY_IMG_LONGITUD_FOCAL = "longitudFocal";
private static final String KEY_IMG_SOFTWARE = "software";
private static final String KEY_IMG_COPYRIGHT = "copyright";
private static final String CUSTOM_PREFIX = "img:";
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
/*
medidaX
medidaY
resolucion
fecha
latitud
longitud
tiempoExposicion
apertura
velocidadISO
flash
modoMedida
programaExposicion
longitudFocal
software
copyright
*/
public static String[] SUPPORTED_MIMETYPES = new String[] {
MimetypeMap.MIMETYPE_IMAGE_GIF,
MimetypeMap.MIMETYPE_IMAGE_JPEG,
MimetypeMap.MIMETYPE_IMAGE_PNG,
MimetypeMap.MIMETYPE_IMAGE_RGB,
MimetypeMap.MIMETYPE_IMAGE_SVG,
MimetypeMap.MIMETYPE_OPENDOCUMENT_GRAPHICS,
MimetypeMap.MIMETYPE_OPENDOCUMENT_IMAGE,
};
public ImgMetadataExtracter()
{
// super(SUPPORTED_MIMETYPES);
super(new HashSet<String>(Arrays.asList(SUPPORTED_MIMETYPES)));
logger.debug("Initializing ImgMetadataExtracter logger constructor");
}
@Override
protected Map<String, Serializable> extractSpecific(Metadata metadata, Map<String, Serializable> properties, Map<String,String> headers) {
// putRawValue(KEY_IMG_MEDIDAX, metadata.get(XMPDM.ALBUM), properties);
// putRawValue(KEY_SONG_TITLE, metadata.get(Metadata.TITLE), properties);
// putRawValue(KEY_ARTIST, metadata.get(TIFF.ARTIST), properties);
// putRawValue(KEY_IMG_MEDIDAX, metadata.get(Metadata.IMAGE_WIDTH), properties);
// putRawValue(KEY_IMG_MEDIDAY, metadata.get(Metadata.IMAGE_LENGTH), properties);
// putRawValue(KEY_IMG_RESOLUCION, metadata.get(Metadata.RESOLUTION_HORIZONTAL), properties);
//
//// putRawValue(KEY_IMG_FECHA, getDateOrNull(metadata.get(Metadata.CREATION_DATE)), properties);
//// putRawValue(KEY_IMG_FECHA, getDateOrNull(metadata.get(Metadata.ORIGINAL_DATE)), properties);
//// putRawValue(KEY_IMG_FECHA, metadata.get(Metadata.ORIGINAL_DATE), properties);
// putRawValue(KEY_IMG_LATITUD, metadata.get(Metadata.LATITUDE), properties);
// putRawValue(KEY_IMG_LONGITUD, metadata.get(Metadata.ALTITUDE), properties);
// putRawValue(KEY_IMG_TIEMPO_EXPOSICION, metadata.get(Metadata.EXPOSURE_TIME), properties);
//// putRawValue(KEY_IMG_APERTURA, metadata.get(TIFF.ALBUM), properties);
// putRawValue(KEY_IMG_VELOCIDAD_ISO, metadata.get(Metadata.ISO_SPEED_RATINGS), properties);
// putRawValue(KEY_IMG_FLASH, metadata.get(Metadata.FLASH_FIRED), properties);
//// putRawValue(KEY_IMG_MODO_MEDIDA, metadata.get(TIFF.ALBUM), properties);
//// putRawValue(KEY_IMG_PROGRAMA_EXPOSICION, metadata.get(Tiff.ALBUM), properties);
// putRawValue(KEY_IMG_LONGITUD_FOCAL, metadata.get(Metadata.FOCAL_LENGTH), properties);
// putRawValue(KEY_IMG_SOFTWARE, metadata.get(Metadata.SOFTWARE), properties);
//
//// putRawValue(KEY_IMG_COPYRIGHT, metadata.get(XMPDM.COPYRIGHT), properties);
// putRawValue(KEY_IMG_COPYRIGHT, "probando copyright", properties);
// putRawValue(CUSTOM_PREFIX+KEY_IMG_COPYRIGHT, "probando copyright 2", properties);
//
// putRawValue("a", getDateOrNull(metadata.get(Metadata.CREATION_DATE)), properties);
// putRawValue("b", getDateOrNull(metadata.get(Metadata.ORIGINAL_DATE)), properties);
// putRawValue("c", metadata.get(TIFF.IMAGE_WIDTH), properties);
//
// putRawValue(KEY_AUTHOR, metadata.get(Metadata.AUTHOR), properties);
// putRawValue(KEY_TITLE, metadata.get(Metadata.TITLE), properties);
// putRawValue(KEY_COMMENTS, metadata.get(Metadata.COMMENTS), properties);
logger.debug("Poniendo datos?");
logger.debug("KEY_IMG_MEDIDAX: "+KEY_IMG_MEDIDAX);
logger.debug("Metadata.IMAGE_WIDTH.toString(): "+Metadata.IMAGE_WIDTH.toString());
logger.debug("metadata.get(Metadata.IMAGE_WIDTH): "+metadata.get(Metadata.IMAGE_WIDTH));
logger.debug("properties: "+properties.toString());
// logger.debug("headers: "+headers.toString());
// Handle user-defined properties dynamically
// logger.debug("headers: "+headers.values().toString());
// logger.debug("headers");
// for (String key : headers.keySet())
// {
// logger.debug("key: "+key);
// logger.debug("get key: "+headers.get(key));
// }
logger.debug("Map");
Map<String, Set<QName>> mapping = super.getMapping();
for (String key : mapping.keySet())
{
logger.debug("key: "+key);
if (metadata.get(CUSTOM_PREFIX + key) != null)
{
logger.debug("dentro if key");
putRawValue(key, metadata.get(CUSTOM_PREFIX + key), properties);
}
}
logger.debug("Fi for Map");
logger.debug(metadata.get(Metadata.TITLE));
logger.debug(metadata.get(Metadata.CREATION_DATE));
logger.debug(metadata.get(Metadata.CREATOR));
logger.debug(metadata.get(Metadata.DATE));
logger.debug(metadata.get(Metadata.DESCRIPTION));
return properties;
}
@Override
protected Parser getParser() {
// TODO Auto-generated method stub
// return new TiffParser();
return new JpegParser();
// return new ImageParser();
}
private Date getDateOrNull(String dateString)
{
if (dateString != null && dateString.length() != 0)
{
try {
return dateFormat.parse(dateString);
} catch(ParseException e) {}
}
return null;
}
}
protected Parser getParser() {
// TODO Auto-generated method stub
// return new TiffParser();
// return new JpegParser();
return new ImageParser();
}
a esto:protected Parser getParser() {
// TODO Auto-generated method stub
// return new TiffParser();
return new JpegParser();
// return new ImageParser();
}
08:41:31,653 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] Poniendo datos?
08:41:31,653 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] KEY_IMG_MEDIDAX: medidaX
08:41:31,654 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] Metadata.IMAGE_WIDTH.toString(): org.apache.tika.metadata.Property@6706ad67
08:41:31,654 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] metadata.get(Metadata.IMAGE_WIDTH): 250
08:41:31,654 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] properties: {Number of Components=3, Image Height=167 pixels, Data Precision=8 bits, tiff:BitsPerSample=8, Component 1=Y component: Quantization table 0, Sampling factors 2 horiz/2 vert, tiff:ImageLength=167, Component 2=Cb component: Quantization table 1, Sampling factors 1 horiz/1 vert, author=null, Component 3=Cr component: Quantization table 1, Sampling factors 1 horiz/1 vert, title=null, tiff:ImageWidth=250, Image Width=250 pixels, comments=null}
08:41:31,654 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] Map
08:41:31,654 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: flash
08:41:31,654 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: resolucion
08:41:31,654 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: copyright
08:41:31,654 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: tiempoExposicion
08:41:31,654 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: software
08:41:31,654 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: velocidadISO
08:41:31,654 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: apertura
08:41:31,654 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: programaExposicion
08:41:31,654 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: latitud
08:41:31,654 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: longitudFocal
08:41:31,654 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: longitud
08:41:31,654 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: modoMedida
08:41:31,654 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: medidaY
08:41:31,655 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] key: medidaX
08:41:31,655 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter] Fi for Map
08:41:31,655 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter]
08:41:31,655 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter]
08:41:31,655 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter]
08:41:31,655 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter]
08:41:31,655 User:admin DEBUG [metadataExtraction.ImgMetadataExtracter]
01-04-2012 05:50 AM
putRawValue("prueba1", "probando 1", properties);
putRawValue("prueba2", "probando 2", properties);
putRawValue("prueba3", "probando 3", properties);
putRawValue("prueba4", "probando 4", properties);
putRawValue("prueba5", "probando 5", properties);
prueba1=img:copyright
prueba2=cm:description
prueba3=cm:title
prueba4=cm:author
prueba5=cm:name
01-05-2012 06:47 AM
01-05-2012 07:06 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.