exo-jcr SVN: r3045 - core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-09-01 12:56:51 -0400 (Wed, 01 Sep 2010)
New Revision: 3045
Modified:
core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/HTMLDocumentReader.java
core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXExcelDocumentReader.java
core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/POIPropertiesReader.java
Log:
EXOJCR-886: Re-add the constructor with InitParams in HTMLDocumentReader to remain backward compatible, make this constructor deprecated and remove useless variables and imports
Modified: core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/HTMLDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/HTMLDocumentReader.java 2010-09-01 16:47:25 UTC (rev 3044)
+++ core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/HTMLDocumentReader.java 2010-09-01 16:56:51 UTC (rev 3045)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.services.document.impl;
+import org.exoplatform.container.xml.InitParams;
import org.exoplatform.services.document.DocumentReadException;
import org.htmlparser.Parser;
import org.htmlparser.beans.StringBean;
@@ -39,14 +40,21 @@
/**
* Initializes a newly created object for text/html files format parsing.
- *
+ * @deprecated Use the default constructor instead
* @param params the container parameters.
*/
- public HTMLDocumentReader()
+ public HTMLDocumentReader(InitParams params)
{
}
/**
+ * Initializes a newly created object for text/html files format parsing.
+ */
+ public HTMLDocumentReader()
+ {
+ }
+
+ /**
* Get the text/html,application/x-groovy+html mime type.
*
* @return The string with text/html,application/x-groovy+html mime type.
Modified: core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXExcelDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXExcelDocumentReader.java 2010-09-01 16:47:25 UTC (rev 3044)
+++ core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXExcelDocumentReader.java 2010-09-01 16:56:51 UTC (rev 3045)
@@ -18,11 +18,8 @@
*/
package org.exoplatform.services.document.impl;
-import org.apache.poi.POIXMLDocument;
-import org.apache.poi.POIXMLPropertiesTextExtractor;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException;
-import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFRow;
@@ -84,8 +81,6 @@
try
{
wb = new XSSFWorkbook(is);
- OPCPackage pkg;
-
}
catch (IOException e)
{
Modified: core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/POIPropertiesReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/POIPropertiesReader.java 2010-09-01 16:47:25 UTC (rev 3044)
+++ core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/POIPropertiesReader.java 2010-09-01 16:56:51 UTC (rev 3045)
@@ -21,8 +21,6 @@
import org.apache.poi.POIXMLDocument;
import org.apache.poi.POIXMLPropertiesTextExtractor;
import org.apache.poi.POIXMLProperties.CoreProperties;
-import org.apache.poi.POIXMLProperties.CustomProperties;
-import org.apache.poi.POIXMLProperties.ExtendedProperties;
import org.apache.poi.hpsf.MarkUnsupportedException;
import org.apache.poi.hpsf.NoPropertySetStreamException;
import org.apache.poi.hpsf.PropertySet;
15 years, 9 months
exo-jcr SVN: r3044 - core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-09-01 12:47:25 -0400 (Wed, 01 Sep 2010)
New Revision: 3044
Modified:
core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/HTMLDocumentReader.java
core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXExcelDocumentReader.java
core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/POIPropertiesReader.java
Log:
EXOJCR-886: Re-add the constructor with InitParams in HTMLDocumentReader to remain backward compatible, make this constructor deprecated and remove useless variables and imports
Modified: core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/HTMLDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/HTMLDocumentReader.java 2010-09-01 14:51:06 UTC (rev 3043)
+++ core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/HTMLDocumentReader.java 2010-09-01 16:47:25 UTC (rev 3044)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.services.document.impl;
+import org.exoplatform.container.xml.InitParams;
import org.exoplatform.services.document.DocumentReadException;
import org.htmlparser.Parser;
import org.htmlparser.beans.StringBean;
@@ -39,14 +40,21 @@
/**
* Initializes a newly created object for text/html files format parsing.
- *
+ * @deprecated Use the default constructor instead
* @param params the container parameters.
*/
- public HTMLDocumentReader()
+ public HTMLDocumentReader(InitParams params)
{
}
/**
+ * Initializes a newly created object for text/html files format parsing.
+ */
+ public HTMLDocumentReader()
+ {
+ }
+
+ /**
* Get the text/html,application/x-groovy+html mime type.
*
* @return The string with text/html,application/x-groovy+html mime type.
Modified: core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXExcelDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXExcelDocumentReader.java 2010-09-01 14:51:06 UTC (rev 3043)
+++ core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXExcelDocumentReader.java 2010-09-01 16:47:25 UTC (rev 3044)
@@ -18,11 +18,8 @@
*/
package org.exoplatform.services.document.impl;
-import org.apache.poi.POIXMLDocument;
-import org.apache.poi.POIXMLPropertiesTextExtractor;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException;
-import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFRow;
@@ -84,8 +81,6 @@
try
{
wb = new XSSFWorkbook(is);
- OPCPackage pkg;
-
}
catch (IOException e)
{
Modified: core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/POIPropertiesReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/POIPropertiesReader.java 2010-09-01 14:51:06 UTC (rev 3043)
+++ core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/POIPropertiesReader.java 2010-09-01 16:47:25 UTC (rev 3044)
@@ -21,8 +21,6 @@
import org.apache.poi.POIXMLDocument;
import org.apache.poi.POIXMLPropertiesTextExtractor;
import org.apache.poi.POIXMLProperties.CoreProperties;
-import org.apache.poi.POIXMLProperties.CustomProperties;
-import org.apache.poi.POIXMLProperties.ExtendedProperties;
import org.apache.poi.hpsf.MarkUnsupportedException;
import org.apache.poi.hpsf.NoPropertySetStreamException;
import org.apache.poi.hpsf.PropertySet;
15 years, 9 months
exo-jcr SVN: r3043 - in jcr/branches/1.12.x/exo.jcr.component.core/src/test: java/org/exoplatform/services/jcr/usecases/index and 1 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-09-01 10:51:06 -0400 (Wed, 01 Sep 2010)
New Revision: 3043
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestRandomValueIO.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexExcelFileTest.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexPDFFileTest.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexPPTFileTest.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexTextPlainFileTest.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexWordFileTest.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/SlowListTest.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/resources/index/test_index.ppt
Log:
EXOJCR-936: Avoid converting binary value to String in tests
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestRandomValueIO.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestRandomValueIO.java 2010-09-01 14:50:28 UTC (rev 3042)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestRandomValueIO.java 2010-09-01 14:51:06 UTC (rev 3043)
@@ -18,7 +18,6 @@
*/
package org.exoplatform.services.jcr.impl.storage.fs;
-import org.exoplatform.commons.utils.MimeTypeResolver;
import org.exoplatform.services.jcr.JcrImplBaseTest;
import org.exoplatform.services.jcr.core.value.EditableBinaryValue;
import org.exoplatform.services.jcr.core.value.ReadableBinaryValue;
@@ -675,16 +674,12 @@
// create property
String type = "nt:file";
- String name = "foo.doc";
+ String name = "foo.txt";
Node createdNodeRef = testRoot.addNode(name, type);
Node dataNode = createdNodeRef.addNode("jcr:content", "nt:resource");
- MimeTypeResolver mimetypeResolver = new MimeTypeResolver();
- mimetypeResolver.setDefaultMimeType("application/zip");
- String mimeType = mimetypeResolver.getMimeType(name);
-
- dataNode.setProperty("jcr:mimeType", mimeType);
+ dataNode.setProperty("jcr:mimeType", "text/plain");
dataNode.setProperty("jcr:lastModified", Calendar.getInstance());
dataNode.setProperty("jcr:data", new ByteArrayInputStream(new byte[]{}));
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexExcelFileTest.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexExcelFileTest.java 2010-09-01 14:50:28 UTC (rev 3042)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexExcelFileTest.java 2010-09-01 14:51:06 UTC (rev 3043)
@@ -51,16 +51,12 @@
{
InputStream is = IndexExcelFileTest.class.getResourceAsStream("/index/test_index.xls");
assertNotNull("Can not create an input stream from file for indexing", is);
- int size = is.available();
- byte b[] = new byte[size];
- is.read(b);
- is.close();
Node cmr = root.addNode("cmr").addNode("categories").addNode("cmr");
Node cool = cmr.addNode("cool", "nt:file");
Node contentNode = cool.addNode("jcr:content", "nt:resource");
contentNode.setProperty("jcr:encoding", "UTF-8");
- contentNode.setProperty("jcr:data", session.getValueFactory().createValue(new String(b)));
+ contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType", "application/excel");
contentNode.setProperty("jcr:lastModified", session.getValueFactory().createValue(Calendar.getInstance()));
assertNotNull("Can not create a cmr node for indexing", cmr);
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexPDFFileTest.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexPDFFileTest.java 2010-09-01 14:50:28 UTC (rev 3042)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexPDFFileTest.java 2010-09-01 14:51:06 UTC (rev 3043)
@@ -51,16 +51,12 @@
{
InputStream is = IndexPDFFileTest.class.getResourceAsStream("/index/test_index.pdf");
assertNotNull("Can not create an input stream from file for indexing", is);
- int size = is.available();
- byte b[] = new byte[size];
- is.read(b);
- is.close();
Node cmr = root.addNode("cmr").addNode("categories").addNode("cmr");
Node cool = cmr.addNode("cool", "nt:file");
Node contentNode = cool.addNode("jcr:content", "nt:resource");
contentNode.setProperty("jcr:encoding", "UTF-8");
- contentNode.setProperty("jcr:data", session.getValueFactory().createValue(new String(b)));
+ contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType", "application/pdf");
contentNode.setProperty("jcr:lastModified", session.getValueFactory().createValue(Calendar.getInstance()));
assertNotNull("Can not create a cmr node for indexing", cmr);
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexPPTFileTest.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexPPTFileTest.java 2010-09-01 14:50:28 UTC (rev 3042)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexPPTFileTest.java 2010-09-01 14:51:06 UTC (rev 3043)
@@ -52,16 +52,12 @@
{
InputStream is = IndexPPTFileTest.class.getResourceAsStream("/index/test_index.ppt");
assertNotNull("Can not create an input stream from file for indexing", is);
- int size = is.available();
- byte b[] = new byte[size];
- is.read(b);
- is.close();
Node cmr = root.addNode("cmr").addNode("categories").addNode("cmr");
Node cool = cmr.addNode("cool", "nt:file");
Node contentNode = cool.addNode("jcr:content", "nt:resource");
contentNode.setProperty("jcr:encoding", "UTF-8");
- contentNode.setProperty("jcr:data", session.getValueFactory().createValue(new String(b)));
+ contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType", "application/powerpoint");
contentNode.setProperty("jcr:lastModified", session.getValueFactory().createValue(Calendar.getInstance()));
assertNotNull("Can not create a cmr node for indexing", cmr);
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexTextPlainFileTest.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexTextPlainFileTest.java 2010-09-01 14:50:28 UTC (rev 3042)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexTextPlainFileTest.java 2010-09-01 14:51:06 UTC (rev 3043)
@@ -51,16 +51,12 @@
{
InputStream is = IndexTextPlainFileTest.class.getResourceAsStream("/index/test_index.txt");
assertNotNull("Can not create an input stream from file for indexing", is);
- int size = is.available();
- byte b[] = new byte[size];
- is.read(b);
- is.close();
Node cmr = root.addNode("cmr").addNode("categories").addNode("cmr");
Node cool = cmr.addNode("cool", "nt:file");
Node contentNode = cool.addNode("jcr:content", "nt:resource");
contentNode.setProperty("jcr:encoding", "UTF-8");
- contentNode.setProperty("jcr:data", session.getValueFactory().createValue(new String(b)));
+ contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType", "text/plain");
contentNode.setProperty("jcr:lastModified", session.getValueFactory().createValue(Calendar.getInstance()));
assertNotNull("Can not create a cmr node for indexing", cmr);
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexWordFileTest.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexWordFileTest.java 2010-09-01 14:50:28 UTC (rev 3042)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexWordFileTest.java 2010-09-01 14:51:06 UTC (rev 3043)
@@ -52,16 +52,12 @@
{
InputStream is = IndexWordFileTest.class.getResourceAsStream("/index/test_index.doc");
assertNotNull("Can not create an input stream from file for indexing", is);
- int size = is.available();
- byte b[] = new byte[size];
- is.read(b);
- is.close();
Node cmr = root.addNode("cmr").addNode("categories").addNode("cmr");
Node cool = cmr.addNode("cool", "nt:file");
Node contentNode = cool.addNode("jcr:content", "nt:resource");
contentNode.setProperty("jcr:encoding", "UTF-8");
- contentNode.setProperty("jcr:data", session.getValueFactory().createValue(new String(b)));
+ contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType", "application/msword");
contentNode.setProperty("jcr:lastModified", session.getValueFactory().createValue(Calendar.getInstance()));
assertNotNull("Can not create a cmr node for indexing", cmr);
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/SlowListTest.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/SlowListTest.java 2010-09-01 14:50:28 UTC (rev 3042)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/SlowListTest.java 2010-09-01 14:51:06 UTC (rev 3043)
@@ -50,10 +50,7 @@
long start, end;
InputStream is = SlowListTest.class.getResourceAsStream("/index/test_index.xls");
assertNotNull("Can not create an input stream from file for indexing", is);
- int size = is.available();
- byte b[] = new byte[size];
- is.read(b);
- is.close();
+
Node test = root.addNode("cms2").addNode("test");
start = System.currentTimeMillis(); // to get the time of start
assertNotNull("Can not create a test node for indexing", test);
@@ -63,7 +60,7 @@
Node cool = test.addNode(name, "nt:file");
Node contentNode = cool.addNode("jcr:content", "nt:resource");
contentNode.setProperty("jcr:encoding", "UTF-8");
- contentNode.setProperty("jcr:data", session.getValueFactory().createValue(new String(b)));
+ contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType", "application/excel");
contentNode.setProperty("jcr:lastModified", session.getValueFactory().createValue(Calendar.getInstance()));
assertNotNull("Can not create a cool node for indexing", cool);
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/resources/index/test_index.ppt
===================================================================
(Binary files differ)
15 years, 9 months
exo-jcr SVN: r3042 - in jcr/trunk/exo.jcr.component.core/src/test: resources/index and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-09-01 10:50:28 -0400 (Wed, 01 Sep 2010)
New Revision: 3042
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexExcelFileTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexPDFFileTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexPPTFileTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexTextPlainFileTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexWordFileTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/SlowListTest.java
jcr/trunk/exo.jcr.component.core/src/test/resources/index/test_index.ppt
Log:
EXOJCR-936: Avoid converting binary value to String in tests
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexExcelFileTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexExcelFileTest.java 2010-09-01 10:23:32 UTC (rev 3041)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexExcelFileTest.java 2010-09-01 14:50:28 UTC (rev 3042)
@@ -51,16 +51,12 @@
{
InputStream is = IndexExcelFileTest.class.getResourceAsStream("/index/test_index.xls");
assertNotNull("Can not create an input stream from file for indexing", is);
- int size = is.available();
- byte b[] = new byte[size];
- is.read(b);
- is.close();
Node cmr = root.addNode("cmr").addNode("categories").addNode("cmr");
Node cool = cmr.addNode("cool", "nt:file");
Node contentNode = cool.addNode("jcr:content", "nt:resource");
contentNode.setProperty("jcr:encoding", "UTF-8");
- contentNode.setProperty("jcr:data", session.getValueFactory().createValue(new String(b)));
+ contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType", "application/excel");
contentNode.setProperty("jcr:lastModified", session.getValueFactory().createValue(Calendar.getInstance()));
assertNotNull("Can not create a cmr node for indexing", cmr);
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexPDFFileTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexPDFFileTest.java 2010-09-01 10:23:32 UTC (rev 3041)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexPDFFileTest.java 2010-09-01 14:50:28 UTC (rev 3042)
@@ -51,16 +51,12 @@
{
InputStream is = IndexPDFFileTest.class.getResourceAsStream("/index/test_index.pdf");
assertNotNull("Can not create an input stream from file for indexing", is);
- int size = is.available();
- byte b[] = new byte[size];
- is.read(b);
- is.close();
Node cmr = root.addNode("cmr").addNode("categories").addNode("cmr");
Node cool = cmr.addNode("cool", "nt:file");
Node contentNode = cool.addNode("jcr:content", "nt:resource");
contentNode.setProperty("jcr:encoding", "UTF-8");
- contentNode.setProperty("jcr:data", session.getValueFactory().createValue(new String(b)));
+ contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType", "application/pdf");
contentNode.setProperty("jcr:lastModified", session.getValueFactory().createValue(Calendar.getInstance()));
assertNotNull("Can not create a cmr node for indexing", cmr);
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexPPTFileTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexPPTFileTest.java 2010-09-01 10:23:32 UTC (rev 3041)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexPPTFileTest.java 2010-09-01 14:50:28 UTC (rev 3042)
@@ -52,16 +52,12 @@
{
InputStream is = IndexPPTFileTest.class.getResourceAsStream("/index/test_index.ppt");
assertNotNull("Can not create an input stream from file for indexing", is);
- int size = is.available();
- byte b[] = new byte[size];
- is.read(b);
- is.close();
Node cmr = root.addNode("cmr").addNode("categories").addNode("cmr");
Node cool = cmr.addNode("cool", "nt:file");
Node contentNode = cool.addNode("jcr:content", "nt:resource");
contentNode.setProperty("jcr:encoding", "UTF-8");
- contentNode.setProperty("jcr:data", session.getValueFactory().createValue(new String(b)));
+ contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType", "application/powerpoint");
contentNode.setProperty("jcr:lastModified", session.getValueFactory().createValue(Calendar.getInstance()));
assertNotNull("Can not create a cmr node for indexing", cmr);
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexTextPlainFileTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexTextPlainFileTest.java 2010-09-01 10:23:32 UTC (rev 3041)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexTextPlainFileTest.java 2010-09-01 14:50:28 UTC (rev 3042)
@@ -51,16 +51,12 @@
{
InputStream is = IndexTextPlainFileTest.class.getResourceAsStream("/index/test_index.txt");
assertNotNull("Can not create an input stream from file for indexing", is);
- int size = is.available();
- byte b[] = new byte[size];
- is.read(b);
- is.close();
Node cmr = root.addNode("cmr").addNode("categories").addNode("cmr");
Node cool = cmr.addNode("cool", "nt:file");
Node contentNode = cool.addNode("jcr:content", "nt:resource");
contentNode.setProperty("jcr:encoding", "UTF-8");
- contentNode.setProperty("jcr:data", session.getValueFactory().createValue(new String(b)));
+ contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType", "text/plain");
contentNode.setProperty("jcr:lastModified", session.getValueFactory().createValue(Calendar.getInstance()));
assertNotNull("Can not create a cmr node for indexing", cmr);
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexWordFileTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexWordFileTest.java 2010-09-01 10:23:32 UTC (rev 3041)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/IndexWordFileTest.java 2010-09-01 14:50:28 UTC (rev 3042)
@@ -52,16 +52,12 @@
{
InputStream is = IndexWordFileTest.class.getResourceAsStream("/index/test_index.doc");
assertNotNull("Can not create an input stream from file for indexing", is);
- int size = is.available();
- byte b[] = new byte[size];
- is.read(b);
- is.close();
Node cmr = root.addNode("cmr").addNode("categories").addNode("cmr");
Node cool = cmr.addNode("cool", "nt:file");
Node contentNode = cool.addNode("jcr:content", "nt:resource");
contentNode.setProperty("jcr:encoding", "UTF-8");
- contentNode.setProperty("jcr:data", session.getValueFactory().createValue(new String(b)));
+ contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType", "application/msword");
contentNode.setProperty("jcr:lastModified", session.getValueFactory().createValue(Calendar.getInstance()));
assertNotNull("Can not create a cmr node for indexing", cmr);
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/SlowListTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/SlowListTest.java 2010-09-01 10:23:32 UTC (rev 3041)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/index/SlowListTest.java 2010-09-01 14:50:28 UTC (rev 3042)
@@ -50,10 +50,7 @@
long start, end;
InputStream is = SlowListTest.class.getResourceAsStream("/index/test_index.xls");
assertNotNull("Can not create an input stream from file for indexing", is);
- int size = is.available();
- byte b[] = new byte[size];
- is.read(b);
- is.close();
+
Node test = root.addNode("cms2").addNode("test");
start = System.currentTimeMillis(); // to get the time of start
assertNotNull("Can not create a test node for indexing", test);
@@ -63,7 +60,7 @@
Node cool = test.addNode(name, "nt:file");
Node contentNode = cool.addNode("jcr:content", "nt:resource");
contentNode.setProperty("jcr:encoding", "UTF-8");
- contentNode.setProperty("jcr:data", session.getValueFactory().createValue(new String(b)));
+ contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType", "application/excel");
contentNode.setProperty("jcr:lastModified", session.getValueFactory().createValue(Calendar.getInstance()));
assertNotNull("Can not create a cool node for indexing", cool);
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/index/test_index.ppt
===================================================================
(Binary files differ)
15 years, 9 months
exo-jcr SVN: r3041 - kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/listener.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-09-01 06:23:32 -0400 (Wed, 01 Sep 2010)
New Revision: 3041
Modified:
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/listener/ListenerService.java
Log:
EXOJCR-934: Decouple event name from listener name in ListenerService.
Modified: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/listener/ListenerService.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/listener/ListenerService.java 2010-09-01 10:20:09 UTC (rev 3040)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/listener/ListenerService.java 2010-09-01 10:23:32 UTC (rev 3041)
@@ -44,9 +44,9 @@
/**
* Listeners by name map.
*/
- private Map<String, List<Listener>> listeners_;
+ private final Map<String, List<Listener>> listeners_;
- private static Log log = ExoLogger.getLogger("exo.kernel.component.common.ListenerService");
+ private static final Log log = ExoLogger.getLogger("exo.kernel.component.common.ListenerService");
/**
* Construct a listener service.
@@ -77,15 +77,33 @@
}
/**
- * This method is used to register a listener with the service. The method
- * should: 1. Check to see if there is a list of listener with the listener
- * name, create one if the listener list doesn't exit 2. Add the new listener
- * to the listener list.
+ * This method is used to register a {@link Listener} to the events of the same
+ * name. It is similar to addListener(listener.getName(), listener)
*
- * @param listener
+ * @param listener the listener to notify any time an even of the same name is
+ * triggered
*/
public void addListener(Listener listener)
{
+ addListener(listener.getName(), listener);
+ }
+
+ /**
+ * This method is used to register a new {@link Listener}. Any time an
+ * event of the given event name has been triggered, the {@link Listener} will be
+ * notified.
+ * This method will:
+ * <ol>
+ * <li>Check if it exists a list of listeners that have been registered for the
+ * given event name, create a new list if no list exists</li>
+ * <li>Add the listener to the list</li>
+ * </ol>
+ * @param eventName The name of the event to listen to
+ * @param listener The Listener to notify any time the event with the given
+ * name is triggered
+ */
+ public void addListener(String eventName, Listener listener)
+ {
// Check is Listener or its superclass asynchronous, if so - wrap it in AsynchronousListener.
Class listenerClass = listener.getClass();
@@ -103,28 +121,16 @@
}
while (listenerClass != null);
- String name = listener.getName();
- List<Listener> list = listeners_.get(name);
+ List<Listener> list = listeners_.get(eventName);
if (list == null)
{
list = new ArrayList<Listener>();
- listeners_.put(name, list);
+ listeners_.put(eventName, list);
}
list.add(listener);
}
/**
- * @deprecated use the Listener name as the event name
- * @param eventName
- * @param listener
- */
- public void addListener(String eventName, Listener listener)
- {
- listener.setName(eventName);
- addListener(listener);
- }
-
- /**
* This method is used to broadcast an event. This method should: 1. Check if
* there is a list of listener that listen to the event name. 2. If there is a
* list of listener, create the event object with the given name , source and
15 years, 9 months
exo-jcr SVN: r3040 - in jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav: command/dasl and 4 other directories.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-09-01 06:20:09 -0400 (Wed, 01 Sep 2010)
New Revision: 3040
Modified:
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/PropFindCommand.java
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/dasl/SearchResultResponseEntity.java
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/deltav/report/VersionTreeResponseEntity.java
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/propfind/PropFindResponseEntity.java
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/PropertyConstants.java
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/PropstatGroupedRepresentation.java
Log:
EXOJCR-935 dav:isreadonly property management added
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/PropFindCommand.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/PropFindCommand.java 2010-09-01 10:12:38 UTC (rev 3039)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/PropFindCommand.java 2010-09-01 10:20:09 UTC (rev 3040)
@@ -142,15 +142,15 @@
if (request.getType().equalsIgnoreCase("allprop"))
{
- response = new PropFindResponseEntity(depth, resource, null, false);
+ response = new PropFindResponseEntity(depth, resource, null, false, session);
}
else if (request.getType().equalsIgnoreCase("propname"))
{
- response = new PropFindResponseEntity(depth, resource, null, true);
+ response = new PropFindResponseEntity(depth, resource, null, true, session);
}
else if (request.getType().equalsIgnoreCase("prop"))
{
- response = new PropFindResponseEntity(depth, resource, propertyNames(body), false);
+ response = new PropFindResponseEntity(depth, resource, propertyNames(body), false, session);
}
else
{
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/dasl/SearchResultResponseEntity.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/dasl/SearchResultResponseEntity.java 2010-09-01 10:12:38 UTC (rev 3039)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/dasl/SearchResultResponseEntity.java 2010-09-01 10:20:09 UTC (rev 3040)
@@ -176,7 +176,7 @@
xmlStreamWriter.writeCharacters(URLDecoder.decode(resource.getIdentifier().toASCIIString(), "UTF-8"));
xmlStreamWriter.writeEndElement();
- PropstatGroupedRepresentation propstat = new PropstatGroupedRepresentation(resource, properties, false);
+ PropstatGroupedRepresentation propstat = new PropstatGroupedRepresentation(resource, properties, false, null);
PropertyWriteUtil.writePropStats(xmlStreamWriter, propstat.getPropStats());
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/deltav/report/VersionTreeResponseEntity.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/deltav/report/VersionTreeResponseEntity.java 2010-09-01 10:12:38 UTC (rev 3039)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/deltav/report/VersionTreeResponseEntity.java 2010-09-01 10:20:09 UTC (rev 3040)
@@ -120,7 +120,7 @@
xmlStreamWriter.writeEndElement();
PropstatGroupedRepresentation propstat =
- new PropstatGroupedRepresentation(versionResource, properties, false);
+ new PropstatGroupedRepresentation(versionResource, properties, false, null);
PropertyWriteUtil.writePropStats(xmlStreamWriter, propstat.getPropStats());
xmlStreamWriter.writeEndElement();
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/propfind/PropFindResponseEntity.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/propfind/PropFindResponseEntity.java 2010-09-01 10:12:38 UTC (rev 3039)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/propfind/PropFindResponseEntity.java 2010-09-01 10:20:09 UTC (rev 3040)
@@ -36,6 +36,7 @@
import java.util.Set;
import javax.jcr.RepositoryException;
+import javax.jcr.Session;
import javax.ws.rs.core.StreamingOutput;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLOutputFactory;
@@ -91,6 +92,11 @@
* Boolean flag, shows if only property names a requested.
*/
protected final boolean propertyNamesOnly;
+
+ /**
+ * Session.
+ */
+ protected final Session session;
/**
* Constructor.
@@ -100,13 +106,14 @@
* @param propertyNames the list of properties requested
* @param propertyNamesOnly if only property names a requested
*/
- public PropFindResponseEntity(int depth, Resource rootResource, Set<QName> propertyNames, boolean propertyNamesOnly)
+ public PropFindResponseEntity(int depth, Resource rootResource, Set<QName> propertyNames, boolean propertyNamesOnly, Session session)
{
this.rootResource = rootResource;
this.namespaceContext = rootResource.getNamespaceContext();
this.propertyNames = propertyNames;
this.depth = depth;
this.propertyNamesOnly = propertyNamesOnly;
+ this.session = session;
}
/**
@@ -173,7 +180,7 @@
xmlStreamWriter.writeEndElement();
PropstatGroupedRepresentation propstat =
- new PropstatGroupedRepresentation(resource, propertyNames, propertyNamesOnly);
+ new PropstatGroupedRepresentation(resource, propertyNames, propertyNamesOnly, session);
PropertyWriteUtil.writePropStats(xmlStreamWriter, propstat.getPropStats());
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/PropertyConstants.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/PropertyConstants.java 2010-09-01 10:12:38 UTC (rev 3039)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/PropertyConstants.java 2010-09-01 10:20:09 UTC (rev 3040)
@@ -202,6 +202,11 @@
QName JCR_CONTENT = new QName("jcr:", "content");
/**
+ * dav:isreadonly property for MicroSoft Webfolders extension.
+ */
+ QName IS_READ_ONLY = new QName("DAV:", "isreadonly");
+
+ /**
* Creation date pattern.
*/
String CREATION_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'";
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/PropstatGroupedRepresentation.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/PropstatGroupedRepresentation.java 2010-09-01 10:12:38 UTC (rev 3039)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/PropstatGroupedRepresentation.java 2010-09-01 10:20:09 UTC (rev 3040)
@@ -20,11 +20,14 @@
import org.exoplatform.common.http.HTTPStatus;
import org.exoplatform.common.util.HierarchicalProperty;
+import org.exoplatform.services.jcr.access.PermissionType;
import org.exoplatform.services.jcr.webdav.WebDavConst;
import org.exoplatform.services.jcr.webdav.resource.Resource;
+import org.exoplatform.services.jcr.webdav.util.PropertyConstants;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import java.security.AccessControlException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -35,6 +38,7 @@
import javax.jcr.ItemNotFoundException;
import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException;
+import javax.jcr.Session;
import javax.xml.namespace.QName;
/**
@@ -74,15 +78,21 @@
protected final Resource resource;
/**
+ * seesion.
+ */
+ protected final Session session;
+
+ /**
* @param resource resource
* @param propNames properties names
* @param namesOnly Boolean flag. Shows if only properties names are required
* (true) or properties and values (false).
* @throws RepositoryException {@link RepositoryException}
*/
- public PropstatGroupedRepresentation(final Resource resource, final Set<QName> propNames, boolean namesOnly)
- throws RepositoryException
+ public PropstatGroupedRepresentation(final Resource resource, final Set<QName> propNames, boolean namesOnly,
+ final Session session) throws RepositoryException
{
+ this.session = session;
this.namesOnly = namesOnly;
this.resource = resource;
this.propStats = new HashMap<String, Set<HierarchicalProperty>>();
@@ -122,8 +132,23 @@
HierarchicalProperty prop = new HierarchicalProperty(propName);
try
{
- prop = resource.getProperty(propName);
- statname = WebDavConst.getStatusDescription(HTTPStatus.OK);
+ if (propName.equals(PropertyConstants.IS_READ_ONLY))
+ {
+ if (isReadOnly())
+ {
+ prop.setValue("1");
+ }
+ else
+ {
+ prop.setValue("0");
+ }
+ statname = WebDavConst.getStatusDescription(HTTPStatus.OK);
+ }
+ else
+ {
+ prop = resource.getProperty(propName);
+ statname = WebDavConst.getStatusDescription(HTTPStatus.OK);
+ }
}
catch (AccessDeniedException exc)
@@ -158,4 +183,41 @@
return propStats;
}
+ private boolean isReadOnly()
+ {
+
+ String resourcePath = resource.getIdentifier().getPath();
+ String workspace = session.getWorkspace().getName();
+ String path = resourcePath.substring(resourcePath.indexOf(workspace) + workspace.length());
+
+ try
+ {
+ session.checkPermission(path, PermissionType.READ);
+ }
+ catch (AccessControlException e1)
+ {
+ return false;
+ }
+ catch (RepositoryException e1)
+ {
+ return false;
+ }
+
+ // Node must not have any permission except "set_property" so checking for this permission
+ // must throw AccessControlException
+ try
+ {
+ session.checkPermission(path, PermissionType.SET_PROPERTY);
+ return false;
+ }
+ catch (AccessControlException e)
+ {
+ return true;
+ }
+ catch (RepositoryException e)
+ {
+ return false;
+ }
+ }
+
}
15 years, 9 months
exo-jcr SVN: r3039 - in jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav: command/dasl and 4 other directories.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-09-01 06:12:38 -0400 (Wed, 01 Sep 2010)
New Revision: 3039
Modified:
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/PropFindCommand.java
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/dasl/SearchResultResponseEntity.java
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/deltav/report/VersionTreeResponseEntity.java
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/propfind/PropFindResponseEntity.java
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/PropertyConstants.java
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/PropstatGroupedRepresentation.java
Log:
EXOJCR-935 dav:isreadonly property management added
Modified: jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/PropFindCommand.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/PropFindCommand.java 2010-09-01 10:11:32 UTC (rev 3038)
+++ jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/PropFindCommand.java 2010-09-01 10:12:38 UTC (rev 3039)
@@ -142,15 +142,15 @@
if (request.getType().equalsIgnoreCase("allprop"))
{
- response = new PropFindResponseEntity(depth, resource, null, false);
+ response = new PropFindResponseEntity(depth, resource, null, false, session);
}
else if (request.getType().equalsIgnoreCase("propname"))
{
- response = new PropFindResponseEntity(depth, resource, null, true);
+ response = new PropFindResponseEntity(depth, resource, null, true, session);
}
else if (request.getType().equalsIgnoreCase("prop"))
{
- response = new PropFindResponseEntity(depth, resource, propertyNames(body), false);
+ response = new PropFindResponseEntity(depth, resource, propertyNames(body), false, session);
}
else
{
Modified: jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/dasl/SearchResultResponseEntity.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/dasl/SearchResultResponseEntity.java 2010-09-01 10:11:32 UTC (rev 3038)
+++ jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/dasl/SearchResultResponseEntity.java 2010-09-01 10:12:38 UTC (rev 3039)
@@ -176,7 +176,7 @@
xmlStreamWriter.writeCharacters(URLDecoder.decode(resource.getIdentifier().toASCIIString(), "UTF-8"));
xmlStreamWriter.writeEndElement();
- PropstatGroupedRepresentation propstat = new PropstatGroupedRepresentation(resource, properties, false);
+ PropstatGroupedRepresentation propstat = new PropstatGroupedRepresentation(resource, properties, false, null);
PropertyWriteUtil.writePropStats(xmlStreamWriter, propstat.getPropStats());
Modified: jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/deltav/report/VersionTreeResponseEntity.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/deltav/report/VersionTreeResponseEntity.java 2010-09-01 10:11:32 UTC (rev 3038)
+++ jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/deltav/report/VersionTreeResponseEntity.java 2010-09-01 10:12:38 UTC (rev 3039)
@@ -120,7 +120,7 @@
xmlStreamWriter.writeEndElement();
PropstatGroupedRepresentation propstat =
- new PropstatGroupedRepresentation(versionResource, properties, false);
+ new PropstatGroupedRepresentation(versionResource, properties, false, null);
PropertyWriteUtil.writePropStats(xmlStreamWriter, propstat.getPropStats());
xmlStreamWriter.writeEndElement();
Modified: jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/propfind/PropFindResponseEntity.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/propfind/PropFindResponseEntity.java 2010-09-01 10:11:32 UTC (rev 3038)
+++ jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/propfind/PropFindResponseEntity.java 2010-09-01 10:12:38 UTC (rev 3039)
@@ -36,6 +36,7 @@
import java.util.Set;
import javax.jcr.RepositoryException;
+import javax.jcr.Session;
import javax.ws.rs.core.StreamingOutput;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLOutputFactory;
@@ -91,6 +92,11 @@
* Boolean flag, shows if only property names a requested.
*/
protected final boolean propertyNamesOnly;
+
+ /**
+ * Session.
+ */
+ protected final Session session;
/**
* Constructor.
@@ -100,13 +106,14 @@
* @param propertyNames the list of properties requested
* @param propertyNamesOnly if only property names a requested
*/
- public PropFindResponseEntity(int depth, Resource rootResource, Set<QName> propertyNames, boolean propertyNamesOnly)
+ public PropFindResponseEntity(int depth, Resource rootResource, Set<QName> propertyNames, boolean propertyNamesOnly, Session session)
{
this.rootResource = rootResource;
this.namespaceContext = rootResource.getNamespaceContext();
this.propertyNames = propertyNames;
this.depth = depth;
this.propertyNamesOnly = propertyNamesOnly;
+ this.session = session;
}
/**
@@ -173,7 +180,7 @@
xmlStreamWriter.writeEndElement();
PropstatGroupedRepresentation propstat =
- new PropstatGroupedRepresentation(resource, propertyNames, propertyNamesOnly);
+ new PropstatGroupedRepresentation(resource, propertyNames, propertyNamesOnly, session);
PropertyWriteUtil.writePropStats(xmlStreamWriter, propstat.getPropStats());
Modified: jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/PropertyConstants.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/PropertyConstants.java 2010-09-01 10:11:32 UTC (rev 3038)
+++ jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/PropertyConstants.java 2010-09-01 10:12:38 UTC (rev 3039)
@@ -202,6 +202,11 @@
QName JCR_CONTENT = new QName("jcr:", "content");
/**
+ * dav:isreadonly property for MicroSoft Webfolders extension.
+ */
+ QName IS_READ_ONLY = new QName("DAV:", "isreadonly");
+
+ /**
* Creation date pattern.
*/
String CREATION_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'";
Modified: jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/PropstatGroupedRepresentation.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/PropstatGroupedRepresentation.java 2010-09-01 10:11:32 UTC (rev 3038)
+++ jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/PropstatGroupedRepresentation.java 2010-09-01 10:12:38 UTC (rev 3039)
@@ -20,11 +20,14 @@
import org.exoplatform.common.http.HTTPStatus;
import org.exoplatform.common.util.HierarchicalProperty;
+import org.exoplatform.services.jcr.access.PermissionType;
import org.exoplatform.services.jcr.webdav.WebDavConst;
import org.exoplatform.services.jcr.webdav.resource.Resource;
+import org.exoplatform.services.jcr.webdav.util.PropertyConstants;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import java.security.AccessControlException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -35,6 +38,7 @@
import javax.jcr.ItemNotFoundException;
import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException;
+import javax.jcr.Session;
import javax.xml.namespace.QName;
/**
@@ -74,15 +78,21 @@
protected final Resource resource;
/**
+ * seesion.
+ */
+ protected final Session session;
+
+ /**
* @param resource resource
* @param propNames properties names
* @param namesOnly Boolean flag. Shows if only properties names are required
* (true) or properties and values (false).
* @throws RepositoryException {@link RepositoryException}
*/
- public PropstatGroupedRepresentation(final Resource resource, final Set<QName> propNames, boolean namesOnly)
- throws RepositoryException
+ public PropstatGroupedRepresentation(final Resource resource, final Set<QName> propNames, boolean namesOnly,
+ final Session session) throws RepositoryException
{
+ this.session = session;
this.namesOnly = namesOnly;
this.resource = resource;
this.propStats = new HashMap<String, Set<HierarchicalProperty>>();
@@ -122,8 +132,23 @@
HierarchicalProperty prop = new HierarchicalProperty(propName);
try
{
- prop = resource.getProperty(propName);
- statname = WebDavConst.getStatusDescription(HTTPStatus.OK);
+ if (propName.equals(PropertyConstants.IS_READ_ONLY))
+ {
+ if (isReadOnly())
+ {
+ prop.setValue("1");
+ }
+ else
+ {
+ prop.setValue("0");
+ }
+ statname = WebDavConst.getStatusDescription(HTTPStatus.OK);
+ }
+ else
+ {
+ prop = resource.getProperty(propName);
+ statname = WebDavConst.getStatusDescription(HTTPStatus.OK);
+ }
}
catch (AccessDeniedException exc)
@@ -158,4 +183,41 @@
return propStats;
}
+ private boolean isReadOnly()
+ {
+
+ String resourcePath = resource.getIdentifier().getPath();
+ String workspace = session.getWorkspace().getName();
+ String path = resourcePath.substring(resourcePath.indexOf(workspace) + workspace.length());
+
+ try
+ {
+ session.checkPermission(path, PermissionType.READ);
+ }
+ catch (AccessControlException e1)
+ {
+ return false;
+ }
+ catch (RepositoryException e1)
+ {
+ return false;
+ }
+
+ // Node must not have any permission except "set_property" so checking for this permission
+ // must throw AccessControlException
+ try
+ {
+ session.checkPermission(path, PermissionType.SET_PROPERTY);
+ return false;
+ }
+ catch (AccessControlException e)
+ {
+ return true;
+ }
+ catch (RepositoryException e)
+ {
+ return false;
+ }
+ }
+
}
15 years, 9 months
exo-jcr SVN: r3038 - kernel/branches/2.2.x/exo.kernel.component.common/src/main/java/org/exoplatform/services/listener.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-09-01 06:11:32 -0400 (Wed, 01 Sep 2010)
New Revision: 3038
Modified:
kernel/branches/2.2.x/exo.kernel.component.common/src/main/java/org/exoplatform/services/listener/ListenerService.java
Log:
EXOJCR-934: Decouple event name from listener name in ListenerService.
Modified: kernel/branches/2.2.x/exo.kernel.component.common/src/main/java/org/exoplatform/services/listener/ListenerService.java
===================================================================
--- kernel/branches/2.2.x/exo.kernel.component.common/src/main/java/org/exoplatform/services/listener/ListenerService.java 2010-09-01 08:38:05 UTC (rev 3037)
+++ kernel/branches/2.2.x/exo.kernel.component.common/src/main/java/org/exoplatform/services/listener/ListenerService.java 2010-09-01 10:11:32 UTC (rev 3038)
@@ -33,9 +33,9 @@
public class ListenerService
{
- private Map<String, List<Listener>> listeners_;
+ private final Map<String, List<Listener>> listeners_;
- private static Log log = ExoLogger.getLogger("exo.kernel.component.common.ListenerService");
+ private static final Log log = ExoLogger.getLogger("exo.kernel.component.common.ListenerService");
/**
* Construct a listener service.
@@ -46,34 +46,40 @@
}
/**
- * This method is used to register a listener with the service. The method
- * should: 1. Check to see if there is a list of listener with the listener
- * name, create one if the listener list doesn't exit 2. Add the new listener
- * to the listener list
+ * This method is used to register a {@link Listener} to the events of the same
+ * name. It is similar to addListener(listener.getName(), listener)
*
- * @param listener
+ * @param listener the listener to notify any time an even of the same name is
+ * triggered
*/
public void addListener(Listener listener)
{
- String name = listener.getName();
- List<Listener> list = listeners_.get(name);
- if (list == null)
- {
- list = new ArrayList<Listener>();
- listeners_.put(name, list);
- }
- list.add(listener);
+ addListener(listener.getName(), listener);
}
/**
- * @deprecated use the Listener name as the event name
- * @param eventName
- * @param listener
+ * This method is used to register a new {@link Listener}. Any time an
+ * event of the given event name has been triggered, the {@link Listener} will be
+ * notified.
+ * This method will:
+ * <ol>
+ * <li>Check if it exists a list of listeners that have been registered for the
+ * given event name, create a new list if no list exists</li>
+ * <li>Add the listener to the list</li>
+ * </ol>
+ * @param eventName The name of the event to listen to
+ * @param listener The Listener to notify any time the event with the given
+ * name is triggered
*/
public void addListener(String eventName, Listener listener)
{
- listener.setName(eventName);
- addListener(listener);
+ List<Listener> list = listeners_.get(eventName);
+ if (list == null)
+ {
+ list = new ArrayList<Listener>();
+ listeners_.put(eventName, list);
+ }
+ list.add(listener);
}
/**
15 years, 9 months
exo-jcr SVN: r3037 - jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-09-01 04:38:05 -0400 (Wed, 01 Sep 2010)
New Revision: 3037
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/AbstractImportTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java
Log:
EXOJCR-880 : Remark #4 (use memory in SystemViewImport) to this issue was applied.
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/AbstractImportTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/AbstractImportTest.java 2010-09-01 08:37:19 UTC (rev 3036)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/AbstractImportTest.java 2010-09-01 08:38:05 UTC (rev 3037)
@@ -320,7 +320,54 @@
outStream.close();
return outStream.toByteArray();
}
+
+ /**
+ * Serialize content of MIX_REFERENCEABLE_NODE_NAME to file.
+ *
+ * @param rootNode
+ * @param isSystemView
+ * @param isStream
+ * @return
+ * @throws IOException
+ * @throws RepositoryException
+ * @throws SAXException
+ * @throws TransformerConfigurationException
+ */
+ protected File serializeToFile(Node exportRootNode, boolean isSystemView, boolean isStream) throws IOException,
+ RepositoryException,
+ SAXException,
+ TransformerConfigurationException {
+ ExtendedSession extendedSession = (ExtendedSession) exportRootNode.getSession();
+
+ File file = File.createTempFile("export", ".xml");
+
+ FileOutputStream outStream = new FileOutputStream(file);
+
+ if (isSystemView) {
+
+ if (isStream) {
+ extendedSession.exportSystemView(exportRootNode.getPath(), outStream, false, false);
+ } else {
+ SAXTransformerFactory saxFact = (SAXTransformerFactory) TransformerFactory.newInstance();
+ TransformerHandler handler = saxFact.newTransformerHandler();
+ handler.setResult(new StreamResult(outStream));
+ extendedSession.exportSystemView(exportRootNode.getPath(), handler, false, false);
+ }
+ } else {
+ if (isStream) {
+ extendedSession.exportDocumentView(exportRootNode.getPath(), outStream, false, false);
+ } else {
+ SAXTransformerFactory saxFact = (SAXTransformerFactory) TransformerFactory.newInstance();
+ TransformerHandler handler = saxFact.newTransformerHandler();
+ handler.setResult(new StreamResult(outStream));
+ extendedSession.exportDocumentView(exportRootNode.getPath(), handler, false, false);
+ }
+ }
+ outStream.close();
+ return file;
+ }
+
protected void serialize(Node rootNode, boolean isSystemView, boolean isStream, File content) throws IOException,
RepositoryException, SAXException, TransformerConfigurationException
{
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java 2010-09-01 08:37:19 UTC (rev 3036)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java 2010-09-01 08:38:05 UTC (rev 3037)
@@ -2087,5 +2087,86 @@
fileImport.checkout();
root.save();
}
-
+
+ public void testBigRestore_Sys() throws Exception
+ {
+ File file = createBLOBTempFile(1000);
+ int depth = 1;
+
+ Node testRoot = root.addNode("testRoot");
+ Node fileNode = testRoot.addNode("TestBigRestore_Sys");
+
+ for (int i=0; i<depth; i++)
+ {
+ Node l1 = fileNode.addNode("node_l1_" + i);
+ for (int j=0; j<depth; j++)
+ {
+ Node l2 = l1.addNode("node_l2_" + j);
+ for (int k=0; k<depth; k++)
+ {
+ Node l3 = l2.addNode("node_l3_" + k, "nt:file");
+
+ Node contentNode = l3.addNode("jcr:content", "nt:resource");
+ contentNode.setProperty("jcr:data", new FileInputStream(file));
+ contentNode.setProperty("jcr:mimeType", "image/jpg");
+ contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
+
+ l3.addMixin("exo:linkable");
+ l3.setProperty("exo:links", new String[] {"http://ya.ru"});
+
+ l3.addMixin("exo:datetime");
+ l3.setProperty("exo:dateCreated", Calendar.getInstance());
+ l3.setProperty("exo:dateModified", Calendar.getInstance());
+ }
+ root.save();
+ }
+ }
+
+ root.save();
+
+ fileNode.addMixin("mix:versionable");
+ root.save();
+
+ fileNode.checkin();
+ fileNode.checkout();
+ root.save();
+
+ fileNode.checkin();
+ fileNode.checkout();
+ root.save();
+
+ //export
+ VersionableNodeInfo nodeInfo = new VersionableNodeInfo(fileNode);
+
+ // node content
+ File versionableNode = serializeToFile(fileNode, true, true);
+ // version history
+ File versionHistory = serializeToFile(fileNode.getVersionHistory(), true, true);
+
+ versionableNode.deleteOnExit();
+ versionHistory.deleteOnExit();
+
+ System.out.println("VersionNode export size : " + versionableNode.length());
+ System.out.println("VersionHistory export size : " + versionHistory.length());
+
+
+ // restore node content
+ Node restoreRoot = testRoot.addNode("restRoot");
+ testRoot.save();
+
+ deserialize(restoreRoot, XmlSaveType.SESSION, true, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING,
+ new FileInputStream(versionableNode));
+ root.save();
+
+ assertTrue(restoreRoot.hasNode("TestBigRestore_Sys"));
+
+ Node fileImport = restoreRoot.getNode("TestBigRestore_Sys");
+ assertTrue(fileImport.isNodeType("mix:versionable"));
+
+ VersionHistoryImporter versionHistoryImporter =
+ new VersionHistoryImporter((NodeImpl)fileImport, new FileInputStream(versionHistory), nodeInfo
+ .getBaseVersion(), nodeInfo.getPredecessorsHistory(), nodeInfo.getVersionHistory());
+ versionHistoryImporter.doImport();
+ root.save();
+ }
}
15 years, 9 months
exo-jcr SVN: r3036 - jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-09-01 04:37:19 -0400 (Wed, 01 Sep 2010)
New Revision: 3036
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/AbstractImportTest.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java
Log:
EXOJCR-880 : Remark #4 (use memory in SystemViewImport) to this issue was applied.
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/AbstractImportTest.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/AbstractImportTest.java 2010-09-01 07:48:47 UTC (rev 3035)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/AbstractImportTest.java 2010-09-01 08:37:19 UTC (rev 3036)
@@ -320,7 +320,54 @@
outStream.close();
return outStream.toByteArray();
}
+
+ /**
+ * Serialize content of MIX_REFERENCEABLE_NODE_NAME to file.
+ *
+ * @param rootNode
+ * @param isSystemView
+ * @param isStream
+ * @return
+ * @throws IOException
+ * @throws RepositoryException
+ * @throws SAXException
+ * @throws TransformerConfigurationException
+ */
+ protected File serializeToFile(Node exportRootNode, boolean isSystemView, boolean isStream) throws IOException,
+ RepositoryException,
+ SAXException,
+ TransformerConfigurationException {
+ ExtendedSession extendedSession = (ExtendedSession) exportRootNode.getSession();
+
+ File file = File.createTempFile("export", ".xml");
+
+ FileOutputStream outStream = new FileOutputStream(file);
+
+ if (isSystemView) {
+
+ if (isStream) {
+ extendedSession.exportSystemView(exportRootNode.getPath(), outStream, false, false);
+ } else {
+ SAXTransformerFactory saxFact = (SAXTransformerFactory) TransformerFactory.newInstance();
+ TransformerHandler handler = saxFact.newTransformerHandler();
+ handler.setResult(new StreamResult(outStream));
+ extendedSession.exportSystemView(exportRootNode.getPath(), handler, false, false);
+ }
+ } else {
+ if (isStream) {
+ extendedSession.exportDocumentView(exportRootNode.getPath(), outStream, false, false);
+ } else {
+ SAXTransformerFactory saxFact = (SAXTransformerFactory) TransformerFactory.newInstance();
+ TransformerHandler handler = saxFact.newTransformerHandler();
+ handler.setResult(new StreamResult(outStream));
+ extendedSession.exportDocumentView(exportRootNode.getPath(), handler, false, false);
+ }
+ }
+ outStream.close();
+ return file;
+ }
+
protected void serialize(Node rootNode, boolean isSystemView, boolean isStream, File content) throws IOException,
RepositoryException, SAXException, TransformerConfigurationException
{
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java 2010-09-01 07:48:47 UTC (rev 3035)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java 2010-09-01 08:37:19 UTC (rev 3036)
@@ -2087,4 +2087,86 @@
fileImport.checkout();
root.save();
}
+
+ public void testBigRestore_Sys() throws Exception
+ {
+ File file = createBLOBTempFile(1000);
+ int depth = 1;
+
+ Node testRoot = root.addNode("testRoot");
+ Node fileNode = testRoot.addNode("TestBigRestore_Sys");
+
+ for (int i=0; i<depth; i++)
+ {
+ Node l1 = fileNode.addNode("node_l1_" + i);
+ for (int j=0; j<depth; j++)
+ {
+ Node l2 = l1.addNode("node_l2_" + j);
+ for (int k=0; k<depth; k++)
+ {
+ Node l3 = l2.addNode("node_l3_" + k, "nt:file");
+
+ Node contentNode = l3.addNode("jcr:content", "nt:resource");
+ contentNode.setProperty("jcr:data", new FileInputStream(file));
+ contentNode.setProperty("jcr:mimeType", "image/jpg");
+ contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
+
+ l3.addMixin("exo:linkable");
+ l3.setProperty("exo:links", new String[] {"http://ya.ru"});
+
+ l3.addMixin("exo:datetime");
+ l3.setProperty("exo:dateCreated", Calendar.getInstance());
+ l3.setProperty("exo:dateModified", Calendar.getInstance());
+ }
+ root.save();
+ }
+ }
+
+ root.save();
+
+ fileNode.addMixin("mix:versionable");
+ root.save();
+
+ fileNode.checkin();
+ fileNode.checkout();
+ root.save();
+
+ fileNode.checkin();
+ fileNode.checkout();
+ root.save();
+
+ //export
+ VersionableNodeInfo nodeInfo = new VersionableNodeInfo(fileNode);
+
+ // node content
+ File versionableNode = serializeToFile(fileNode, true, true);
+ // version history
+ File versionHistory = serializeToFile(fileNode.getVersionHistory(), true, true);
+
+ versionableNode.deleteOnExit();
+ versionHistory.deleteOnExit();
+
+ System.out.println("VersionNode export size : " + versionableNode.length());
+ System.out.println("VersionHistory export size : " + versionHistory.length());
+
+
+ // restore node content
+ Node restoreRoot = testRoot.addNode("restRoot");
+ testRoot.save();
+
+ deserialize(restoreRoot, XmlSaveType.SESSION, true, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING,
+ new FileInputStream(versionableNode));
+ root.save();
+
+ assertTrue(restoreRoot.hasNode("TestBigRestore_Sys"));
+
+ Node fileImport = restoreRoot.getNode("TestBigRestore_Sys");
+ assertTrue(fileImport.isNodeType("mix:versionable"));
+
+ VersionHistoryImporter versionHistoryImporter =
+ new VersionHistoryImporter((NodeImpl)fileImport, new FileInputStream(versionHistory), nodeInfo
+ .getBaseVersion(), nodeInfo.getPredecessorsHistory(), nodeInfo.getVersionHistory());
+ versionHistoryImporter.doImport();
+ root.save();
+ }
}
15 years, 9 months