Author: tolusha
Date: 2011-06-08 08:40:18 -0400 (Wed, 08 Jun 2011)
New Revision: 4487
Modified:
core/branches/2.3.x/patch/2.3.8/COR-228/COR-228.patch
Log:
COR-228: patch updated
Modified: core/branches/2.3.x/patch/2.3.8/COR-228/COR-228.patch
===================================================================
--- core/branches/2.3.x/patch/2.3.8/COR-228/COR-228.patch 2011-06-08 08:16:20 UTC (rev
4486)
+++ core/branches/2.3.x/patch/2.3.8/COR-228/COR-228.patch 2011-06-08 12:40:18 UTC (rev
4487)
@@ -1,353 +1,3 @@
-Index:
exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPropertiesExtracting.java
-===================================================================
----
exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPropertiesExtracting.java (revision
4476)
-+++
exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPropertiesExtracting.java (working
copy)
-@@ -18,7 +18,6 @@
- */
- package org.exoplatform.services.document.test;
-
--import org.exoplatform.commons.utils.ISO8601;
- import org.exoplatform.services.document.DCMetaData;
- import org.exoplatform.services.document.DocumentReader;
- import org.exoplatform.services.document.DocumentReaderService;
-@@ -34,6 +33,22 @@
- {
- DocumentReaderService service;
-
-+ private void evalProps(Properties etalon, Properties testedProps, boolean testSize)
-+ {
-+ Iterator it = etalon.entrySet().iterator();
-+ while (it.hasNext())
-+ {
-+ Map.Entry prop = (Map.Entry)it.next();
-+ Object tval = testedProps.get(prop.getKey());
-+ assertNotNull(prop.getKey() + " property not founded. ", tval);
-+ assertEquals(prop.getKey() + " property value is incorrect",
prop.getValue(), tval);
-+ }
-+ if (testSize)
-+ {
-+ assertEquals("size is incorrect", etalon.size(),
testedProps.size());
-+ }
-+ }
-+
- @Override
- public void setUp() throws Exception
- {
-@@ -41,20 +56,21 @@
- service =
(DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
- }
-
-- public void testPDFDocumentReaderServiceXMPMetadata() throws Exception
-+ public void testExcelDocumentReaderService() throws Exception
- {
-- InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/MyTest.pdf");
-+ InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.xls");
- try
- {
-- DocumentReader rdr = service.getDocumentReader("application/pdf");
-- Properties testprops = rdr.getProperties(is);
-+ Properties props =
service.getDocumentReader("application/excel").getProperties(is);
- Properties etalon = new Properties();
-- etalon.put(DCMetaData.TITLE, "Test de convertion de fichier tif");
-- etalon.put(DCMetaData.CREATOR, "Christian Klaus");
-- etalon.put(DCMetaData.SUBJECT, "20080901 TEST Christian Etat OK");
-- Calendar c = ISO8601.parseEx("2008-09-01T08:01:10+00:00");
-- etalon.put(DCMetaData.DATE, c);
-- evalProps(etalon, testprops);
-+ etalon.put(DCMetaData.TITLE, "test-Title");
-+ etalon.put(DCMetaData.DATE, new Date(1283247293000L));
-+ etalon.put(DCMetaData.SUBJECT, "test-Subject");
-+ etalon.put(DCMetaData.CREATOR, "KHANH NGUYEN GIA");
-+ etalon.put(DCMetaData.CONTRIBUTOR, "Max Yakimenko");
-+ etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
-+
-+ evalProps(etalon, props, true);
- }
- finally
- {
-@@ -62,20 +78,111 @@
- }
- }
-
-- public void testWordDocumentReaderService() throws Exception
-+ public void testOODocumentReaderService() throws Exception
- {
-- InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.doc");
-+ InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.odt");
- try
- {
-- Properties props =
service.getDocumentReader("application/msword").getProperties(is);
-+ Properties props =
service.getDocumentReader("application/vnd.oasis.opendocument.text").getProperties(is);
- Properties etalon = new Properties();
-+ Calendar date = Calendar.getInstance();
-+ date.setTimeInMillis(0);
-+ date.set(2010, 7, 31, 14, 13, 23);
-+
- etalon.put(DCMetaData.TITLE, "test-Title");
-- etalon.put(DCMetaData.DATE, new Date(1283247060000L));
-+ etalon.put(DCMetaData.LANGUAGE, "ru-RU");
-+ etalon.put(DCMetaData.DATE, "2010-08-31T14:13:23");
- etalon.put(DCMetaData.SUBJECT, "test-Subject");
-- etalon.put(DCMetaData.CREATOR, "Max Yakimenko");
-- etalon.put(DCMetaData.CONTRIBUTOR, "Max Yakimenko");
-+ etalon.put(DCMetaData.CREATOR, "nikolaz ");
- etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
-- evalProps(etalon, props);
-+
-+ evalProps(etalon, props, true);
-+ }
-+ finally
-+ {
-+ is.close();
-+ }
-+ }
-+
-+ public void testPDFDocumentReaderService() throws Exception
-+ {
-+ InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.pdf");
-+ DocumentReader rdr = service.getDocumentReader("application/pdf");
-+ Properties props = rdr.getProperties(is);
-+ assertTrue(props.isEmpty());
-+
-+ // Properties etalon = new Properties();
-+ // etalon.put(DCMetaData.PUBLISHER, "FOP 0.20.4");
-+ // evalProps(etalon, props, false);
-+ }
-+
-+ public void testPDFDocumentReaderServiceBrokenFile() throws Exception
-+ {
-+ InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/pfs_accapp.pdf");
-+ try
-+ {
-+
-+ DocumentReader rdr = service.getDocumentReader("application/pdf");
-+ Properties testprops = rdr.getProperties(is);
-+ Properties etalon = new Properties();
-+ etalon.put(DCMetaData.TITLE, "Personal Account Opening Form VN");
-+ etalon.put(DCMetaData.CREATOR, "mr");
-+ evalProps(etalon, testprops, false);
-+ }
-+ finally
-+ {
-+ is.close();
-+ }
-+ }
-+
-+ public void testPDFDocumentReaderServiceMetro() throws Exception
-+ {
-+ InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/metro.pdf");
-+ try
-+ {
-+
-+ DocumentReader rdr = service.getDocumentReader("application/pdf");
-+ Properties testprops = rdr.getProperties(is);
-+ Properties etalon = new Properties();
-+ etalon.put(DCMetaData.TITLE, "metro");
-+ etalon.put(DCMetaData.CREATOR, "Preview");
-+ evalProps(etalon, testprops, false);
-+ }
-+ finally
-+ {
-+ is.close();
-+ }
-+ }
-+
-+ public void testPDFDocumentReaderServiceXMPUsecase1() throws Exception
-+ {
-+ InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/MyTest.pdf");
-+ DocumentReader rdr = service.getDocumentReader("application/pdf");
-+
-+ Properties testprops = rdr.getProperties(is);
-+ // printProps(testprops);
-+
-+ Properties etalon = new Properties();
-+ etalon.put(DCMetaData.TITLE, "Test de convertion de fichier tif");
-+ etalon.put(DCMetaData.CREATOR, "Christian Klaus");
-+ etalon.put(DCMetaData.SUBJECT, "20080901 TEST Christian Etat OK");
-+ // Calendar c = ISO8601.parseEx("2008-09-01T08:01:10+00:00");
-+ // etalon.put(DCMetaData.DATE, c);
-+
-+ evalProps(etalon, testprops, false);
-+ }
-+
-+ public void testPDFDocumentReaderServiceXMPUsecase2() throws Exception
-+ {
-+ InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/Trait_union.06.Mai_2009.pdf");
-+ try
-+ {
-+ DocumentReader rdr = service.getDocumentReader("application/pdf");
-+ Properties testprops = rdr.getProperties(is);
-+ Properties etalon = new Properties();
-+ etalon.put(DCMetaData.TITLE, "journal interne mai 2009.qxp");
-+ etalon.put(DCMetaData.CREATOR, "presse");
-+ evalProps(etalon, testprops, false);
- }
- finally
- {
-@@ -96,7 +203,7 @@
- etalon.put(DCMetaData.CREATOR, "Max Yakimenko");
- etalon.put(DCMetaData.CONTRIBUTOR, "Max Yakimenko");
- etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
-- evalProps(etalon, props);
-+ evalProps(etalon, props, true);
- }
- finally
- {
-@@ -104,21 +211,20 @@
- }
- }
-
-- public void testExcelDocumentReaderService() throws Exception
-+ public void testWordDocumentReaderService() throws Exception
- {
-- InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.xls");
-+ InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.doc");
- try
- {
-- Properties props =
service.getDocumentReader("application/excel").getProperties(is);
-+ Properties props =
service.getDocumentReader("application/msword").getProperties(is);
- Properties etalon = new Properties();
- etalon.put(DCMetaData.TITLE, "test-Title");
-- etalon.put(DCMetaData.DATE, new Date(1283247293000L));
-+ etalon.put(DCMetaData.DATE, new Date(1283247060000L));
- etalon.put(DCMetaData.SUBJECT, "test-Subject");
-- etalon.put(DCMetaData.CREATOR, "KHANH NGUYEN GIA");
-+ etalon.put(DCMetaData.CREATOR, "Max Yakimenko");
- etalon.put(DCMetaData.CONTRIBUTOR, "Max Yakimenko");
- etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
--
-- evalProps(etalon, props);
-+ evalProps(etalon, props, true);
- }
- finally
- {
-@@ -126,27 +232,27 @@
- }
- }
-
-- public void testXWordDocumentReaderService() throws Exception
-+ public void testXExcelDocumentReaderService() throws Exception
- {
-- InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.docx");
-+ InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.xlsx");
- try
- {
- Properties props =
--
service.getDocumentReader("application/vnd.openxmlformats-officedocument.wordprocessingml.document")
-+
service.getDocumentReader("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
- .getProperties(is);
- Properties etalon = new Properties();
- Calendar date = Calendar.getInstance();
- date.setTimeInMillis(0);
-- date.set(2010, 7, 31, 7, 53, 0);
-+ date.set(2010, 7, 31, 8, 7, 25);
-
- etalon.put(DCMetaData.TITLE, "test-Title");
- etalon.put(DCMetaData.DATE, date.getTime());
-- etalon.put(DCMetaData.SUBJECT, "Subject");
-- etalon.put(DCMetaData.CREATOR, "nikolaz");
-+ etalon.put(DCMetaData.SUBJECT, "test-Subject");
-+ etalon.put(DCMetaData.CREATOR, "KHANH NGUYEN GIA");
- etalon.put(DCMetaData.CONTRIBUTOR, "Max Yakimenko");
- etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
-
-- evalProps(etalon, props);
-+ evalProps(etalon, props, true);
- }
- finally
- {
-@@ -174,7 +280,7 @@
- etalon.put(DCMetaData.CONTRIBUTOR, "Max Yakimenko");
- etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
-
-- evalProps(etalon, props);
-+ evalProps(etalon, props, true);
- }
- finally
- {
-@@ -182,27 +288,27 @@
- }
- }
-
-- public void testXExcelDocumentReaderService() throws Exception
-+ public void testXWordDocumentReaderService() throws Exception
- {
-- InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.xlsx");
-+ InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.docx");
- try
- {
- Properties props =
--
service.getDocumentReader("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
-+
service.getDocumentReader("application/vnd.openxmlformats-officedocument.wordprocessingml.document")
- .getProperties(is);
- Properties etalon = new Properties();
- Calendar date = Calendar.getInstance();
- date.setTimeInMillis(0);
-- date.set(2010, 7, 31, 8, 7, 25);
-+ date.set(2010, 7, 31, 7, 53, 0);
-
- etalon.put(DCMetaData.TITLE, "test-Title");
- etalon.put(DCMetaData.DATE, date.getTime());
-- etalon.put(DCMetaData.SUBJECT, "test-Subject");
-- etalon.put(DCMetaData.CREATOR, "KHANH NGUYEN GIA");
-+ etalon.put(DCMetaData.SUBJECT, "Subject");
-+ etalon.put(DCMetaData.CREATOR, "nikolaz");
- etalon.put(DCMetaData.CONTRIBUTOR, "Max Yakimenko");
- etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
-
-- evalProps(etalon, props);
-+ evalProps(etalon, props, true);
- }
- finally
- {
-@@ -210,47 +316,4 @@
- }
- }
-
-- public void testOODocumentReaderService() throws Exception
-- {
-- InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.odt");
-- try
-- {
-- Properties props =
service.getDocumentReader("application/vnd.oasis.opendocument.text").getProperties(is);
-- Properties etalon = new Properties();
-- Calendar date = Calendar.getInstance();
-- date.setTimeInMillis(0);
-- date.set(2010, 7, 31, 14, 13, 23);
--
-- etalon.put(DCMetaData.TITLE, "test-Title");
-- etalon.put(DCMetaData.LANGUAGE, "ru-RU");
-- etalon.put(DCMetaData.DATE, "2010-08-31T14:13:23");
-- etalon.put(DCMetaData.SUBJECT, "test-Subject");
-- etalon.put(DCMetaData.CREATOR, "nikolaz ");
-- etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
--
-- evalProps(etalon, props);
-- }
-- finally
-- {
-- is.close();
-- }
-- }
--
-- private void evalProps(Properties etalon, Properties testedProps)
-- {
-- Iterator it = etalon.entrySet().iterator();
-- while (it.hasNext())
-- {
-- Map.Entry prop = (Map.Entry)it.next();
-- Object tval = testedProps.get(prop.getKey());
-- assertNotNull(prop.getKey() + " property not founded. ", tval);
-- if (tval instanceof Date)
-- {
-- System.out.println("was:" + ((Date)tval).getTime() + "
expected: " + ((Date)prop.getValue()).getTime());
-- }
-- assertEquals(prop.getKey() + " property value is incorrect",
prop.getValue(), tval);
-- }
-- assertEquals("size is incorrect", etalon.size(), testedProps.size());
-- }
--
- }
Index: exo.core.component.document/src/test/resources/Trait_union.06.Mai_2009.pdf
===================================================================
--- exo.core.component.document/src/test/resources/Trait_union.06.Mai_2009.pdf (revision
0)
@@ -40525,11 +40175,368 @@
Added: svn:mime-type
+ application/octet-stream
+Index:
exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPropertiesExtracting.java
+===================================================================
+---
exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPropertiesExtracting.java (revision
4481)
++++
exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPropertiesExtracting.java (working
copy)
+@@ -18,7 +18,6 @@
+ */
+ package org.exoplatform.services.document.test;
+
+-import org.exoplatform.commons.utils.ISO8601;
+ import org.exoplatform.services.document.DCMetaData;
+ import org.exoplatform.services.document.DocumentReader;
+ import org.exoplatform.services.document.DocumentReaderService;
+@@ -34,6 +33,22 @@
+ {
+ DocumentReaderService service;
+
++ private void evalProps(Properties etalon, Properties testedProps, boolean testSize)
++ {
++ Iterator it = etalon.entrySet().iterator();
++ while (it.hasNext())
++ {
++ Map.Entry prop = (Map.Entry)it.next();
++ Object tval = testedProps.get(prop.getKey());
++ assertNotNull(prop.getKey() + " property not founded. ", tval);
++ assertEquals(prop.getKey() + " property value is incorrect",
prop.getValue(), tval);
++ }
++ if (testSize)
++ {
++ assertEquals("size is incorrect", etalon.size(),
testedProps.size());
++ }
++ }
++
+ @Override
+ public void setUp() throws Exception
+ {
+@@ -41,20 +56,21 @@
+ service =
(DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
+ }
+
+- public void testPDFDocumentReaderServiceXMPMetadata() throws Exception
++ public void testExcelDocumentReaderService() throws Exception
+ {
+- InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/MyTest.pdf");
++ InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.xls");
+ try
+ {
+- DocumentReader rdr = service.getDocumentReader("application/pdf");
+- Properties testprops = rdr.getProperties(is);
++ Properties props =
service.getDocumentReader("application/excel").getProperties(is);
+ Properties etalon = new Properties();
+- etalon.put(DCMetaData.TITLE, "Test de convertion de fichier tif");
+- etalon.put(DCMetaData.CREATOR, "Christian Klaus");
+- etalon.put(DCMetaData.SUBJECT, "20080901 TEST Christian Etat OK");
+- Calendar c = ISO8601.parseEx("2008-09-01T08:01:10+00:00");
+- etalon.put(DCMetaData.DATE, c);
+- evalProps(etalon, testprops);
++ etalon.put(DCMetaData.TITLE, "test-Title");
++ etalon.put(DCMetaData.DATE, new Date(1283247293000L));
++ etalon.put(DCMetaData.SUBJECT, "test-Subject");
++ etalon.put(DCMetaData.CREATOR, "KHANH NGUYEN GIA");
++ etalon.put(DCMetaData.CONTRIBUTOR, "Max Yakimenko");
++ etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
++
++ evalProps(etalon, props, true);
+ }
+ finally
+ {
+@@ -62,20 +78,25 @@
+ }
+ }
+
+- public void testWordDocumentReaderService() throws Exception
++ public void testOODocumentReaderService() throws Exception
+ {
+- InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.doc");
++ InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.odt");
+ try
+ {
+- Properties props =
service.getDocumentReader("application/msword").getProperties(is);
++ Properties props =
service.getDocumentReader("application/vnd.oasis.opendocument.text").getProperties(is);
+ Properties etalon = new Properties();
++ Calendar date = Calendar.getInstance();
++ date.setTimeInMillis(0);
++ date.set(2010, 7, 31, 14, 13, 23);
++
+ etalon.put(DCMetaData.TITLE, "test-Title");
+- etalon.put(DCMetaData.DATE, new Date(1283247060000L));
++ etalon.put(DCMetaData.LANGUAGE, "ru-RU");
++ etalon.put(DCMetaData.DATE, "2010-08-31T14:13:23");
+ etalon.put(DCMetaData.SUBJECT, "test-Subject");
+- etalon.put(DCMetaData.CREATOR, "Max Yakimenko");
+- etalon.put(DCMetaData.CONTRIBUTOR, "Max Yakimenko");
++ etalon.put(DCMetaData.CREATOR, "nikolaz ");
+ etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
+- evalProps(etalon, props);
++
++ evalProps(etalon, props, true);
+ }
+ finally
+ {
+@@ -83,6 +104,92 @@
+ }
+ }
+
++ public void testPDFDocumentReaderService() throws Exception
++ {
++ InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.pdf");
++ DocumentReader rdr = service.getDocumentReader("application/pdf");
++ Properties props = rdr.getProperties(is);
++ assertTrue(props.isEmpty());
++
++ // Properties etalon = new Properties();
++ // etalon.put(DCMetaData.PUBLISHER, "FOP 0.20.4");
++ // evalProps(etalon, props, false);
++ }
++
++ public void testPDFDocumentReaderServiceBrokenFile() throws Exception
++ {
++ InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/pfs_accapp.pdf");
++ try
++ {
++
++ DocumentReader rdr = service.getDocumentReader("application/pdf");
++ Properties testprops = rdr.getProperties(is);
++ Properties etalon = new Properties();
++ etalon.put(DCMetaData.TITLE, "Personal Account Opening Form VN");
++ etalon.put(DCMetaData.CREATOR, "mr");
++ evalProps(etalon, testprops, false);
++ }
++ finally
++ {
++ is.close();
++ }
++ }
++
++ public void testPDFDocumentReaderServiceMetro() throws Exception
++ {
++ InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/metro.pdf");
++ try
++ {
++
++ DocumentReader rdr = service.getDocumentReader("application/pdf");
++ Properties testprops = rdr.getProperties(is);
++ Properties etalon = new Properties();
++ etalon.put(DCMetaData.TITLE, "metro");
++ etalon.put(DCMetaData.CREATOR, "Preview");
++ evalProps(etalon, testprops, false);
++ }
++ finally
++ {
++ is.close();
++ }
++ }
++
++ public void testPDFDocumentReaderServiceXMPUsecase1() throws Exception
++ {
++ InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/MyTest.pdf");
++ DocumentReader rdr = service.getDocumentReader("application/pdf");
++
++ Properties testprops = rdr.getProperties(is);
++ // printProps(testprops);
++
++ Properties etalon = new Properties();
++ etalon.put(DCMetaData.TITLE, "Test de convertion de fichier tif");
++ etalon.put(DCMetaData.CREATOR, "Christian Klaus");
++ etalon.put(DCMetaData.SUBJECT, "20080901 TEST Christian Etat OK");
++ // Calendar c = ISO8601.parseEx("2008-09-01T08:01:10+00:00");
++ // etalon.put(DCMetaData.DATE, c);
++
++ evalProps(etalon, testprops, false);
++ }
++
++ public void testPDFDocumentReaderServiceXMPUsecase2() throws Exception
++ {
++ InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/Trait_union.06.Mai_2009.pdf");
++ try
++ {
++ DocumentReader rdr = service.getDocumentReader("application/pdf");
++ Properties testprops = rdr.getProperties(is);
++ Properties etalon = new Properties();
++ etalon.put(DCMetaData.TITLE, "journal interne mai 2009.qxp");
++ etalon.put(DCMetaData.CREATOR, "presse");
++ evalProps(etalon, testprops, false);
++ }
++ finally
++ {
++ is.close();
++ }
++ }
++
+ public void testPPTDocumentReaderService() throws Exception
+ {
+ InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.ppt");
+@@ -96,7 +203,7 @@
+ etalon.put(DCMetaData.CREATOR, "Max Yakimenko");
+ etalon.put(DCMetaData.CONTRIBUTOR, "Max Yakimenko");
+ etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
+- evalProps(etalon, props);
++ evalProps(etalon, props, true);
+ }
+ finally
+ {
+@@ -104,21 +211,20 @@
+ }
+ }
+
+- public void testExcelDocumentReaderService() throws Exception
++ public void testWordDocumentReaderService() throws Exception
+ {
+- InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.xls");
++ InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.doc");
+ try
+ {
+- Properties props =
service.getDocumentReader("application/excel").getProperties(is);
++ Properties props =
service.getDocumentReader("application/msword").getProperties(is);
+ Properties etalon = new Properties();
+ etalon.put(DCMetaData.TITLE, "test-Title");
+- etalon.put(DCMetaData.DATE, new Date(1283247293000L));
++ etalon.put(DCMetaData.DATE, new Date(1283247060000L));
+ etalon.put(DCMetaData.SUBJECT, "test-Subject");
+- etalon.put(DCMetaData.CREATOR, "KHANH NGUYEN GIA");
++ etalon.put(DCMetaData.CREATOR, "Max Yakimenko");
+ etalon.put(DCMetaData.CONTRIBUTOR, "Max Yakimenko");
+ etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
+-
+- evalProps(etalon, props);
++ evalProps(etalon, props, true);
+ }
+ finally
+ {
+@@ -126,27 +232,27 @@
+ }
+ }
+
+- public void testXWordDocumentReaderService() throws Exception
++ public void testXExcelDocumentReaderService() throws Exception
+ {
+- InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.docx");
++ InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.xlsx");
+ try
+ {
+ Properties props =
+-
service.getDocumentReader("application/vnd.openxmlformats-officedocument.wordprocessingml.document")
++
service.getDocumentReader("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
+ .getProperties(is);
+ Properties etalon = new Properties();
+ Calendar date = Calendar.getInstance();
+ date.setTimeInMillis(0);
+- date.set(2010, 7, 31, 7, 53, 0);
++ date.set(2010, 7, 31, 8, 7, 25);
+
+ etalon.put(DCMetaData.TITLE, "test-Title");
+ etalon.put(DCMetaData.DATE, date.getTime());
+- etalon.put(DCMetaData.SUBJECT, "Subject");
+- etalon.put(DCMetaData.CREATOR, "nikolaz");
++ etalon.put(DCMetaData.SUBJECT, "test-Subject");
++ etalon.put(DCMetaData.CREATOR, "KHANH NGUYEN GIA");
+ etalon.put(DCMetaData.CONTRIBUTOR, "Max Yakimenko");
+ etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
+
+- evalProps(etalon, props);
++ evalProps(etalon, props, true);
+ }
+ finally
+ {
+@@ -174,7 +280,7 @@
+ etalon.put(DCMetaData.CONTRIBUTOR, "Max Yakimenko");
+ etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
+
+- evalProps(etalon, props);
++ evalProps(etalon, props, true);
+ }
+ finally
+ {
+@@ -182,27 +288,27 @@
+ }
+ }
+
+- public void testXExcelDocumentReaderService() throws Exception
++ public void testXWordDocumentReaderService() throws Exception
+ {
+- InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.xlsx");
++ InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.docx");
+ try
+ {
+ Properties props =
+-
service.getDocumentReader("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
++
service.getDocumentReader("application/vnd.openxmlformats-officedocument.wordprocessingml.document")
+ .getProperties(is);
+ Properties etalon = new Properties();
+ Calendar date = Calendar.getInstance();
+ date.setTimeInMillis(0);
+- date.set(2010, 7, 31, 8, 7, 25);
++ date.set(2010, 7, 31, 7, 53, 0);
+
+ etalon.put(DCMetaData.TITLE, "test-Title");
+ etalon.put(DCMetaData.DATE, date.getTime());
+- etalon.put(DCMetaData.SUBJECT, "test-Subject");
+- etalon.put(DCMetaData.CREATOR, "KHANH NGUYEN GIA");
++ etalon.put(DCMetaData.SUBJECT, "Subject");
++ etalon.put(DCMetaData.CREATOR, "nikolaz");
+ etalon.put(DCMetaData.CONTRIBUTOR, "Max Yakimenko");
+ etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
+
+- evalProps(etalon, props);
++ evalProps(etalon, props, true);
+ }
+ finally
+ {
+@@ -210,47 +316,4 @@
+ }
+ }
+
+- public void testOODocumentReaderService() throws Exception
+- {
+- InputStream is =
TestPropertiesExtracting.class.getResourceAsStream("/test.odt");
+- try
+- {
+- Properties props =
service.getDocumentReader("application/vnd.oasis.opendocument.text").getProperties(is);
+- Properties etalon = new Properties();
+- Calendar date = Calendar.getInstance();
+- date.setTimeInMillis(0);
+- date.set(2010, 7, 31, 14, 13, 23);
+-
+- etalon.put(DCMetaData.TITLE, "test-Title");
+- etalon.put(DCMetaData.LANGUAGE, "ru-RU");
+- etalon.put(DCMetaData.DATE, "2010-08-31T14:13:23");
+- etalon.put(DCMetaData.SUBJECT, "test-Subject");
+- etalon.put(DCMetaData.CREATOR, "nikolaz ");
+- etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
+-
+- evalProps(etalon, props);
+- }
+- finally
+- {
+- is.close();
+- }
+- }
+-
+- private void evalProps(Properties etalon, Properties testedProps)
+- {
+- Iterator it = etalon.entrySet().iterator();
+- while (it.hasNext())
+- {
+- Map.Entry prop = (Map.Entry)it.next();
+- Object tval = testedProps.get(prop.getKey());
+- assertNotNull(prop.getKey() + " property not founded. ", tval);
+- if (tval instanceof Date)
+- {
+- System.out.println("was:" + ((Date)tval).getTime() + "
expected: " + ((Date)prop.getValue()).getTime());
+- }
+- assertEquals(prop.getKey() + " property value is incorrect",
prop.getValue(), tval);
+- }
+- assertEquals("size is incorrect", etalon.size(), testedProps.size());
+- }
+-
+ }
Index:
exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/PDFDocumentReader.java
===================================================================
---
exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/PDFDocumentReader.java (revision
4481)
+++
exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/PDFDocumentReader.java (working
copy)
-@@ -18,37 +18,31 @@
+@@ -18,37 +18,28 @@
*/
package org.exoplatform.services.document.impl;
@@ -40559,11 +40566,11 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
+-import java.security.AccessController;
+-import java.security.PrivilegedActionException;
+-import java.security.PrivilegedExceptionAction;
+-import java.text.ParseException;
+import java.io.UnsupportedEncodingException;
- import java.security.AccessController;
- import java.security.PrivilegedActionException;
- import java.security.PrivilegedExceptionAction;
--import java.text.ParseException;
import java.util.Calendar;
-import java.util.HashMap;
+import java.util.List;
@@ -40576,8 +40583,125 @@
/**
* Created by The eXo Platform SAS A parser of Adobe PDF files.
*
-@@ -168,204 +162,269 @@
+@@ -79,79 +70,51 @@
*/
+ public String getContentAsText(final InputStream is) throws IOException,
DocumentReadException
+ {
+-
++ if (is == null)
++ {
++ throw new NullPointerException("InputStream is null.");
++ }
++ PDDocument pdDocument = null;
++ StringWriter sw = new StringWriter();
+ try
+ {
+- return (String)AccessController.doPrivileged(new
PrivilegedExceptionAction<Object>()
+- {
+- public Object run() throws Exception
+- {
+- if (is == null)
+- {
+- throw new NullPointerException("InputStream is null.");
+- }
+- PDDocument pdDocument = null;
+- StringWriter sw = new StringWriter();
+- try
+- {
+- if (is.available() == 0)
+- return "";
++ if (is.available() == 0)
++ return "";
+
+- try
+- {
+- pdDocument = PDDocument.load(is);
+- }
+- catch (IOException e)
+- {
+- throw new DocumentReadException("Can not load PDF
document.", e);
+- }
+-
+- PDFTextStripper stripper = new PDFTextStripper();
+- stripper.setStartPage(1);
+- stripper.setEndPage(Integer.MAX_VALUE);
+- stripper.writeText(pdDocument, sw);
+- }
+- finally
+- {
+- if (pdDocument != null)
+- try
+- {
+- pdDocument.close();
+- }
+- catch (IOException e)
+- {
+- }
+- if (is != null)
+- try
+- {
+- is.close();
+- }
+- catch (IOException e)
+- {
+- }
+- }
+- return sw.toString();
+- }
+- });
+-
+- }
+- catch (PrivilegedActionException pae)
+- {
+- Throwable cause = pae.getCause();
+- if (cause instanceof IOException)
++ try
+ {
+- throw (IOException)cause;
++ pdDocument = PDDocument.load(is);
+ }
+- else if (cause instanceof RuntimeException)
++ catch (IOException e)
+ {
+- throw (RuntimeException)cause;
++ throw new DocumentReadException("Can not load PDF document.", e);
+ }
+- else
+- {
+- throw new RuntimeException(cause);
+- }
++
++ PDFTextStripper stripper = new PDFTextStripper();
++ stripper.setStartPage(1);
++ stripper.setEndPage(Integer.MAX_VALUE);
++ stripper.writeText(pdDocument, sw);
+ }
+-
++ finally
++ {
++ if (pdDocument != null)
++ try
++ {
++ pdDocument.close();
++ }
++ catch (IOException e)
++ {
++ }
++ if (is != null)
++ try
++ {
++ is.close();
++ }
++ catch (IOException e)
++ {
++ }
++ }
++ return sw.toString();
+ }
+
+ public String getContentAsText(InputStream is, String encoding) throws IOException,
DocumentReadException
+@@ -168,204 +131,269 @@
+ */
public Properties getProperties(InputStream is) throws IOException,
DocumentReadException
{
-
@@ -41013,7 +41137,7 @@
}
Index: packaging/module/src/main/javascript/core.packaging.module.js
===================================================================
---- packaging/module/src/main/javascript/core.packaging.module.js (revision 4476)
+--- packaging/module/src/main/javascript/core.packaging.module.js (revision 4481)
+++ packaging/module/src/main/javascript/core.packaging.module.js (working copy)
@@ -39,6 +39,7 @@
module.component.documents =