Author: tolusha
Date: 2010-06-14 04:17:58 -0400 (Mon, 14 Jun 2010)
New Revision: 2564
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/TemplateConfigurationHelper.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/RepositoryServiceConfigurationImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/BackupWorkspaceInitializer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/FileSystemLockPersister.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ErrorLog.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/FileBasedNamespaceMappings.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/directory/FSDirectoryManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueFactoryImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/FileObjectReaderImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/FilePathHolder.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedValueDataReader.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedValueDataWriter.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableIOSupport.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/FileIOChannel.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/FileValueStorage.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/SimpleFileIOChannel.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFile.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileIOHelper.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileOperation.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/PrivilegedFileHelper.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/BufferedDecoder.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/statistics/JCRStatisticsManager.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/TextExtractorTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/IndexingQueueTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/directory/DirectoryManagerTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportDocView.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportImport.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportSysView.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestDocumentViewImport.java
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/TestSystemViewImport.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/nodetypes/TestValueConstraints.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestSetProperty.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestUpdate.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestMoveNode.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestRestoreWorkspaceInitializer.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceRestore.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestArabicSearch.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestDateSearch.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestErrorMultithreading.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestExcelFileSearch.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestByteArrayPersistedValueDataSerialization.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCleanableFileStreamValueData.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationLogTestLoad.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationVSJavaSerializationTestLoad.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JcrImplSerializationBaseTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/MultipleDeserializationTestLoad.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestEOFException.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestJCRSerializationCopyMove.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestJCRSerializationStream.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestJCRSerializationVersionRestore.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestPropsDeserialization.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/ValueStoragePluginTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestRandomValueIO.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/Probe.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileIOChannel.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileValueIO.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/TestValueFileIOHelper.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/tools/tree/generator/RandomValueNodeGenerator.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestPersistedValueData.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestTransientValueData.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestTransientValueDataSpooling.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestValueImpl.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestBLOBValue.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/java/TestFileLock.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestBinaryValue.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestBinaryValueMultiThreading.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestConcurrentItems.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestExportBigFiles.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestLoadRepo.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestMoveBinaryValue.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestMoveBinaryValue1.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/thread/CreateThread.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/thread/NtFileCreatorThread.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/dataflow/persistent/TestGetNodesConcurrentModification.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestBulkItemsAdd.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestPerformance.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/storage/fs/TestFSReadWrite.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/RemoveVDTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/TestRollbackBigFiles.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/common/TestExportImportAmongSessions.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/export/ExportWorkspaceSystemViewTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/version/FileRestoreTest.java
Log:
EXOJCR-756: replace new FileInputStream on PrivilegedFileHelper.fileInputStream(), new
File() on PrivilegedFileHelper.file()
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/TemplateConfigurationHelper.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/TemplateConfigurationHelper.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/TemplateConfigurationHelper.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.config;
import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
@@ -148,7 +149,7 @@
ClassLoader cl = Thread.currentThread().getContextClassLoader();
inputStream = cl == null ? null : cl.getResourceAsStream(filename);
}
-
+
// check system class loader
if (inputStream == null)
{
@@ -160,7 +161,7 @@
{
try
{
- inputStream = new FileInputStream(filename);
+ inputStream = PrivilegedFileHelper.fileInputStream(filename);
}
catch (IOException e)
{
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/RepositoryServiceConfigurationImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/RepositoryServiceConfigurationImpl.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/RepositoryServiceConfigurationImpl.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -170,9 +170,9 @@
else
{
URL filePath = configurationService.getURL(param.getValue());
- File sourceConfig = new File(filePath.toURI());
+ File sourceConfig = PrivilegedFileHelper.file(filePath.toURI());
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmm");
- File backUp = new File(sourceConfig.getAbsoluteFile() + "_" +
format.format(new Date()));
+ File backUp = PrivilegedFileHelper.file(sourceConfig.getAbsoluteFile() +
"_" + format.format(new Date()));
if (!sourceConfig.renameTo(backUp))
throw new RepositoryException("Can't back up configuration on
path " + sourceConfig.getAbsolutePath());
saveStream = PrivilegedFileHelper.fileOutputStream(sourceConfig);
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/BackupWorkspaceInitializer.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/BackupWorkspaceInitializer.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/BackupWorkspaceInitializer.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -100,7 +100,7 @@
else
restorePath = fullBackupPath;
- this.tempDir = new File(System.getProperty("java.io.tmpdir"));
+ this.tempDir =
PrivilegedFileHelper.file(System.getProperty("java.io.tmpdir"));
}
@Override
@@ -179,7 +179,7 @@
ObjectInputStream ois = null;
try
{
- ois = new ObjectInputStream(new FileInputStream(incrementalBackupFile));
+ ois = new
ObjectInputStream(PrivilegedFileHelper.fileInputStream(incrementalBackupFile));
while (true)
{
@@ -286,7 +286,7 @@
{
ArrayList<File> list = new ArrayList<File>();
- File rDir = new File(restoreDir);
+ File rDir = PrivilegedFileHelper.file(restoreDir);
Pattern fullBackupPattern = Pattern.compile(".+\\.0");
for (File f : rDir.listFiles(new BackupFilesFilter()))
@@ -308,7 +308,7 @@
private String getFullBackupPath()
{
- File rDir = new File(restoreDir);
+ File rDir = PrivilegedFileHelper.file(restoreDir);
Pattern p = Pattern.compile(".+\\.0");
for (File f : rDir.listFiles(new BackupFilesFilter()))
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -417,7 +417,7 @@
+ ") RestoreIntializer should have mandatory parameter "
+ SysViewWorkspaceInitializer.RESTORE_PATH_PARAMETER);
- this.tempDir = new File(System.getProperty("java.io.tmpdir"));
+ this.tempDir =
PrivilegedFileHelper.file(System.getProperty("java.io.tmpdir"));
}
/**
@@ -463,7 +463,7 @@
WorkspaceDataContainer.DEF_MAXBUFFERSIZE);
this.restorePath = restorePath;
- this.tempDir = new File(System.getProperty("java.io.tmpdir"));
+ this.tempDir =
PrivilegedFileHelper.file(System.getProperty("java.io.tmpdir"));
}
/**
@@ -533,7 +533,7 @@
NamespaceException, RepositoryException, IllegalNameException
{
- InputStream input = new FileInputStream(restorePath);
+ InputStream input = PrivilegedFileHelper.fileInputStream(restorePath);
try
{
XMLStreamReader reader =
XMLInputFactory.newInstance().createXMLStreamReader(input);
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/FileSystemLockPersister.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/FileSystemLockPersister.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/FileSystemLockPersister.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -34,6 +34,7 @@
import org.exoplatform.services.jcr.impl.core.query.SearchManager;
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
import
org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.jcr.observation.ExtendedEvent;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -117,7 +118,7 @@
public void add(LockData lock) throws LockException
{
log.debug("add event fire");
- File lockFile = new File(rootDir, lock.getNodeIdentifier());
+ File lockFile = PrivilegedFileHelper.file(rootDir, lock.getNodeIdentifier());
if (lockFile.exists())
{
@@ -143,7 +144,7 @@
public void remove(LockData lock) throws LockException
{
log.debug("remove event fire");
- File lockFile = new File(rootDir, lock.getNodeIdentifier());
+ File lockFile = PrivilegedFileHelper.file(rootDir, lock.getNodeIdentifier());
if (!lockFile.exists())
{
// throw new LockException("Persistent lock information not exists");
@@ -213,7 +214,7 @@
// remove files
for (int i = 0; i < list.length; i++)
{
- File lockFile = new File(rootDir, list[i]);
+ File lockFile = PrivilegedFileHelper.file(rootDir, list[i]);
if (!lockFile.exists())
{
log.warn("Persistent lock information for node id " + list[i] +
" doesn't exists");
@@ -287,7 +288,7 @@
if (root == null)
throw new RepositoryConfigurationException("Repository service
configuration." + " Source name ("
+ PARAM_ROOT_DIR + ") is expected");
- rootDir = new File(root);
+ rootDir = PrivilegedFileHelper.file(root);
if (rootDir.exists())
{
if (!rootDir.isDirectory())
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ErrorLog.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ErrorLog.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ErrorLog.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -187,7 +187,7 @@
*/
public List<String> readList() throws IOException
{
- InputStream in = new FileInputStream(logFile);
+ InputStream in = PrivilegedFileHelper.fileInputStream(logFile);
try
{
List<String> list = new ArrayList<String>();
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/FileBasedNamespaceMappings.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/FileBasedNamespaceMappings.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/FileBasedNamespaceMappings.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -150,7 +150,7 @@
{
if (storage.exists())
{
- InputStream in = new FileInputStream(storage);
+ InputStream in = PrivilegedFileHelper.fileInputStream(storage);
try
{
Properties props = new Properties();
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -59,6 +59,7 @@
import org.exoplatform.services.jcr.impl.core.query.SearchIndexConfigurationHelper;
import org.exoplatform.services.jcr.impl.core.query.lucene.directory.DirectoryManager;
import org.exoplatform.services.jcr.impl.core.query.lucene.directory.FSDirectoryManager;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;
@@ -473,6 +474,7 @@
* if an error occurs while initializing this handler.
* @throws RepositoryException
*/
+ @Override
public void doInit() throws IOException, RepositoryException
{
QueryHandlerContext context = getContext();
@@ -486,7 +488,7 @@
if (path != null)
{
- indexDirectory = new File(path);
+ indexDirectory = PrivilegedFileHelper.file(path);
if (!indexDirectory.exists())
{
if (!indexDirectory.mkdirs())
@@ -520,7 +522,7 @@
else
{
// read local namespace mappings
- File mapFile = new File(indexDirectory, NS_MAPPING_FILE);
+ File mapFile = PrivilegedFileHelper.file(indexDirectory, NS_MAPPING_FILE);
if (mapFile.exists())
{
// be backward compatible and use ns_mappings.properties from
@@ -589,7 +591,7 @@
new Integer(getIndexFormatVersion().getVersion()));
}
- File file = new File(indexDirectory, ERROR_LOG);
+ File file = PrivilegedFileHelper.file(indexDirectory, ERROR_LOG);
errorLog = new ErrorLog(file, errorLogfileSize);
// reprocess any notfinished notifies;
if (modeHandler.getMode() == IndexerIoMode.READ_WRITE)
@@ -865,6 +867,7 @@
return new FilterMultiColumnQueryHits(searcher.execute(query, sort,
resultFetchHint,
QueryImpl.DEFAULT_SELECTOR_NAME))
{
+ @Override
public void close() throws IOException
{
try
@@ -912,6 +915,7 @@
searcher.setSimilarity(getSimilarity());
return new FilterMultiColumnQueryHits(query.execute(searcher, sort,
resultFetchHint))
{
+ @Override
public void close() throws IOException
{
try
@@ -1317,14 +1321,14 @@
int lastSeparator = synonymProviderConfigPath.lastIndexOf(separator);
if (lastSeparator != -1)
{
- File root = new File(path, synonymProviderConfigPath.substring(0,
lastSeparator));
+ File root = PrivilegedFileHelper.file(path,
synonymProviderConfigPath.substring(0, lastSeparator));
fsr =
- new BufferedInputStream(new FileInputStream(new File(root,
synonymProviderConfigPath
+ new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(PrivilegedFileHelper.file(root,
synonymProviderConfigPath
.substring(lastSeparator + 1))));
}
else
{
- fsr = new BufferedInputStream(new FileInputStream(new
File(synonymProviderConfigPath)));
+ fsr = new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(PrivilegedFileHelper.file(synonymProviderConfigPath)));
}
synonymProviderConfigFs = fsr;
@@ -1386,7 +1390,7 @@
if (indexingConfigPath != null)
{
- // File config = new File(indexingConfigPath);
+ // File config = PrivilegedFileHelper.file(indexingConfigPath);
InputStream is = SearchIndex.class.getResourceAsStream(indexingConfigPath);
if (is == null)
@@ -1798,6 +1802,7 @@
return hi;
}
+ @Override
public boolean equals(Object obj)
{
if (obj instanceof CombinedIndexReader)
@@ -1808,6 +1813,7 @@
return false;
}
+ @Override
public int hashCode()
{
int hash = 0;
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/directory/FSDirectoryManager.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/directory/FSDirectoryManager.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/directory/FSDirectoryManager.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -21,6 +21,7 @@
import org.apache.lucene.store.NativeFSLockFactory;
import org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex;
import org.exoplatform.services.jcr.impl.util.SecurityHelper;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.File;
import java.io.FileFilter;
@@ -48,7 +49,7 @@
{
public Object run() throws Exception
{
- baseDir = new File(handler.getPath());
+ baseDir = PrivilegedFileHelper.file(handler.getPath());
return null;
}
});
@@ -63,7 +64,7 @@
{
public Boolean run() throws Exception
{
- return new File(baseDir, name).exists();
+ return PrivilegedFileHelper.file(baseDir, name).exists();
}
});
@@ -85,7 +86,7 @@
}
else
{
- dir = new File(baseDir, name);
+ dir = PrivilegedFileHelper.file(baseDir, name);
}
return FSDirectory.getDirectory(dir, new NativeFSLockFactory(dir));
}
@@ -134,7 +135,7 @@
{
public Boolean run() throws Exception
{
- File directory = new File(baseDir, name);
+ File directory = PrivilegedFileHelper.file(baseDir, name);
// trivial if it does not exist anymore
if (!directory.exists())
{
@@ -171,8 +172,8 @@
{
public Boolean run() throws Exception
{
- File src = new File(baseDir, from);
- File dest = new File(baseDir, to);
+ File src = PrivilegedFileHelper.file(baseDir, from);
+ File dest = PrivilegedFileHelper.file(baseDir, to);
return src.renameTo(dest);
}
});
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueFactoryImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueFactoryImpl.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueFactoryImpl.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -30,6 +30,7 @@
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import org.exoplatform.services.jcr.impl.util.JCRDateFormat;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.jcr.impl.util.io.WorkspaceFileCleanerHolder;
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
import org.exoplatform.services.log.ExoLogger;
@@ -83,7 +84,7 @@
{
public Object run()
{
- tempDirectory = new File(System.getProperty("java.io.tmpdir"));
+ tempDirectory =
PrivilegedFileHelper.file(System.getProperty("java.io.tmpdir"));
return null;
}
};
@@ -104,7 +105,7 @@
{
public Object run()
{
- tempDirectory = new File(System.getProperty("java.io.tmpdir"));
+ tempDirectory =
PrivilegedFileHelper.file(System.getProperty("java.io.tmpdir"));
return null;
}
};
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -77,7 +77,7 @@
sch = new RandomAccessFile(sf, "rw").getChannel();
- FileChannel sourceCh = new FileInputStream(spoolFile).getChannel();
+ FileChannel sourceCh =
PrivilegedFileHelper.fileInputStream(spoolFile).getChannel();
try
{
sch.transferFrom(sourceCh, 0, sourceCh.size());
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -228,7 +228,7 @@
}
else if (spoolFile != null)
{
- return new FileInputStream(spoolFile); // from spool file if initialized
+ return PrivilegedFileHelper.fileInputStream(spoolFile); // from spool file
if initialized
}
else if (tmpStream != null)
{
@@ -345,7 +345,7 @@
else
{
if (spoolChannel == null)
- spoolChannel = new FileInputStream(spoolFile).getChannel();
+ spoolChannel =
PrivilegedFileHelper.fileInputStream(spoolFile).getChannel();
// validation
if (position >= spoolChannel.size() && position > 0)
@@ -645,7 +645,7 @@
*/
private byte[] fileToByteArray() throws IOException
{
- FileChannel fch = new FileInputStream(spoolFile).getChannel();
+ FileChannel fch = PrivilegedFileHelper.fileInputStream(spoolFile).getChannel();
if (LOG.isDebugEnabled() && fch.size() > maxBufferSize)
{
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -114,7 +114,7 @@
{
if (channel == null)
{
- channel = new FileInputStream(file).getChannel();
+ channel = PrivilegedFileHelper.fileInputStream(file).getChannel();
}
// validation
@@ -198,7 +198,7 @@
private byte[] fileToByteArray() throws IOException
{
// TODO do refactor of work with NIO and java6
- FileChannel fch = new FileInputStream(file).getChannel();
+ FileChannel fch = PrivilegedFileHelper.fileInputStream(file).getChannel();
try
{
@@ -236,7 +236,7 @@
byte[] buf = new byte[size];
in.readFully(buf);
- File f = new File(new String(buf, "UTF-8"));
+ File f = PrivilegedFileHelper.file(new String(buf, "UTF-8"));
// validate if exists
if (f.exists())
{
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/FileObjectReaderImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/FileObjectReaderImpl.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/FileObjectReaderImpl.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -21,6 +21,7 @@
import org.exoplatform.services.jcr.dataflow.serialization.ObjectReader;
import org.exoplatform.services.jcr.dataflow.serialization.SerializationConstants;
import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.EOFException;
import java.io.File;
@@ -58,7 +59,7 @@
*/
public FileObjectReaderImpl(File file) throws FileNotFoundException
{
- this.channel = new FileInputStream(file).getChannel();
+ this.channel = PrivilegedFileHelper.fileInputStream(file).getChannel();
}
/**
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/FilePathHolder.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/FilePathHolder.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/FilePathHolder.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.impl.dataflow.serialization;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.File;
import java.util.ArrayList;
@@ -85,7 +86,7 @@
List<String> ls = new ArrayList<String>(filePathMap.values());
for (String fPath : ls)
- cleaner.addFile(new File(fPath));
+ cleaner.addFile(PrivilegedFileHelper.file(fPath));
}
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedValueDataReader.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedValueDataReader.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedValueDataReader.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -87,7 +87,7 @@
*/
public AbstractPersistedValueData read(ObjectReader in) throws
UnknownClassIdException, IOException
{
- File tempDirectory = new File(SerializationConstants.TEMP_DIR);
+ File tempDirectory = PrivilegedFileHelper.file(SerializationConstants.TEMP_DIR);
tempDirectory.mkdirs();
// read id
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedValueDataWriter.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedValueDataWriter.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedValueDataWriter.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -23,6 +23,7 @@
import org.exoplatform.services.jcr.impl.dataflow.AbstractPersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.persistent.FilePersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.persistent.StreamPersistedValueData;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.jcr.util.IdGenerator;
import java.io.FileInputStream;
@@ -70,14 +71,14 @@
FilePersistedValueData streamed = (FilePersistedValueData)vd;
InputStream in = null;
-
+
if (streamed.getFile() == null && vd instanceof
StreamPersistedValueData)
{
- in = new FileInputStream(((StreamPersistedValueData)vd).getTempFile());
+ in =
PrivilegedFileHelper.fileInputStream(((StreamPersistedValueData)vd).getTempFile());
}
else
{
- in = streamed.getAsStream();
+ in = streamed.getAsStream();
}
// TODO optimize it, use channels
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -34,6 +34,7 @@
import
org.exoplatform.services.jcr.impl.storage.jdbc.statistics.StatisticsJDBCStorageConnection;
import org.exoplatform.services.jcr.impl.storage.jdbc.update.StorageUpdateManager;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerException;
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
@@ -183,6 +184,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Connection getJdbcConnection() throws RepositoryException
{
return connection;
@@ -380,11 +382,11 @@
try
{
String sdParam = wsConfig.getContainer().getParameterValue(SWAPDIR_PROP);
- this.swapDirectory = new File(sdParam);
+ this.swapDirectory = PrivilegedFileHelper.file(sdParam);
}
catch (RepositoryConfigurationException e1)
{
- this.swapDirectory = new File(DEF_SWAPDIR);
+ this.swapDirectory = PrivilegedFileHelper.file(DEF_SWAPDIR);
}
if (!swapDirectory.exists())
swapDirectory.mkdirs();
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableIOSupport.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableIOSupport.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableIOSupport.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.services.jcr.impl.storage.value.fs;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -88,6 +89,6 @@
public File getFile(String hash)
{
// work with digest
- return new File(channel.rootDir, channel.makeFilePath(hash, 0));
+ return PrivilegedFileHelper.file(channel.rootDir, channel.makeFilePath(hash, 0));
}
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/FileIOChannel.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/FileIOChannel.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/FileIOChannel.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -25,6 +25,7 @@
import org.exoplatform.services.jcr.impl.storage.value.fs.operations.ValueFileIOHelper;
import org.exoplatform.services.jcr.impl.storage.value.fs.operations.WriteValue;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.jcr.storage.value.ValueIOChannel;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -95,7 +96,7 @@
this.storageId = storageId;
this.resources = resources;
- this.tempDir = new File(rootDir, FileValueStorage.TEMP_DIR_NAME);
+ this.tempDir = PrivilegedFileHelper.file(rootDir, FileValueStorage.TEMP_DIR_NAME);
}
/**
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/FileValueStorage.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/FileValueStorage.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/FileValueStorage.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -21,6 +21,7 @@
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.impl.storage.value.ValueDataResourceHolder;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.exoplatform.services.jcr.storage.value.ValueStoragePlugin;
import org.exoplatform.services.log.ExoLogger;
@@ -67,6 +68,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void init(Properties props, ValueDataResourceHolder resources) throws
IOException,
RepositoryConfigurationException
{
@@ -77,6 +79,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void checkConsistency(WorkspaceStorageConnection dataConnection)
{
@@ -103,7 +106,7 @@
*/
protected void prepareRootDir(String rootDirPath) throws IOException,
RepositoryConfigurationException
{
- this.rootDir = new File(rootDirPath);
+ this.rootDir = PrivilegedFileHelper.file(rootDirPath);
if (!rootDir.exists())
{
@@ -112,7 +115,7 @@
log.info("Directory created: " + rootDir.getAbsolutePath());
// create internal temp dir
- File tempDir = new File(rootDir, TEMP_DIR_NAME);
+ File tempDir = PrivilegedFileHelper.file(rootDir, TEMP_DIR_NAME);
tempDir.mkdirs();
if (tempDir.exists() && tempDir.isDirectory())
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/SimpleFileIOChannel.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/SimpleFileIOChannel.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/SimpleFileIOChannel.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -20,6 +20,7 @@
import org.exoplatform.services.jcr.impl.storage.value.ValueDataResourceHolder;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.File;
import java.io.FileFilter;
@@ -65,7 +66,7 @@
@Override
protected File getFile(String propertyId, int orderNumber) throws IOException
{
- return new File(rootDir, makeFilePath(propertyId, orderNumber));
+ return PrivilegedFileHelper.file(rootDir, makeFilePath(propertyId, orderNumber));
}
@Override
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFile.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFile.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFile.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.impl.storage.value.fs;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -62,7 +63,7 @@
{
boolean res = deleteFromSuper();
if (res)
- deleteParent(new File(getParent()));
+ deleteParent(PrivilegedFileHelper.file(getParent()));
return res;
}
@@ -83,7 +84,7 @@
{
if (res = fp.delete())
{
- res = deleteParent(new File(fp.getParent()));
+ res = deleteParent(PrivilegedFileHelper.file(fp.getParent()));
}
else
{
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -120,7 +120,7 @@
// write calc digest hash
// we need hash at first to know do we have to store file or just use one
// existing (with same hash)
- File temp = new File(tempDir, IdGenerator.generate() + "-" + propertyId +
orderNumb + TEMP_FILE_EXTENSION);
+ File temp = PrivilegedFileHelper.file(tempDir, IdGenerator.generate() +
"-" + propertyId + orderNumb + TEMP_FILE_EXTENSION);
FileDigestOutputStream out = cas.openFile(temp);
try
{
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileIOHelper.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileIOHelper.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileIOHelper.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -90,7 +90,7 @@
}
else
{
- FileInputStream is = new FileInputStream(file);
+ FileInputStream is = PrivilegedFileHelper.fileInputStream(file);
try
{
int buffSize = (int)fileSize;
@@ -251,7 +251,7 @@
+ tempFile.getAbsolutePath() + ". Destination:
" + file.getAbsolutePath());
}
- copyClose(new FileInputStream(tempFile),
PrivilegedFileHelper.fileOutputStream(file));
+ copyClose(PrivilegedFileHelper.fileInputStream(tempFile),
PrivilegedFileHelper.fileOutputStream(file));
}
}
else
@@ -329,7 +329,7 @@
in = streamed.getStream();
if (in == null)
{
- in = new FileInputStream(streamed.getTempFile());
+ in = PrivilegedFileHelper.fileInputStream(streamed.getTempFile());
}
}
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileOperation.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileOperation.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileOperation.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -130,7 +130,7 @@
public Object run() throws Exception
{
// lock file in temp directory
- lockFile = new File(tempDir, targetFile.getName() + LOCK_FILE_EXTENSION);
+ lockFile = PrivilegedFileHelper.file(tempDir, targetFile.getName() +
LOCK_FILE_EXTENSION);
FileOutputStream lout = PrivilegedFileHelper.fileOutputStream(lockFile,
true);
lout.write(operationInfo.getBytes()); // TODO write info
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/PrivilegedFileHelper.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/PrivilegedFileHelper.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/PrivilegedFileHelper.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -23,6 +23,7 @@
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.net.URI;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
@@ -161,6 +162,37 @@
}
}
+ public static FileInputStream fileInputStream(final String name) throws
FileNotFoundException
+ {
+ PrivilegedExceptionAction<FileInputStream> action = new
PrivilegedExceptionAction<FileInputStream>()
+ {
+ public FileInputStream run() throws Exception
+ {
+ return new FileInputStream(name);
+ }
+ };
+ try
+ {
+ return AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException pae)
+ {
+ Throwable cause = pae.getCause();
+ if (cause instanceof FileNotFoundException)
+ {
+ throw (FileNotFoundException)cause;
+ }
+ else if (cause instanceof RuntimeException)
+ {
+ throw (RuntimeException)cause;
+ }
+ else
+ {
+ throw new RuntimeException(cause);
+ }
+ }
+ }
+
public static File createTempFile(final String prefix, final String suffix, final File
directory)
throws IllegalArgumentException, IOException
{
@@ -331,6 +363,42 @@
return AccessController.doPrivileged(action);
}
+ public static File file(final URI uri)
+ {
+ PrivilegedAction<File> action = new PrivilegedAction<File>()
+ {
+ public File run()
+ {
+ return new File(uri);
+ }
+ };
+ return AccessController.doPrivileged(action);
+ }
+
+ public static File file(final String parent, final String child)
+ {
+ PrivilegedAction<File> action = new PrivilegedAction<File>()
+ {
+ public File run()
+ {
+ return new File(parent, child);
+ }
+ };
+ return AccessController.doPrivileged(action);
+ }
+
+ public static File file(final File parent, final String child)
+ {
+ PrivilegedAction<File> action = new PrivilegedAction<File>()
+ {
+ public File run()
+ {
+ return new File(parent, child);
+ }
+ };
+ return AccessController.doPrivileged(action);
+ }
+
public static String[] list(final File file)
{
PrivilegedAction<String[]> action = new PrivilegedAction<String[]>()
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/BufferedDecoder.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/BufferedDecoder.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/BufferedDecoder.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -101,7 +101,7 @@
{
out.close();
- return new BufferedInputStream(new FileInputStream(fileBuffer));
+ return new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(fileBuffer));
}
else
{
@@ -141,7 +141,7 @@
try
{
out.close();
- BufferedInputStream is = new BufferedInputStream(new
FileInputStream(fileBuffer));
+ BufferedInputStream is = new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(fileBuffer));
StringBuffer fileData = new StringBuffer(DEFAULT_READ_BUFFER_SIZE);
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/statistics/JCRStatisticsManager.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/statistics/JCRStatisticsManager.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/statistics/JCRStatisticsManager.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -25,6 +25,7 @@
import org.exoplatform.management.jmx.annotations.NameTemplate;
import org.exoplatform.management.jmx.annotations.Property;
import org.exoplatform.management.rest.annotations.RESTEndpoint;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -147,8 +148,8 @@
try
{
file =
- new File(System.getProperty("user.dir"), "Statistics" +
category + "-" + System.currentTimeMillis()
- + ".csv");
+ PrivilegedFileHelper.file(System.getProperty("user.dir"),
"Statistics" + category + "-"
+ + System.currentTimeMillis() + ".csv");
file.createNewFile();
pw = new PrintWriter(file);
}
@@ -217,6 +218,7 @@
}
Runtime.getRuntime().addShutdownHook(new
Thread("JCRStatisticsManager-Hook")
{
+ @Override
public void run()
{
printData();
@@ -224,6 +226,7 @@
});
Thread t = new Thread("JCRStatisticsManager-Writer")
{
+ @Override
public void run()
{
while (true)
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/TextExtractorTest.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/TextExtractorTest.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/TextExtractorTest.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -16,6 +16,8 @@
*/
package org.exoplatform.services.jcr.api.core.query;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
+
import javax.jcr.Node;
import java.io.File;
import java.io.InputStream;
@@ -28,91 +30,111 @@
* <code>TextExtractorTest</code> implements a file / folder import from the
* local file system.
*/
-public class TextExtractorTest extends AbstractQueryTest {
+public class TextExtractorTest extends AbstractQueryTest
+{
- private static final String TEST_FOLDER = "test-data";
+ private static final String TEST_FOLDER = "test-data";
- private int fileCount = 0;
+ private int fileCount = 0;
- public void testImport() throws Exception {
- File sourceFolder = new File(TEST_FOLDER);
- // only run if there is test data
- if (!sourceFolder.exists()) {
- return;
- }
- long time = System.currentTimeMillis();
- addContents(sourceFolder,
- testRootNode.addNode(sourceFolder.getName(), "nt:folder"));
- superuser.save();
- time = System.currentTimeMillis() - time;
- log.println("Imported " + fileCount + " files in " + time +
" ms.");
- }
+ public void testImport() throws Exception
+ {
+ File sourceFolder = PrivilegedFileHelper.file(TEST_FOLDER);
+ // only run if there is test data
+ if (!sourceFolder.exists())
+ {
+ return;
+ }
+ long time = System.currentTimeMillis();
+ addContents(sourceFolder, testRootNode.addNode(sourceFolder.getName(),
"nt:folder"));
+ superuser.save();
+ time = System.currentTimeMillis() - time;
+ log.println("Imported " + fileCount + " files in " + time +
" ms.");
+ }
- /**
- * Recursively adds files and folders to the workspace.
- */
- private void addContents(File folder, Node n) throws Exception {
- String[] names = folder.list();
- for (int i = 0; i < names.length; i++) {
- File f = new File(folder, names[i]);
- if (f.canRead()) {
- if (f.isDirectory()) {
- log.println("Added folder: " + f.getAbsolutePath());
- addContents(f, n.addNode(names[i], "nt:folder"));
- } else {
- addFile(n, f);
- log.println("Added file: " + f.getAbsolutePath());
- // save after 100 files
- if (++fileCount % 100 == 0) {
- n.getSession().save();
- }
- }
+ /**
+ * Recursively adds files and folders to the workspace.
+ */
+ private void addContents(File folder, Node n) throws Exception
+ {
+ String[] names = folder.list();
+ for (int i = 0; i < names.length; i++)
+ {
+ File f = PrivilegedFileHelper.file(folder, names[i]);
+ if (f.canRead())
+ {
+ if (f.isDirectory())
+ {
+ log.println("Added folder: " + f.getAbsolutePath());
+ addContents(f, n.addNode(names[i], "nt:folder"));
}
- }
- }
-
- /**
- * Repeatedly update a file in the workspace and force text extraction
- * on it.
- */
- public void testRepeatedUpdate() throws Exception {
- File testFile = new File("test.pdf");
- if (!testFile.exists()) {
- return;
- }
- Node resource = addFile(testRootNode,
testFile).getNode("jcr:content");
- superuser.save();
- for (int i = 0; i < 10; i++) {
- // kick start text extractor
- executeXPathQuery(testPath, new Node[]{testRootNode});
- InputStream in = new BufferedInputStream(new FileInputStream(testFile));
- try {
- resource.setProperty("jcr:data", in);
- } finally {
- in.close();
+ else
+ {
+ addFile(n, f);
+ log.println("Added file: " + f.getAbsolutePath());
+ // save after 100 files
+ if (++fileCount % 100 == 0)
+ {
+ n.getSession().save();
+ }
}
- log.println("updating resource...");
- superuser.save();
- }
- }
+ }
+ }
+ }
- private static Node addFile(Node folder, File f) throws Exception {
- String mimeType = URLConnection.guessContentTypeFromName(f.getName());
- if (mimeType == null) {
- mimeType = "application/octet-stream";
- }
- Node file = folder.addNode(f.getName(), "nt:file");
- Node resource = file.addNode("jcr:content", "nt:resource");
- InputStream in = new BufferedInputStream(new FileInputStream(f));
- try {
+ /**
+ * Repeatedly update a file in the workspace and force text extraction
+ * on it.
+ */
+ public void testRepeatedUpdate() throws Exception
+ {
+ File testFile = PrivilegedFileHelper.file("test.pdf");
+ if (!testFile.exists())
+ {
+ return;
+ }
+ Node resource = addFile(testRootNode, testFile).getNode("jcr:content");
+ superuser.save();
+ for (int i = 0; i < 10; i++)
+ {
+ // kick start text extractor
+ executeXPathQuery(testPath, new Node[]{testRootNode});
+ InputStream in = new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(testFile));
+ try
+ {
resource.setProperty("jcr:data", in);
- resource.setProperty("jcr:mimeType", mimeType);
- Calendar lastModified = Calendar.getInstance();
- lastModified.setTimeInMillis(f.lastModified());
- resource.setProperty("jcr:lastModified", lastModified);
- } finally {
+ }
+ finally
+ {
in.close();
- }
- return file;
- }
+ }
+ log.println("updating resource...");
+ superuser.save();
+ }
+ }
+
+ private static Node addFile(Node folder, File f) throws Exception
+ {
+ String mimeType = URLConnection.guessContentTypeFromName(f.getName());
+ if (mimeType == null)
+ {
+ mimeType = "application/octet-stream";
+ }
+ Node file = folder.addNode(f.getName(), "nt:file");
+ Node resource = file.addNode("jcr:content", "nt:resource");
+ InputStream in = new BufferedInputStream(PrivilegedFileHelper.fileInputStream(f));
+ try
+ {
+ resource.setProperty("jcr:data", in);
+ resource.setProperty("jcr:mimeType", mimeType);
+ Calendar lastModified = Calendar.getInstance();
+ lastModified.setTimeInMillis(f.lastModified());
+ resource.setProperty("jcr:lastModified", lastModified);
+ }
+ finally
+ {
+ in.close();
+ }
+ return file;
+ }
}
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/IndexingQueueTest.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/IndexingQueueTest.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/IndexingQueueTest.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -16,13 +16,12 @@
*/
package org.exoplatform.services.jcr.api.core.query.lucene;
-
-
import org.exoplatform.services.jcr.api.core.query.AbstractIndexingTest;
import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
import org.exoplatform.services.jcr.impl.core.query.lucene.IndexingQueue;
import org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
@@ -42,204 +41,206 @@
* nodes in a background thread when text extraction takes more than 10 ms. See
* the workspace.xml file for the indexing-test workspace.
*/
-public class IndexingQueueTest extends AbstractIndexingTest {
+public class IndexingQueueTest extends AbstractIndexingTest
+{
- private static final File TEMP_DIR = new
File(System.getProperty("java.io.tmpdir"));
+ private static final File TEMP_DIR =
PrivilegedFileHelper.file(System.getProperty("java.io.tmpdir"));
- private static final String CONTENT_TYPE =
"application/indexing-queue-test";
+ private static final String CONTENT_TYPE =
"application/indexing-queue-test";
- private static final String ENCODING = "UTF-8";
- public void testname() throws Exception
+ private static final String ENCODING = "UTF-8";
+
+ public void testname() throws Exception
{
-
+
}
-//
-// public void testQueue() throws Exception {
-// Extractor.sleepTime = 200;
-// SearchIndex index = (SearchIndex) getQueryHandler();
-// IndexingQueue queue = index.getIndex().getIndexingQueue();
-//
-// assertEquals(0, queue.getNumPendingDocuments());
-//
-// String text = "the quick brown fox jumps over the lazy dog.";
-// InputStream in = new ByteArrayInputStream(text.getBytes(ENCODING));
-// Node resource = testRootNode.addNode(nodeName1, "nt:resource");
-// resource.setProperty("jcr:data", in);
-// resource.setProperty("jcr:lastModified", Calendar.getInstance());
-// resource.setProperty("jcr:mimeType", CONTENT_TYPE);
-// resource.setProperty("jcr:encoding", ENCODING);
-// session.save();
-//
-// assertEquals(1, queue.getNumPendingDocuments());
-//
-// Query q = qm.createQuery(testPath + "/*[jcr:contains(.,
'fox')]", Query.XPATH);
-// NodeIterator nodes = q.execute().getNodes();
-// assertFalse(nodes.hasNext());
-//
-// synchronized (index.getIndex()) {
-// while (queue.getNumPendingDocuments() > 0) {
-// index.getIndex().wait(50);
-// }
-// }
-//
-// q = qm.createQuery(testPath + "/*[jcr:contains(., 'fox')]",
Query.XPATH);
-// nodes = q.execute().getNodes();
-// assertTrue(nodes.hasNext());
-// }
-//
-// public void testInitialIndex() throws Exception {
-// Extractor.sleepTime = 200;
-// SearchIndex index = (SearchIndex) getQueryHandler();
-// File indexDir = new File(index.getPath());
-//
-// // fill workspace
-// Node testFolder = testRootNode.addNode("folder",
"nt:folder");
-// String text = "the quick brown fox jumps over the lazy dog.";
-// int num = createFiles(testFolder, text.getBytes(ENCODING), 10, 2, 0);
-// session.save();
-//
-// // shutdown workspace
-// RepositoryImpl repo = (RepositoryImpl) session.getRepository();
-// session.logout();
-// session = null;
-// superuser.logout();
-// superuser = null;
-// TestHelper.shutdownWorkspace(WORKSPACE_NAME, repo);
-//
-// // delete index
-// try {
-// FileUtil.delete(indexDir);
-// } catch (IOException e) {
-// fail("Unable to delete index directory");
-// }
-//
-// int initialNumExtractorFiles = getNumExtractorFiles();
-//
-// Extractor.sleepTime = 20;
-// Thread t = new Thread(new Runnable() {
-// public void run() {
-// try {
-// session = helper.getSuperuserSession(WORKSPACE_NAME);
-// } catch (RepositoryException e) {
-// throw new RuntimeException(e);
-// }
-// }
-// });
-// t.start();
-//
-// while (t.isAlive()) {
-// // there must not be more than 20 extractor files, because:
-// // - initial index creation checks indexing queue every 10 nodes
-// // - there is an aggregate definition on the workspace that causes
-// // 2 extractor jobs per nt:resource
-// // => 2 * 10 = 20
-// int numFiles = getNumExtractorFiles() - initialNumExtractorFiles;
-// assertTrue(numFiles <= 20);
-// Thread.sleep(50);
-// }
-//
-// qm = session.getWorkspace().getQueryManager();
-// index = (SearchIndex) getQueryHandler();
-// IndexingQueue queue = index.getIndex().getIndexingQueue();
-//
-// // flush index to make sure any documents in the buffer are written
-// // to the index. this is to make sure all nodes are pushed either to
-// // the index or to the indexing queue
-// index.getIndex().flush();
-//
-// synchronized (index.getIndex()) {
-// while (queue.getNumPendingDocuments() > 0) {
-// index.getIndex().wait(50);
-// }
-// }
-//
-// String stmt = testPath + "//element(*, nt:resource)[jcr:contains(.,
'fox')]";
-// Query q = qm.createQuery(stmt, Query.XPATH);
-// assertEquals(num, q.execute().getNodes().getSize());
-// }
-//
-// /*
-// * Test case for JCR-2082
-// */
-// public void testReaderUpToDate() throws Exception {
-// Extractor.sleepTime = 10;
-// SearchIndex index = (SearchIndex) getQueryHandler();
-// File indexDir = new File(index.getPath());
-//
-// // shutdown workspace
-// RepositoryImpl repo = (RepositoryImpl) session.getRepository();
-// session.logout();
-// session = null;
-// superuser.logout();
-// superuser = null;
-// TestHelper.shutdownWorkspace(WORKSPACE_NAME, repo);
-//
-// // delete index
-// try {
-// FileUtil.delete(indexDir);
-// } catch (IOException e) {
-// fail("Unable to delete index directory");
-// }
-//
-// // start workspace again by getting a session
-// session = helper.getSuperuserSession(WORKSPACE_NAME);
-//
-// qm = session.getWorkspace().getQueryManager();
-//
-// Query q = qm.createQuery(testPath, Query.XPATH);
-// assertEquals(1, getSize(q.execute().getNodes()));
-// }
-//
-// private int createFiles(Node folder, byte[] data,
-// int filesPerLevel, int levels, int count)
-// throws RepositoryException {
-// levels--;
-// for (int i = 0; i < filesPerLevel; i++) {
-// // create files
-// Node file = folder.addNode("file" + i, "nt:file");
-// InputStream in = new ByteArrayInputStream(data);
-// Node resource = file.addNode("jcr:content",
"nt:resource");
-// resource.setProperty("jcr:data", in);
-// resource.setProperty("jcr:lastModified",
Calendar.getInstance());
-// resource.setProperty("jcr:mimeType", CONTENT_TYPE);
-// resource.setProperty("jcr:encoding", ENCODING);
-// count++;
-// }
-// if (levels > 0) {
-// for (int i = 0; i < filesPerLevel; i++) {
-// // create files
-// Node subFolder = folder.addNode("folder" + i,
"nt:folder");
-// count = createFiles(subFolder, data,
-// filesPerLevel, levels, count);
-// }
-// }
-// return count;
-// }
-//
-// private int getNumExtractorFiles() throws IOException {
-// return TEMP_DIR.listFiles(new FilenameFilter() {
-// public boolean accept(File dir, String name) {
-// return name.startsWith("extractor");
-// }
-// }).length;
-// }
+ //
+ // public void testQueue() throws Exception {
+ // Extractor.sleepTime = 200;
+ // SearchIndex index = (SearchIndex) getQueryHandler();
+ // IndexingQueue queue = index.getIndex().getIndexingQueue();
+ //
+ // assertEquals(0, queue.getNumPendingDocuments());
+ //
+ // String text = "the quick brown fox jumps over the lazy dog.";
+ // InputStream in = new ByteArrayInputStream(text.getBytes(ENCODING));
+ // Node resource = testRootNode.addNode(nodeName1, "nt:resource");
+ // resource.setProperty("jcr:data", in);
+ // resource.setProperty("jcr:lastModified", Calendar.getInstance());
+ // resource.setProperty("jcr:mimeType", CONTENT_TYPE);
+ // resource.setProperty("jcr:encoding", ENCODING);
+ // session.save();
+ //
+ // assertEquals(1, queue.getNumPendingDocuments());
+ //
+ // Query q = qm.createQuery(testPath + "/*[jcr:contains(.,
'fox')]", Query.XPATH);
+ // NodeIterator nodes = q.execute().getNodes();
+ // assertFalse(nodes.hasNext());
+ //
+ // synchronized (index.getIndex()) {
+ // while (queue.getNumPendingDocuments() > 0) {
+ // index.getIndex().wait(50);
+ // }
+ // }
+ //
+ // q = qm.createQuery(testPath + "/*[jcr:contains(.,
'fox')]", Query.XPATH);
+ // nodes = q.execute().getNodes();
+ // assertTrue(nodes.hasNext());
+ // }
+ //
+ // public void testInitialIndex() throws Exception {
+ // Extractor.sleepTime = 200;
+ // SearchIndex index = (SearchIndex) getQueryHandler();
+ // File indexDir = PrivilegedFileHelper.file(index.getPath());
+ //
+ // // fill workspace
+ // Node testFolder = testRootNode.addNode("folder",
"nt:folder");
+ // String text = "the quick brown fox jumps over the lazy dog.";
+ // int num = createFiles(testFolder, text.getBytes(ENCODING), 10, 2, 0);
+ // session.save();
+ //
+ // // shutdown workspace
+ // RepositoryImpl repo = (RepositoryImpl) session.getRepository();
+ // session.logout();
+ // session = null;
+ // superuser.logout();
+ // superuser = null;
+ // TestHelper.shutdownWorkspace(WORKSPACE_NAME, repo);
+ //
+ // // delete index
+ // try {
+ // FileUtil.delete(indexDir);
+ // } catch (IOException e) {
+ // fail("Unable to delete index directory");
+ // }
+ //
+ // int initialNumExtractorFiles = getNumExtractorFiles();
+ //
+ // Extractor.sleepTime = 20;
+ // Thread t = new Thread(new Runnable() {
+ // public void run() {
+ // try {
+ // session = helper.getSuperuserSession(WORKSPACE_NAME);
+ // } catch (RepositoryException e) {
+ // throw new RuntimeException(e);
+ // }
+ // }
+ // });
+ // t.start();
+ //
+ // while (t.isAlive()) {
+ // // there must not be more than 20 extractor files, because:
+ // // - initial index creation checks indexing queue every 10 nodes
+ // // - there is an aggregate definition on the workspace that causes
+ // // 2 extractor jobs per nt:resource
+ // // => 2 * 10 = 20
+ // int numFiles = getNumExtractorFiles() - initialNumExtractorFiles;
+ // assertTrue(numFiles <= 20);
+ // Thread.sleep(50);
+ // }
+ //
+ // qm = session.getWorkspace().getQueryManager();
+ // index = (SearchIndex) getQueryHandler();
+ // IndexingQueue queue = index.getIndex().getIndexingQueue();
+ //
+ // // flush index to make sure any documents in the buffer are written
+ // // to the index. this is to make sure all nodes are pushed either to
+ // // the index or to the indexing queue
+ // index.getIndex().flush();
+ //
+ // synchronized (index.getIndex()) {
+ // while (queue.getNumPendingDocuments() > 0) {
+ // index.getIndex().wait(50);
+ // }
+ // }
+ //
+ // String stmt = testPath + "//element(*, nt:resource)[jcr:contains(.,
'fox')]";
+ // Query q = qm.createQuery(stmt, Query.XPATH);
+ // assertEquals(num, q.execute().getNodes().getSize());
+ // }
+ //
+ // /*
+ // * Test case for JCR-2082
+ // */
+ // public void testReaderUpToDate() throws Exception {
+ // Extractor.sleepTime = 10;
+ // SearchIndex index = (SearchIndex) getQueryHandler();
+ // File indexDir = PrivilegedFileHelper.file(index.getPath());
+ //
+ // // shutdown workspace
+ // RepositoryImpl repo = (RepositoryImpl) session.getRepository();
+ // session.logout();
+ // session = null;
+ // superuser.logout();
+ // superuser = null;
+ // TestHelper.shutdownWorkspace(WORKSPACE_NAME, repo);
+ //
+ // // delete index
+ // try {
+ // FileUtil.delete(indexDir);
+ // } catch (IOException e) {
+ // fail("Unable to delete index directory");
+ // }
+ //
+ // // start workspace again by getting a session
+ // session = helper.getSuperuserSession(WORKSPACE_NAME);
+ //
+ // qm = session.getWorkspace().getQueryManager();
+ //
+ // Query q = qm.createQuery(testPath, Query.XPATH);
+ // assertEquals(1, getSize(q.execute().getNodes()));
+ // }
+ //
+ // private int createFiles(Node folder, byte[] data,
+ // int filesPerLevel, int levels, int count)
+ // throws RepositoryException {
+ // levels--;
+ // for (int i = 0; i < filesPerLevel; i++) {
+ // // create files
+ // Node file = folder.addNode("file" + i, "nt:file");
+ // InputStream in = new ByteArrayInputStream(data);
+ // Node resource = file.addNode("jcr:content",
"nt:resource");
+ // resource.setProperty("jcr:data", in);
+ // resource.setProperty("jcr:lastModified",
Calendar.getInstance());
+ // resource.setProperty("jcr:mimeType", CONTENT_TYPE);
+ // resource.setProperty("jcr:encoding", ENCODING);
+ // count++;
+ // }
+ // if (levels > 0) {
+ // for (int i = 0; i < filesPerLevel; i++) {
+ // // create files
+ // Node subFolder = folder.addNode("folder" + i,
"nt:folder");
+ // count = createFiles(subFolder, data,
+ // filesPerLevel, levels, count);
+ // }
+ // }
+ // return count;
+ // }
+ //
+ // private int getNumExtractorFiles() throws IOException {
+ // return TEMP_DIR.listFiles(new FilenameFilter() {
+ // public boolean accept(File dir, String name) {
+ // return name.startsWith("extractor");
+ // }
+ // }).length;
+ // }
-// public static final class Extractor implements TextExtractor {
-//
-// protected static volatile int sleepTime = 200;
-//
-// public String[] getContentTypes() {
-// return new String[]{CONTENT_TYPE};
-// }
-//
-// public Reader extractText(InputStream stream, String type, String encoding)
-// throws IOException {
-// try {
-// Thread.sleep(sleepTime);
-// } catch (InterruptedException e) {
-// throw new IOException();
-// }
-// return new InputStreamReader(stream, encoding);
-// }
- // }
+ // public static final class Extractor implements TextExtractor {
+ //
+ // protected static volatile int sleepTime = 200;
+ //
+ // public String[] getContentTypes() {
+ // return new String[]{CONTENT_TYPE};
+ // }
+ //
+ // public Reader extractText(InputStream stream, String type, String encoding)
+ // throws IOException {
+ // try {
+ // Thread.sleep(sleepTime);
+ // } catch (InterruptedException e) {
+ // throw new IOException();
+ // }
+ // return new InputStreamReader(stream, encoding);
+ // }
+ // }
}
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/directory/DirectoryManagerTest.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/directory/DirectoryManagerTest.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/directory/DirectoryManagerTest.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -23,6 +23,7 @@
import org.exoplatform.services.jcr.impl.core.query.lucene.directory.DirectoryManager;
import org.exoplatform.services.jcr.impl.core.query.lucene.directory.FSDirectoryManager;
import
org.exoplatform.services.jcr.impl.core.query.lucene.directory.RAMDirectoryManager;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.File;
import java.util.Arrays;
@@ -33,88 +34,104 @@
* <code>DirectoryManagerTest</code> performs tests on directory manager
* implementations.
*/
-public class DirectoryManagerTest extends TestCase {
+public class DirectoryManagerTest extends TestCase
+{
- private static final Collection IMPLEMENTATIONS = Arrays
- .asList(new Class[] { FSDirectoryManager.class,
- RAMDirectoryManager.class });
+ private static final Collection IMPLEMENTATIONS =
+ Arrays.asList(new Class[]{FSDirectoryManager.class, RAMDirectoryManager.class});
- private static final SearchIndex INDEX = new SearchIndex();
+ private static final SearchIndex INDEX = new SearchIndex();
- private static final String TEST = "test";
+ private static final String TEST = "test";
- private static final String RENAMED = "renamed";
+ private static final String RENAMED = "renamed";
- static {
- INDEX.setPath(new File(new File("target"),
"directory-factory-test")
- .getAbsolutePath());
- }
+ static
+ {
+
INDEX.setPath(PrivilegedFileHelper.file(PrivilegedFileHelper.file("target"),
"directory-factory-test")
+ .getAbsolutePath());
+ }
- protected void tearDown() throws Exception {
- new File(INDEX.getPath(), TEST).delete();
- new File(INDEX.getPath(), RENAMED).delete();
- }
+ @Override
+ protected void tearDown() throws Exception
+ {
+ PrivilegedFileHelper.file(INDEX.getPath(), TEST).delete();
+ PrivilegedFileHelper.file(INDEX.getPath(), RENAMED).delete();
+ }
- public void testHasDirectory() throws Exception {
- execute(new Callable() {
- public void call(DirectoryManager directoryManager)
- throws Exception {
- Directory dir = directoryManager.getDirectory(TEST);
- assertTrue(directoryManager.hasDirectory(TEST));
- dir.close();
- }
- });
- }
+ public void testHasDirectory() throws Exception
+ {
+ execute(new Callable()
+ {
+ public void call(DirectoryManager directoryManager) throws Exception
+ {
+ Directory dir = directoryManager.getDirectory(TEST);
+ assertTrue(directoryManager.hasDirectory(TEST));
+ dir.close();
+ }
+ });
+ }
- public void testDelete() throws Exception {
- execute(new Callable() {
- public void call(DirectoryManager directoryManager)
- throws Exception {
- directoryManager.getDirectory(TEST).close();
- directoryManager.delete(TEST);
- assertFalse(directoryManager.hasDirectory(TEST));
- }
- });
- }
+ public void testDelete() throws Exception
+ {
+ execute(new Callable()
+ {
+ public void call(DirectoryManager directoryManager) throws Exception
+ {
+ directoryManager.getDirectory(TEST).close();
+ directoryManager.delete(TEST);
+ assertFalse(directoryManager.hasDirectory(TEST));
+ }
+ });
+ }
- public void testGetDirectoryNames() throws Exception {
- execute(new Callable() {
- public void call(DirectoryManager directoryManager)
- throws Exception {
- directoryManager.getDirectory(TEST).close();
- assertTrue(Arrays.asList(directoryManager.getDirectoryNames())
- .contains(TEST));
- }
- });
- }
+ public void testGetDirectoryNames() throws Exception
+ {
+ execute(new Callable()
+ {
+ public void call(DirectoryManager directoryManager) throws Exception
+ {
+ directoryManager.getDirectory(TEST).close();
+
assertTrue(Arrays.asList(directoryManager.getDirectoryNames()).contains(TEST));
+ }
+ });
+ }
- public void testRename() throws Exception {
- execute(new Callable() {
- public void call(DirectoryManager directoryManager)
- throws Exception {
- directoryManager.getDirectory(TEST).close();
- directoryManager.rename(TEST, RENAMED);
- assertTrue(directoryManager.hasDirectory(RENAMED));
- assertFalse(directoryManager.hasDirectory(TEST));
- }
- });
- }
+ public void testRename() throws Exception
+ {
+ execute(new Callable()
+ {
+ public void call(DirectoryManager directoryManager) throws Exception
+ {
+ directoryManager.getDirectory(TEST).close();
+ directoryManager.rename(TEST, RENAMED);
+ assertTrue(directoryManager.hasDirectory(RENAMED));
+ assertFalse(directoryManager.hasDirectory(TEST));
+ }
+ });
+ }
- private void execute(Callable callable) throws Exception {
- for (Iterator it = IMPLEMENTATIONS.iterator(); it.hasNext();) {
- Class clazz = (Class) it.next();
- DirectoryManager dirMgr = (DirectoryManager) clazz.newInstance();
- dirMgr.init(INDEX);
- try {
- callable.call(dirMgr);
- } finally {
- dirMgr.dispose();
- }
- }
- }
+ private void execute(Callable callable) throws Exception
+ {
+ for (Iterator it = IMPLEMENTATIONS.iterator(); it.hasNext();)
+ {
+ Class clazz = (Class)it.next();
+ DirectoryManager dirMgr = (DirectoryManager)clazz.newInstance();
+ dirMgr.init(INDEX);
+ try
+ {
+ callable.call(dirMgr);
+ }
+ finally
+ {
+ dirMgr.dispose();
+ }
+ }
+ }
- private interface Callable {
+ private interface Callable
+ {
- public void call(DirectoryManager directoryManager) throws Exception;
- }
+ public void call(DirectoryManager directoryManager) throws Exception;
+ }
}
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportDocView.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportDocView.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportDocView.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -140,7 +140,7 @@
File file = createBLOBTempFile(2500);// 2.5M
if (log.isDebugEnabled())
log.debug("=== File has created, size " + file.length());
- contentTestPdfNode.setProperty("jcr:data", new
FileInputStream(file));
+ contentTestPdfNode.setProperty("jcr:data",
PrivilegedFileHelper.fileInputStream(file));
contentTestPdfNode.setProperty("jcr:mimeType",
"application/octet-stream");
}
catch (IOException e)
@@ -188,7 +188,7 @@
session.exportDocumentView(testNode.getPath(), outStream, false, false);
outStream.close();
- Document doc = builder.parse(new FileInputStream(destFile));
+ Document doc = builder.parse(PrivilegedFileHelper.fileInputStream(destFile));
// assertEquals(Constants.DEFAULT_ENCODING, doc.getXmlEncoding());
@@ -273,7 +273,7 @@
outStream.close();
}
- Document doc = builder.parse(new FileInputStream(destFile));
+ Document doc = builder.parse(PrivilegedFileHelper.fileInputStream(destFile));
// assertEquals(Constants.DEFAULT_ENCODING, doc.getXmlEncoding());
@@ -340,7 +340,7 @@
session.exportDocumentView(firstNode.getPath(), outStream, false, false);
outStream.close();
- Document doc = builder.parse(new FileInputStream(destFile));
+ Document doc = builder.parse(PrivilegedFileHelper.fileInputStream(destFile));
// assertEquals(Constants.DEFAULT_ENCODING, doc.getXmlEncoding());
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportImport.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportImport.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportImport.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -73,7 +73,7 @@
testNode.remove();
session.save();
- session.importXML(root.getPath(), new FileInputStream(destFile),
ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
+ session.importXML(root.getPath(), PrivilegedFileHelper.fileInputStream(destFile),
ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
session.save();
@@ -126,7 +126,7 @@
folder.remove();
session.save();
- session.importXML(root.getPath(), new FileInputStream(destFile),
ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
+ session.importXML(root.getPath(), PrivilegedFileHelper.fileInputStream(destFile),
ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
session.save();
@@ -150,7 +150,7 @@
testNode.remove();
session.save();
- session.importXML(root.getPath(), new FileInputStream(destFile),
ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
+ session.importXML(root.getPath(), PrivilegedFileHelper.fileInputStream(destFile),
ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
session.save();
@@ -396,7 +396,7 @@
session.save();
}
- session.importXML(destParentNode != null ? destParentNode.getPath() :
root.getPath(), new FileInputStream(
+ session.importXML(destParentNode != null ? destParentNode.getPath() :
root.getPath(), PrivilegedFileHelper.fileInputStream(
destFile), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
session.save();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportSysView.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportSysView.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportSysView.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -135,7 +135,7 @@
{
File file = createBLOBTempFile(2500);// 2.5M
log.info("=== File has created, size " + file.length());
- contentTestPdfNode.setProperty("jcr:data", new
FileInputStream(file));
+ contentTestPdfNode.setProperty("jcr:data",
PrivilegedFileHelper.fileInputStream(file));
contentTestPdfNode.setProperty("jcr:mimeType",
"application/octet-stream");
}
catch (IOException e)
@@ -174,7 +174,7 @@
session.exportSystemView(testNode.getPath(), outStream, false, false);
outStream.close();
- Document doc = builder.parse(new FileInputStream(destFile));
+ Document doc = builder.parse(PrivilegedFileHelper.fileInputStream(destFile));
NodeList nodes = doc.getElementsByTagName("sv:node");
assertEquals(1, nodes.getLength());
assertEquals(3, nodes.item(0).getChildNodes().getLength());
@@ -224,7 +224,7 @@
session.exportSystemView(firstNode.getPath(), outStream, false, false);
outStream.close();
- Document doc = builder.parse(new FileInputStream(destFile));
+ Document doc = builder.parse(PrivilegedFileHelper.fileInputStream(destFile));
// assertEquals(Constants.DEFAULT_ENCODING, doc.getXmlEncoding());
@@ -265,7 +265,7 @@
outputStream2.close();
log.info("Export with handler done " + (System.currentTimeMillis() -
startTime) / 1000 + " sec");
- Document doc = builder.parse(new FileInputStream(destFile));
+ Document doc = builder.parse(PrivilegedFileHelper.fileInputStream(destFile));
XPathExpression expr = xpath.compile("//sv:property");
Object result = expr.evaluate(doc, XPathConstants.NODESET);
@@ -319,7 +319,7 @@
session.exportSystemView(testNode.getPath(), outStream, false, false);
outStream.close();
- Document doc = builder.parse(new FileInputStream(destFile));
+ Document doc = builder.parse(PrivilegedFileHelper.fileInputStream(destFile));
XPathExpression expr = xpath.compile("//sv:property");
@@ -373,7 +373,7 @@
session.exportSystemView(testNode.getPath(), outStream, true, false);
outStream.close();
- Document doc = builder.parse(new FileInputStream(destFile));
+ Document doc = builder.parse(PrivilegedFileHelper.fileInputStream(destFile));
XPathExpression expr = xpath.compile("//sv:property");
Object result = expr.evaluate(doc, XPathConstants.NODESET);
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestDocumentViewImport.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestDocumentViewImport.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestDocumentViewImport.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -21,6 +21,7 @@
import org.exoplatform.services.ext.action.InvocationContext;
import org.exoplatform.services.jcr.core.ExtendedSession;
import org.exoplatform.services.jcr.impl.util.StringConverter;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.jcr.impl.xml.importing.ContentImporter;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -339,7 +340,7 @@
{
File file = createBLOBTempFile(25);// 2.5M
log.info("=== File has created, size " + file.length());
- contentTestPdfNode.setProperty("jcr:data", new
FileInputStream(file));
+ contentTestPdfNode.setProperty("jcr:data",
PrivilegedFileHelper.fileInputStream(file));
contentTestPdfNode.setProperty("jcr:mimeType",
"application/octet-stream");
}
catch (IOException e)
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-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestImport.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -27,6 +27,7 @@
import org.exoplatform.services.jcr.core.ExtendedNode;
import org.exoplatform.services.jcr.impl.core.NodeImpl;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.jcr.util.VersionHistoryImporter;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -117,7 +118,7 @@
NodeImpl importRoot = (NodeImpl)root.addNode("ImportRoot");
deserialize(importRoot, XmlSaveType.SESSION, true,
ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING,
- new BufferedInputStream(new FileInputStream(tmp)));
+ new BufferedInputStream(PrivilegedFileHelper.fileInputStream(tmp)));
session.save();
Node n1 = importRoot.getNode("TestRoot");
assertTrue("Wrong ACL",
accessManager.hasPermission(((NodeImpl)n1).getACL(), PermissionType.SET_PROPERTY,
@@ -162,7 +163,7 @@
NodeImpl importRoot = (NodeImpl)root.addNode("ImportRoot");
deserialize(importRoot, XmlSaveType.SESSION, true,
ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING,
- new BufferedInputStream(new FileInputStream(tmp)));
+ new BufferedInputStream(PrivilegedFileHelper.fileInputStream(tmp)));
session.save();
Node n1 = importRoot.getNode("TestRoot");
assertTrue("Wrong ACL",
accessManager.hasPermission(((NodeImpl)n1).getACL(), PermissionType.SET_PROPERTY,
@@ -186,6 +187,7 @@
private Node testRoot;
+ @Override
public void execute() throws RepositoryException
{
testRoot = testRootNode.addNode("testImportVersionable");
@@ -207,6 +209,7 @@
testRoot.save();
}
+ @Override
public Node getExportRoot()
{
return testRoot;
@@ -216,6 +219,7 @@
BeforeImportAction beforeImportAction = new BeforeImportAction(null, null)
{
+ @Override
public void execute() throws RepositoryException
{
Node testRoot2 = testRootNode.getNode("testImportVersionable");
@@ -223,6 +227,7 @@
testRootNode.save();
}
+ @Override
public Node getImportRoot()
{
return testRootNode;
@@ -236,6 +241,7 @@
private Node testRoot2;
+ @Override
public void execute() throws RepositoryException
{
testRootNode.save();
@@ -316,6 +322,7 @@
private Node testRoot2;
+ @Override
public void execute() throws RepositoryException
{
testRootNode.save();
@@ -364,6 +371,7 @@
private Node testRoot;
+ @Override
public void execute() throws RepositoryException
{
testRoot = testRootNode.addNode("testImportVersionable");
@@ -385,6 +393,7 @@
testRoot.save();
}
+ @Override
public Node getExportRoot()
{
return testRoot;
@@ -394,6 +403,7 @@
BeforeImportAction beforeImportAction = new BeforeImportAction(null, null)
{
+ @Override
public Node getImportRoot() throws RepositoryException
{
Node importRoot = testRootNode.addNode("ImportRoot");
@@ -410,6 +420,7 @@
private Node testRoot2;
+ @Override
public void execute() throws RepositoryException
{
testRootNode.save();
@@ -495,7 +506,7 @@
session.save();
deserialize(testRootNode, XmlSaveType.SESSION, true,
ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING,
- new BufferedInputStream(new FileInputStream(versionableNodeContent)));
+ new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(versionableNodeContent)));
session.save();
testRoot = testRootNode.getNode("testImportVersionable");
assertTrue(testRoot.isNodeType("mix:versionable"));
@@ -503,8 +514,8 @@
assertEquals(1, testRoot.getVersionHistory().getAllVersions().getSize());
VersionHistoryImporter historyImporter =
- new VersionHistoryImporter((NodeImpl)testRoot, new BufferedInputStream(new
FileInputStream(vhNodeContent)),
- baseVersionUuid, predecessors, versionHistory);
+ new VersionHistoryImporter((NodeImpl)testRoot, new
BufferedInputStream(PrivilegedFileHelper
+ .fileInputStream(vhNodeContent)), baseVersionUuid, predecessors,
versionHistory);
historyImporter.doImport();
session.save();
@@ -864,15 +875,18 @@
{
protected String dumpStr = "";
+ @Override
protected void entering(Node node, int level) throws RepositoryException
{
dumpStr += node.getPath() + "\n";
}
+ @Override
protected void leaving(Property property, int level) throws RepositoryException
{
}
+ @Override
protected void leaving(Node node, int level) throws RepositoryException
{
}
@@ -885,6 +899,7 @@
/**
* {@inheritDoc}
*/
+ @Override
protected void entering(Property property, int level) throws RepositoryException
{
dumpStr += " " + property.getPath() + "=" +
valToString(property) + " \n";
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestSystemViewImport.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestSystemViewImport.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestSystemViewImport.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -268,7 +268,7 @@
Node importTarget = sysview.addNode("import target");
sysview.save();
- sysview.getSession().importXML(importTarget.getPath(), new
FileInputStream(xmlContent),
+ sysview.getSession().importXML(importTarget.getPath(),
PrivilegedFileHelper.fileInputStream(xmlContent),
ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
sysview.save();
@@ -282,7 +282,7 @@
// try one more (for same-name sibling nodes test), mus replace before
// imported node
- sysview.getSession().importXML(importTarget.getPath(), new
FileInputStream(xmlContent),
+ sysview.getSession().importXML(importTarget.getPath(),
PrivilegedFileHelper.fileInputStream(xmlContent),
ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
sysview.save();
@@ -307,7 +307,7 @@
Node importTarget = sysview.addNode("import target");
sysview.save();
- sysview.getSession().importXML(importTarget.getPath(), new
FileInputStream(xmlContent),
+ sysview.getSession().importXML(importTarget.getPath(),
PrivilegedFileHelper.fileInputStream(xmlContent),
ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
sysview.save();
@@ -325,7 +325,7 @@
.hasProperty("jcr:content/New property 2, string"));
// create one more same-name sibling node
- sysview.getSession().importXML(importTarget.getPath(), new
FileInputStream(xmlContent),
+ sysview.getSession().importXML(importTarget.getPath(),
PrivilegedFileHelper.fileInputStream(xmlContent),
ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
sysview.save();
@@ -355,7 +355,7 @@
try
{
- sysview.getSession().importXML(importTarget.getPath(), new
FileInputStream(xmlContent),
+ sysview.getSession().importXML(importTarget.getPath(),
PrivilegedFileHelper.fileInputStream(xmlContent),
ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
fail("An exception ItemExistsException must be throwed. Node with same uuid
already exists");
@@ -368,7 +368,7 @@
// one more time...:)
try
{
- sysview.getSession().importXML(importTarget.getPath(), new
FileInputStream(xmlContent),
+ sysview.getSession().importXML(importTarget.getPath(),
PrivilegedFileHelper.fileInputStream(xmlContent),
ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
fail("An exception ItemExistsException must be throwed. Node with same uuid
already exists. TEST CYCLE2");
}
@@ -385,7 +385,7 @@
Node importTarget = sysview.addNode("import target");
sysview.save();
- sysview.getSession().importXML(importTarget.getPath(), new
FileInputStream(xmlContent),
+ sysview.getSession().importXML(importTarget.getPath(),
PrivilegedFileHelper.fileInputStream(xmlContent),
ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
sysview.save();
@@ -396,7 +396,7 @@
assertFalse("Uuids must be different. " + uuid + " != " +
importedUuid, uuid.equals(importedUuid));
// create one more same-name sibling node
- sysview.getSession().importXML(importTarget.getPath(), new
FileInputStream(xmlContent),
+ sysview.getSession().importXML(importTarget.getPath(),
PrivilegedFileHelper.fileInputStream(xmlContent),
ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
sysview.save();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/nodetypes/TestValueConstraints.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/nodetypes/TestValueConstraints.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/nodetypes/TestValueConstraints.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -21,6 +21,7 @@
import org.exoplatform.services.jcr.JcrAPIBaseTest;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeManagerImpl;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -54,6 +55,7 @@
private static String LOCAL_NORMAL_FILE = null;
+ @Override
public void setUp() throws Exception
{
super.setUp();
@@ -166,8 +168,9 @@
{
Property testProperty =
- testValueConstraintsNode.setProperty("jcr:testBINARYINCLUSIVE", new
FileInputStream(LOCAL_SMALL_FILE));
- testProperty.setValue(new FileInputStream(LOCAL_BIG_FILE));
+ testValueConstraintsNode.setProperty("jcr:testBINARYINCLUSIVE",
PrivilegedFileHelper
+ .fileInputStream(LOCAL_SMALL_FILE));
+ testProperty.setValue(PrivilegedFileHelper.fileInputStream(LOCAL_BIG_FILE));
session.save();
}
@@ -177,8 +180,9 @@
try
{
Property testProperty =
- testValueConstraintsNode.setProperty("jcr:testBINARYEXCLUSIVE", new
FileInputStream(LOCAL_SMALL_FILE));
- testProperty.setValue(new FileInputStream(LOCAL_BIG_FILE));
+ testValueConstraintsNode.setProperty("jcr:testBINARYEXCLUSIVE",
PrivilegedFileHelper
+ .fileInputStream(LOCAL_SMALL_FILE));
+ testProperty.setValue(PrivilegedFileHelper.fileInputStream(LOCAL_BIG_FILE));
session.save();
fail("setValue(BINARY value) must throw a ConstraintViolationException
");
}
@@ -190,7 +194,8 @@
try
{
Property testProperty =
- testValueConstraintsNode.setProperty("jcr:testBINARYEXCLUSIVE", new
FileInputStream(LOCAL_NORMAL_FILE));
+ testValueConstraintsNode.setProperty("jcr:testBINARYEXCLUSIVE",
PrivilegedFileHelper
+ .fileInputStream(LOCAL_NORMAL_FILE));
session.save();
fail("setValue(BINARY value) must throw a ConstraintViolationException
");
}
@@ -354,6 +359,7 @@
}
}
+ @Override
protected void tearDown() throws Exception
{
if (session.getRootNode().hasNode("testValueConstraints"))
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestSetProperty.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestSetProperty.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestSetProperty.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -27,6 +27,7 @@
import org.exoplatform.services.jcr.impl.core.SessionImpl;
import org.exoplatform.services.jcr.impl.core.value.NameValue;
import
org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableWorkspaceDataManager;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.ByteArrayInputStream;
import java.io.File;
@@ -58,6 +59,7 @@
private TransactionChangesLog cLog;
+ @Override
public void setUp() throws Exception
{
super.setUp();
@@ -68,6 +70,7 @@
dm.addItemPersistenceListener(this);
}
+ @Override
public void initRepository() throws RepositoryException
{
Node root = session.getRootNode();
@@ -101,6 +104,7 @@
session.save();
}
+ @Override
public void tearDown() throws Exception
{
@@ -198,7 +202,7 @@
session.refresh(false);
- node.setProperty("jcr:defaultValues", new
Value[]{valueFactory.createValue((long)10)});
+ node.setProperty("jcr:defaultValues", new
Value[]{valueFactory.createValue(10)});
assertEquals(PropertyType.LONG,
node.getProperty("jcr:defaultValues").getValues()[0].getType());
assertEquals(10,
node.getProperty("jcr:defaultValues").getValues()[0].getLong());
node.save();
@@ -367,13 +371,13 @@
Node node = root.addNode("testNode");
File tmpFile1 = createBLOBTempFile(250);
- node.setProperty("testProp", new FileInputStream(tmpFile1));
+ node.setProperty("testProp",
PrivilegedFileHelper.fileInputStream(tmpFile1));
File tmpFile2 = createBLOBTempFile(500);
- node.setProperty("testProp", new FileInputStream(tmpFile2));
+ node.setProperty("testProp",
PrivilegedFileHelper.fileInputStream(tmpFile2));
File tmpFile3 = createBLOBTempFile(1000);
- node.setProperty("testProp", new FileInputStream(tmpFile3));
+ node.setProperty("testProp",
PrivilegedFileHelper.fileInputStream(tmpFile3));
session.save();
@@ -387,7 +391,7 @@
ItemState item = cLog.getAllStates().get(i);
// TODO doesn't pass with FileTree VS, ok with CAS if contents different
//compareStream(((PropertyData)
item.getData()).getValues().get(0).getAsStream(),
- // new FileInputStream(tempFiles[i - 2]));
+ // PrivilegedFileHelper.fileInputStream(tempFiles[i - 2]));
}
}
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestUpdate.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestUpdate.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestUpdate.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.api.writing;
import org.exoplatform.services.jcr.JcrAPIBaseTest;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.File;
import java.io.FileInputStream;
@@ -62,7 +63,7 @@
File propData = createBLOBTempFile(1024);
- InputStream pds = new FileInputStream(propData);
+ InputStream pds = PrivilegedFileHelper.fileInputStream(propData);
try
{
corrNode.setProperty("prop1", pds);
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestMoveNode.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestMoveNode.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestMoveNode.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -21,6 +21,7 @@
import org.exoplatform.services.jcr.JcrImplBaseTest;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.FileInputStream;
import java.io.InputStream;
@@ -224,7 +225,7 @@
Node localBigFile = testLocalBigFiles.addNode("bigFile" + i,
"nt:file");
Node contentNode = localBigFile.addNode("jcr:content",
"nt:resource");
// contentNode.setProperty("jcr:encoding", "UTF-8");
- is[i] = new FileInputStream(TEST_FILE);
+ is[i] = PrivilegedFileHelper.fileInputStream(TEST_FILE);
contentNode.setProperty("jcr:data", is[i]);
contentNode.setProperty("jcr:mimeType", "application/octet-stream
");
if (log.isDebugEnabled())
@@ -269,7 +270,8 @@
{
Node localBigFile = dstNode.getNode("bigFile" + i);
Node contentNode = localBigFile.getNode("jcr:content");
- compareStream(new FileInputStream(filesList.get(i)),
contentNode.getProperty("jcr:data").getStream());
+ compareStream(PrivilegedFileHelper.fileInputStream(filesList.get(i)),
contentNode.getProperty("jcr:data")
+ .getStream());
}
}
}
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestRestoreWorkspaceInitializer.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestRestoreWorkspaceInitializer.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestRestoreWorkspaceInitializer.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -66,14 +66,14 @@
Node blob = root.addNode("binaryTest");
File f;
InputStream is;
- blob.setProperty("blob", is = new FileInputStream(f =
createBLOBTempFile(2 * 1024))); // 2M
+ blob.setProperty("blob", is = PrivilegedFileHelper.fileInputStream(f =
createBLOBTempFile(2 * 1024))); // 2M
root.save();
is.close();
- f.renameTo(new File("./sv_export_binary.bin"));
+ f.renameTo(PrivilegedFileHelper.file("./sv_export_binary.bin"));
- File outf = new File("./sv_export_root.xml");
+ File outf = PrivilegedFileHelper.file("./sv_export_root.xml");
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(outf);
session.exportWorkspaceSystemView(out, false, false);
out.close();
@@ -120,7 +120,7 @@
p = multiv.getProperty("exojcrtest:multiValuedName");
p.getValues();
- compareStream(new FileInputStream("./sv_export_binary.bin"),
root.getNode("binaryTest").getProperty("blob")
+
compareStream(PrivilegedFileHelper.fileInputStream("./sv_export_binary.bin"),
root.getNode("binaryTest").getProperty("blob")
.getStream());
}
catch (ValueFormatException e)
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceRestore.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceRestore.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceRestore.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -86,7 +86,7 @@
defRep = (RepositoryImpl)service.getDefaultRepository();
defRep.configWorkspace(workspaceEntry);
- defRep.importWorkspace(workspaceEntry.getName(), new BufferedInputStream(new
FileInputStream(content)));
+ defRep.importWorkspace(workspaceEntry.getName(), new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(content)));
doTestOnWorkspace(workspaceEntry.getName());
}
@@ -156,7 +156,7 @@
try
{
- defRep.importWorkspace(workspaceEntry.getName(), new BufferedInputStream(new
FileInputStream(content)));
+ defRep.importWorkspace(workspaceEntry.getName(), new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(content)));
fail();
}
catch (RepositoryException e)
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestArabicSearch.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestArabicSearch.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestArabicSearch.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -25,6 +25,7 @@
import org.apache.lucene.search.TermQuery;
import org.exoplatform.services.jcr.impl.core.NodeImpl;
import org.exoplatform.services.jcr.impl.core.query.lucene.FieldNames;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.File;
import java.io.FileInputStream;
@@ -48,10 +49,10 @@
public void testSearchWithEncodingParameter() throws Exception
{
- File file = new File("src/test/resources/ArabicUTF8.txt");
+ File file =
PrivilegedFileHelper.file("src/test/resources/ArabicUTF8.txt");
assertTrue("/test/resources/ArabicUTF8.txt not found", file.exists());
- FileInputStream fis = new FileInputStream(file);
+ FileInputStream fis = PrivilegedFileHelper.fileInputStream(file);
NodeImpl node = (NodeImpl)root.addNode(fileName, "nt:file");
NodeImpl cont = (NodeImpl)node.addNode("jcr:content",
"nt:resource");
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestDateSearch.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestDateSearch.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestDateSearch.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -25,6 +25,7 @@
import org.apache.lucene.search.TermQuery;
import org.exoplatform.services.jcr.impl.core.NodeImpl;
import org.exoplatform.services.jcr.impl.core.query.lucene.FieldNames;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.File;
import java.io.FileInputStream;
@@ -47,10 +48,10 @@
public void testSearchDate() throws Exception
{
- File file = new File("src/test/resources/test.xls");
+ File file = PrivilegedFileHelper.file("src/test/resources/test.xls");
assertTrue("/test/resources/test.xls not found", file.exists());
- FileInputStream fis = new FileInputStream(file);
+ FileInputStream fis = PrivilegedFileHelper.fileInputStream(file);
NodeImpl node = (NodeImpl)root.addNode(fileName, "nt:file");
NodeImpl cont = (NodeImpl)node.addNode("jcr:content",
"nt:resource");
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestErrorMultithreading.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestErrorMultithreading.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestErrorMultithreading.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -20,6 +20,7 @@
import org.exoplatform.services.jcr.core.CredentialsImpl;
import org.exoplatform.services.jcr.impl.core.NodeImpl;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.jcr.util.IdGenerator;
import java.io.File;
@@ -53,6 +54,7 @@
public static final String THREAD_NAME = "name";
+ @Override
public void tearDown()
{
@@ -74,7 +76,7 @@
public Session sess;
- File file = new File("src/test/resources/LARGE.txt");
+ File file =
PrivilegedFileHelper.file("src/test/resources/LARGE.txt");
public FileInputStream fis = null;
@@ -84,6 +86,7 @@
this.sess = s;
}
+ @Override
public void run()
{
System.out.println(name + " - START");
@@ -99,7 +102,7 @@
NodeImpl cont = (NodeImpl)node.addNode("jcr:content",
"nt:resource");
cont.setProperty("jcr:mimeType", "text/plain");
cont.setProperty("jcr:lastModified",
Calendar.getInstance());
- fis = new FileInputStream(file);
+ fis = PrivilegedFileHelper.fileInputStream(file);
cont.setProperty("jcr:data", fis);
root.save();
System.out.println(fileName + " saved");
@@ -121,7 +124,7 @@
{
Credentials credentials = new CredentialsImpl("admin",
"admin".toCharArray());
- Session ss = (SessionImpl)repository.login(credentials, "ws");
+ Session ss = repository.login(credentials, "ws");
Writer wr = new Writer(THREAD_NAME + t, ss);
writers.add(wr);
}
@@ -159,6 +162,7 @@
super.setName(this.name); // super.getName() + ", " +
}
+ @Override
public void run()
{
System.out.println(name + " - START");
@@ -196,7 +200,7 @@
{
Credentials credentials = new CredentialsImpl("admin",
"admin".toCharArray());
- Session ss = (SessionImpl)repository.login(credentials, "ws");
+ Session ss = repository.login(credentials, "ws");
Writer wr = new Writer(THREAD_NAME + t, ss);
writers.add(wr);
}
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestExcelFileSearch.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestExcelFileSearch.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestExcelFileSearch.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -28,6 +28,7 @@
import org.exoplatform.services.document.impl.MSExcelDocumentReader;
import org.exoplatform.services.jcr.impl.core.NodeImpl;
import org.exoplatform.services.jcr.impl.core.query.lucene.FieldNames;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.File;
import java.io.FileInputStream;
@@ -44,10 +45,10 @@
public void testFindFileContent() throws Exception
{
- File file = new File("src/test/resources/test.xls");
+ File file = PrivilegedFileHelper.file("src/test/resources/test.xls");
assertTrue("/test/resources/book.xls not found", file.exists());
- FileInputStream fis = new FileInputStream(file);
+ FileInputStream fis = PrivilegedFileHelper.fileInputStream(file);
NodeImpl node = (NodeImpl)root.addNode("excelFile",
"nt:file");
NodeImpl cont = (NodeImpl)node.addNode("jcr:content",
"nt:resource");
@@ -59,7 +60,7 @@
root.save();
fis.close();
- fis = new FileInputStream(file);
+ fis = PrivilegedFileHelper.fileInputStream(file);
DocumentReaderService extr =
(DocumentReaderService)session.getContainer().getComponentInstanceOfType(DocumentReaderService.class);
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestByteArrayPersistedValueDataSerialization.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestByteArrayPersistedValueDataSerialization.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestByteArrayPersistedValueDataSerialization.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -59,7 +59,7 @@
oos.close();
//deserialize
- ObjectInputStream ois = new ObjectInputStream(new FileInputStream(out));
+ ObjectInputStream ois = new
ObjectInputStream(PrivilegedFileHelper.fileInputStream(out));
ByteArrayPersistedValueData deserializedValueData =
(ByteArrayPersistedValueData)ois.readObject();
//check
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCleanableFileStreamValueData.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCleanableFileStreamValueData.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCleanableFileStreamValueData.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -46,9 +46,9 @@
private static final String FILE_NAME = "testFileCleaned";
- private File parentDir = new File("./target");
+ private File parentDir = PrivilegedFileHelper.file("./target");
- private File testFile = new File(parentDir, FILE_NAME);
+ private File testFile = PrivilegedFileHelper.file(parentDir, FILE_NAME);
private FileCleaner testCleaner;
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationLogTestLoad.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationLogTestLoad.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationLogTestLoad.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -44,7 +44,7 @@
TesterItemsPersistenceListener pl = new
TesterItemsPersistenceListener(this.session);
File file = this.createBLOBTempFile(310);
- FileInputStream fis = new FileInputStream(file);
+ FileInputStream fis = PrivilegedFileHelper.fileInputStream(file);
NodeImpl node = (NodeImpl)root.addNode("file", "nt:file");
NodeImpl cont = (NodeImpl)node.addNode("jcr:content",
"nt:resource");
@@ -82,7 +82,7 @@
System.out.println(" READ START");
// deserialize
- ObjectReaderImpl jcrin = new ObjectReaderImpl(new FileInputStream(jcrfile));
+ ObjectReaderImpl jcrin = new
ObjectReaderImpl(PrivilegedFileHelper.fileInputStream(jcrfile));
// List<TransactionChangesLog> readed = new
ArrayList<TransactionChangesLog>();
long t3 = System.currentTimeMillis();
@@ -123,7 +123,7 @@
// deserialize
System.out.println(" READ START");
- ObjectInputStream jin = new ObjectInputStream(new FileInputStream(jfile));
+ ObjectInputStream jin = new
ObjectInputStream(PrivilegedFileHelper.fileInputStream(jfile));
long t4 = System.currentTimeMillis();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationVSJavaSerializationTestLoad.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationVSJavaSerializationTestLoad.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationVSJavaSerializationTestLoad.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -90,7 +90,7 @@
jcrout.close();
// deserialize
- ObjectReaderImpl jcrin = new ObjectReaderImpl(new FileInputStream(jcrfile));
+ ObjectReaderImpl jcrin = new
ObjectReaderImpl(PrivilegedFileHelper.fileInputStream(jcrfile));
long t3 = System.currentTimeMillis();
@@ -126,7 +126,7 @@
jout.close();
// deserialize
- ObjectInputStream jin = new ObjectInputStream(new FileInputStream(jfile));
+ ObjectInputStream jin = new
ObjectInputStream(PrivilegedFileHelper.fileInputStream(jfile));
it = list.iterator();
long t4 = System.currentTimeMillis();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JcrImplSerializationBaseTest.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JcrImplSerializationBaseTest.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JcrImplSerializationBaseTest.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -121,7 +121,7 @@
protected List<TransactionChangesLog> deSerializeLogs(File jcrfile) throws
IOException, UnknownClassIdException
{
- ObjectReaderImpl jcrin = new ObjectReaderImpl(new FileInputStream(jcrfile));
+ ObjectReaderImpl jcrin = new
ObjectReaderImpl(PrivilegedFileHelper.fileInputStream(jcrfile));
List<TransactionChangesLog> readed = new
ArrayList<TransactionChangesLog>();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/MultipleDeserializationTestLoad.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/MultipleDeserializationTestLoad.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/MultipleDeserializationTestLoad.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -134,7 +134,7 @@
jcrout.close();
- ObjectReaderImpl jcrin = new ObjectReaderImpl(new FileInputStream(jcrfile));
+ ObjectReaderImpl jcrin = new
ObjectReaderImpl(PrivilegedFileHelper.fileInputStream(jcrfile));
long jcrfread = System.currentTimeMillis();
TransactionChangesLog mlog =
(new TransactionChangesLogReader(fileCleaner, maxBufferSize,
holder)).read(jcrin);
@@ -150,7 +150,7 @@
for (int j = 0; j < iterations; j++)
{
// deserialize
- jcrin = new ObjectReaderImpl(new FileInputStream(jcrfile));
+ jcrin = new ObjectReaderImpl(PrivilegedFileHelper.fileInputStream(jcrfile));
long t3 = System.currentTimeMillis();
TransactionChangesLog log = rdr.read(jcrin);
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestEOFException.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestEOFException.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestEOFException.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -48,7 +48,7 @@
ow.write(buffer);
ow.close();
- ObjectReader or = new ObjectReaderImpl(new FileInputStream(test));
+ ObjectReader or = new
ObjectReaderImpl(PrivilegedFileHelper.fileInputStream(test));
byte[] buf = new byte[buffer.length];
try
@@ -78,7 +78,7 @@
ow.writeBoolean(true);
ow.close();
- ObjectReader or = new ObjectReaderImpl(new FileInputStream(test));
+ ObjectReader or = new
ObjectReaderImpl(PrivilegedFileHelper.fileInputStream(test));
boolean b = or.readBoolean();
try
@@ -107,7 +107,7 @@
ow.writeInt(24);
ow.close();
- ObjectReader or = new ObjectReaderImpl(new FileInputStream(test));
+ ObjectReader or = new
ObjectReaderImpl(PrivilegedFileHelper.fileInputStream(test));
int b = or.readInt();
assertEquals(24, b);
@@ -137,7 +137,7 @@
ow.writeLong(24);
ow.close();
- ObjectReader or = new ObjectReaderImpl(new FileInputStream(test));
+ ObjectReader or = new
ObjectReaderImpl(PrivilegedFileHelper.fileInputStream(test));
long b = or.readLong();
assertEquals(24, b);
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestJCRSerializationCopyMove.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestJCRSerializationCopyMove.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestJCRSerializationCopyMove.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.impl.dataflow.serialization;
import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.File;
import java.io.FileInputStream;
@@ -126,7 +127,7 @@
Node file = root.addNode("testMove_",
"nt:folder").addNode("childNode2", "nt:file");
Node contentNode = file.addNode("jcr:content", "nt:resource");
- contentNode.setProperty("jcr:data", new FileInputStream(tempFile));
+ contentNode.setProperty("jcr:data",
PrivilegedFileHelper.fileInputStream(tempFile));
contentNode.setProperty("jcr:mimeType", "text/plain");
contentNode.setProperty("jcr:lastModified",
session.getValueFactory().createValue(Calendar.getInstance()));
session.save();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestJCRSerializationStream.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestJCRSerializationStream.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestJCRSerializationStream.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.impl.dataflow.serialization;
import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.File;
import java.io.FileInputStream;
@@ -50,7 +51,7 @@
Node cool = test.addNode("nnn", "nt:file");
Node contentNode = cool.addNode("jcr:content", "nt:resource");
contentNode.setProperty("jcr:encoding", "UTF-8");
- contentNode.setProperty("jcr:data", new FileInputStream(tempFile));
+ contentNode.setProperty("jcr:data",
PrivilegedFileHelper.fileInputStream(tempFile));
contentNode.setProperty("jcr:mimeType",
"application/octet-stream");
contentNode.setProperty("jcr:lastModified",
session.getValueFactory().createValue(Calendar.getInstance()));
session.save();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestJCRSerializationVersionRestore.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestJCRSerializationVersionRestore.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestJCRSerializationVersionRestore.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -123,7 +123,7 @@
Node srcVersionNode = root.addNode("nt_file_node", "nt:file");
Node contentNode = srcVersionNode.addNode("jcr:content",
"nt:resource");
- contentNode.setProperty("jcr:data", new FileInputStream(tempFile));
+ contentNode.setProperty("jcr:data",
PrivilegedFileHelper.fileInputStream(tempFile));
contentNode.setProperty("jcr:mimeType", "text/plain");
contentNode.setProperty("jcr:lastModified",
session.getValueFactory().createValue(Calendar.getInstance()));
srcVersionNode.addMixin("mix:versionable");
@@ -135,14 +135,14 @@
session.save();
srcVersion.checkout();
- srcVersionNode.getNode("jcr:content").setProperty("jcr:data",
new FileInputStream(tempFile2));
+ srcVersionNode.getNode("jcr:content").setProperty("jcr:data",
PrivilegedFileHelper.fileInputStream(tempFile2));
session.save();
srcVersion.checkin();
session.save();
srcVersion.checkout();
- srcVersionNode.getNode("jcr:content").setProperty("jcr:data",
new FileInputStream(tempFile3));
+ srcVersionNode.getNode("jcr:content").setProperty("jcr:data",
PrivilegedFileHelper.fileInputStream(tempFile3));
session.save();
Version baseVersion = srcVersion.getBaseVersion();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestPropsDeserialization.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestPropsDeserialization.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestPropsDeserialization.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.impl.dataflow.serialization;
import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.File;
import java.io.FileInputStream;
@@ -47,7 +48,7 @@
Node srcVersionNode = root.addNode("nt_file_node", "nt:file");
Node contentNode = srcVersionNode.addNode("jcr:content",
"nt:resource");
- contentNode.setProperty("jcr:data", new FileInputStream(content1));
+ contentNode.setProperty("jcr:data",
PrivilegedFileHelper.fileInputStream(content1));
contentNode.setProperty("jcr:mimeType", "text/plain");
contentNode.setProperty("jcr:lastModified",
session.getValueFactory().createValue(Calendar.getInstance()));
srcVersionNode.addMixin("mix:versionable");
@@ -65,12 +66,12 @@
for (int i = 0; i < logs.size(); i++)
checkIterator(logs.get(i).getAllStates().iterator(),
destLog.get(i).getAllStates().iterator());
-
+
// set value
pl = new TesterItemsPersistenceListener(this.session);
- contentNode.setProperty("jcr:data", new FileInputStream(content2));
+ contentNode.setProperty("jcr:data",
PrivilegedFileHelper.fileInputStream(content2));
session.save();
-
+
// check 2
logs = pl.pushChanges();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/ValueStoragePluginTest.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/ValueStoragePluginTest.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/ValueStoragePluginTest.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -173,7 +173,7 @@
Node localBigFile = testLocalBigFiles.addNode("bigFile" + j,
"nt:file");
Node contentNode = localBigFile.addNode("jcr:content",
"nt:resource");
// contentNode.setProperty("jcr:encoding", "UTF-8");
- InputStream is = new FileInputStream(TEST_FILE);
+ InputStream is = PrivilegedFileHelper.fileInputStream(TEST_FILE);
contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType",
"application/octet-stream ");
is.close();
@@ -195,7 +195,7 @@
Node content = lbf.getNode("jcr:content");
// comparing with source file
- compareStream(new BufferedInputStream(new FileInputStream(blobFiles.get(j))),
content.getProperty(
+ compareStream(new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(blobFiles.get(j))),
content.getProperty(
"jcr:data").getStream());
}
n1.remove();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestRandomValueIO.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestRandomValueIO.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestRandomValueIO.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -22,6 +22,7 @@
import org.exoplatform.services.jcr.JcrImplBaseTest;
import org.exoplatform.services.jcr.core.value.EditableBinaryValue;
import org.exoplatform.services.jcr.core.value.ReadableBinaryValue;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
@@ -81,7 +82,7 @@
// create property
String pname = "file@" + testFile.getName();
- Property p = testRoot.setProperty(pname, new FileInputStream(testFile));
+ Property p = testRoot.setProperty(pname,
PrivilegedFileHelper.fileInputStream(testFile));
EditableBinaryValue exv = (EditableBinaryValue)p.getValue();
@@ -97,7 +98,7 @@
{
// the value obtained by getXXX must be same as on setProperty()
- compareStream(new FileInputStream(testFile),
testRoot.getProperty(pname).getStream());
+ compareStream(PrivilegedFileHelper.fileInputStream(testFile),
testRoot.getProperty(pname).getStream());
// apply edited ExtendetValue to the Property
p.setValue(exv);
@@ -124,7 +125,7 @@
// create property
String pname = "file@" + testFile.getName();
- Property p = testRoot.setProperty(pname, new FileInputStream(testFile));
+ Property p = testRoot.setProperty(pname,
PrivilegedFileHelper.fileInputStream(testFile));
testRoot.save();
@@ -142,7 +143,7 @@
{
// the value obtained by getXXX must be same as on setProperty()
- compareStream(new FileInputStream(testFile),
testRoot.getProperty(pname).getStream());
+ compareStream(PrivilegedFileHelper.fileInputStream(testFile),
testRoot.getProperty(pname).getStream());
// apply edited ExtendetValue to the Property
p.setValue(exv);
@@ -169,7 +170,7 @@
// create property
String pname = "file@" + testFile.getName();
- testRoot.setProperty(pname, new FileInputStream(testFile));
+ testRoot.setProperty(pname, PrivilegedFileHelper.fileInputStream(testFile));
testRoot.save();
@@ -188,7 +189,7 @@
{
// the value obtained by getXXX must be same as on setProperty()
- compareStream(new FileInputStream(testFile),
testRoot.getProperty(pname).getStream());
+ compareStream(PrivilegedFileHelper.fileInputStream(testFile),
testRoot.getProperty(pname).getStream());
// apply edited ExtendetValue to the Property
testRoot.setProperty(pname, exv);
@@ -216,7 +217,7 @@
// create property
String pname = "file@" + testFile.getName();
- Property p = testRoot.setProperty(pname, new FileInputStream(testFile));
+ Property p = testRoot.setProperty(pname,
PrivilegedFileHelper.fileInputStream(testFile));
EditableBinaryValue exv = (EditableBinaryValue)p.getValue();
@@ -269,7 +270,7 @@
// create property
String pname = "file@" + testFile.getName();
- Property p = testRoot.setProperty(pname, new FileInputStream(testFile));
+ Property p = testRoot.setProperty(pname,
PrivilegedFileHelper.fileInputStream(testFile));
EditableBinaryValue exv = (EditableBinaryValue)p.getValue();
@@ -349,7 +350,7 @@
// create property
String pname = "file@" + testFile.getName();
- Property p = testRoot.setProperty(pname, new FileInputStream(testFile));
+ Property p = testRoot.setProperty(pname,
PrivilegedFileHelper.fileInputStream(testFile));
EditableBinaryValue exv = (EditableBinaryValue)p.getValue();
@@ -402,7 +403,7 @@
// create property
String pname = "file@" + testFile.getName();
- Property p = testRoot.setProperty(pname, new FileInputStream(testFile));
+ Property p = testRoot.setProperty(pname,
PrivilegedFileHelper.fileInputStream(testFile));
EditableBinaryValue exv = (EditableBinaryValue)p.getValue();
String update1String = "update#1";
@@ -423,7 +424,8 @@
// test after save
// first 2M of stream data must be same as on setProperty()
- compareStream(new FileInputStream(testFile),
testRoot.getProperty(pname).getStream(), 0, 0, testFile.length());
+ compareStream(PrivilegedFileHelper.fileInputStream(testFile),
testRoot.getProperty(pname).getStream(), 0, 0,
+ testFile.length());
compareStream(new ByteArrayInputStream(update1String.getBytes()),
testRoot.getProperty(pname).getStream(), 0,
pos, update1String.length());
@@ -450,7 +452,7 @@
long fmem = Runtime.getRuntime().freeMemory();
- exv.update(new FileInputStream(testFile), testFile.length(), pos);
+ exv.update(PrivilegedFileHelper.fileInputStream(testFile), testFile.length(),
pos);
long fmemAfter = Runtime.getRuntime().freeMemory();
@@ -470,7 +472,7 @@
// update inside the big data
int npos = 5;
- newexv.update(new FileInputStream(testFile), testFile.length(), npos);
+ newexv.update(PrivilegedFileHelper.fileInputStream(testFile), testFile.length(),
npos);
// apply to the Property and save
p.setValue(newexv);
@@ -481,7 +483,8 @@
assertEquals("Value content is wrong ", content.substring(0, npos), new
String(buff));
- compareStream(new FileInputStream(testFile),
testRoot.getProperty(pname).getStream(), 0, npos, testFile.length());
+ compareStream(PrivilegedFileHelper.fileInputStream(testFile),
testRoot.getProperty(pname).getStream(), 0, npos,
+ testFile.length());
}
public void testAddLength_BigValue() throws Exception
@@ -489,7 +492,7 @@
// create property
String pname = "file@" + testFile.getName();
- Property p = testRoot.setProperty(pname, new FileInputStream(testFile));
+ Property p = testRoot.setProperty(pname,
PrivilegedFileHelper.fileInputStream(testFile));
EditableBinaryValue exv = (EditableBinaryValue)p.getValue();
long pos = 3 * 1024 * 1024;
@@ -511,7 +514,7 @@
// create property
String pname = "file@" + testFile.getName();
- Property p = testRoot.setProperty(pname, new FileInputStream(testFile));
+ Property p = testRoot.setProperty(pname,
PrivilegedFileHelper.fileInputStream(testFile));
EditableBinaryValue exv = (EditableBinaryValue)p.getValue();
long pos = 1024 * 1024;
@@ -622,7 +625,7 @@
// create property
String pname = "file@" + testFile.getName();
- Property p = testRoot.setProperty(pname, new FileInputStream(testFile));
+ Property p = testRoot.setProperty(pname,
PrivilegedFileHelper.fileInputStream(testFile));
EditableBinaryValue exv = (EditableBinaryValue)p.getValue();
long pos = exv.getLength() - (testFile.length() - 20);
@@ -710,7 +713,7 @@
// create property, prepare the data to be readed
String pname = "file@" + testFile.getName();
- Property p = testRoot.setProperty(pname, new FileInputStream(testFile));
+ Property p = testRoot.setProperty(pname,
PrivilegedFileHelper.fileInputStream(testFile));
testRoot.save();
// read partial
@@ -724,7 +727,8 @@
assertEquals("Wrong bytes count have been read", len, res);
- compareStream(new FileInputStream(testFile), new
ByteArrayInputStream(baos.toByteArray()), pos, 0, len);
+ compareStream(PrivilegedFileHelper.fileInputStream(testFile), new
ByteArrayInputStream(baos.toByteArray()), pos,
+ 0, len);
}
public void testReadBigValue() throws Exception
@@ -732,7 +736,7 @@
// create property, prepare the data to be readed
String pname = "file@" + testFile.getName();
- Property p = testRoot.setProperty(pname, new FileInputStream(testFile));
+ Property p = testRoot.setProperty(pname,
PrivilegedFileHelper.fileInputStream(testFile));
EditableBinaryValue exv = (EditableBinaryValue)p.getValue();
@@ -774,7 +778,7 @@
// create property, prepare the data to be readed
String pname = "file@" + testFile.getName();
- Property p = testRoot.setProperty(pname, new FileInputStream(testFile));
+ Property p = testRoot.setProperty(pname,
PrivilegedFileHelper.fileInputStream(testFile));
EditableBinaryValue exv = (EditableBinaryValue)p.getValue();
@@ -912,7 +916,7 @@
// create property, prepare the data to be readed
String pname = "file@" + testFile.getName();
- Property p = testRoot.setProperty(pname, new FileInputStream(testFile));
+ Property p = testRoot.setProperty(pname,
PrivilegedFileHelper.fileInputStream(testFile));
EditableBinaryValue exv = (EditableBinaryValue)p.getValue();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -25,6 +25,7 @@
import org.exoplatform.services.jcr.impl.storage.value.cas.RecordNotFoundException;
import org.exoplatform.services.jcr.impl.storage.value.cas.ValueContentAddressStorage;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.jcr.util.IdGenerator;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -69,10 +70,10 @@
if (rootDir == null)
{
- rootDir = new File("target/temp/values-test");
+ rootDir = PrivilegedFileHelper.file("target/temp/values-test");
rootDir.mkdirs();
- new File(rootDir, FileValueStorage.TEMP_DIR_NAME).mkdirs();
+ PrivilegedFileHelper.file(rootDir, FileValueStorage.TEMP_DIR_NAME).mkdirs();
if (!rootDir.exists())
throw new Exception("Folder does not exist " +
rootDir.getAbsolutePath());
@@ -110,18 +111,19 @@
FileIOChannel fch = openCASChannel(digestType);
String propertyId = IdGenerator.generate();
- ValueData value = new StreamPersistedValueData(0, new FileInputStream(testFile));
+ ValueData value = new StreamPersistedValueData(0,
PrivilegedFileHelper.fileInputStream(testFile));
fch.write(propertyId, value);
fch.commit();
File vsfile =
- new File(rootDir, fch.makeFilePath(vcas.getIdentifier(propertyId, 0),
CASableIOSupport.HASHFILE_ORDERNUMBER)); // orderNum
+ PrivilegedFileHelper.file(rootDir,
fch.makeFilePath(vcas.getIdentifier(propertyId, 0),
+ CASableIOSupport.HASHFILE_ORDERNUMBER)); // orderNum
// =0
assertTrue("File should exists " + vsfile.getAbsolutePath(),
vsfile.exists());
InputStream etalon, tested;
- compareStream(etalon = new FileInputStream(testFile), tested = new
FileInputStream(vsfile));
+ compareStream(etalon = PrivilegedFileHelper.fileInputStream(testFile), tested =
PrivilegedFileHelper.fileInputStream(vsfile));
etalon.close();
tested.close();
}
@@ -141,7 +143,7 @@
// prepare
String propertyId = IdGenerator.generate();
- ValueData value = new StreamPersistedValueData(0, new FileInputStream(testFile));
+ ValueData value = new StreamPersistedValueData(0,
PrivilegedFileHelper.fileInputStream(testFile));
fch.write(propertyId, value);
fch.commit();
@@ -150,7 +152,7 @@
try
{
fch = openCASChannel(digestType);
- fch.write(new String(propertyId), new StreamPersistedValueData(0, new
FileInputStream(testFile)));
+ fch.write(new String(propertyId), new StreamPersistedValueData(0,
PrivilegedFileHelper.fileInputStream(testFile)));
fch.commit();
fail("RecordAlreadyExistsException should be thrown, record exists");
@@ -180,10 +182,10 @@
String propertyId = IdGenerator.generate();
try
{
- ValueData value = new StreamPersistedValueData(0, new
FileInputStream(testFile));
+ ValueData value = new StreamPersistedValueData(0,
PrivilegedFileHelper.fileInputStream(testFile));
fch.write(propertyId, value);
fch.delete(propertyId);
- fch.write(propertyId, new StreamPersistedValueData(0, new
FileInputStream(testFile)));
+ fch.write(propertyId, new StreamPersistedValueData(0,
PrivilegedFileHelper.fileInputStream(testFile)));
fch.commit();
// long initialSize = calcDirSize(rootDir);
@@ -207,14 +209,14 @@
FileIOChannel fch = openCASChannel(digestType);
String propertyId = IdGenerator.generate();
- ValueData value = new StreamPersistedValueData(0, new FileInputStream(testFile));
+ ValueData value = new StreamPersistedValueData(0,
PrivilegedFileHelper.fileInputStream(testFile));
fch.write(propertyId, value);
fch.commit();
ValueData fvalue = fch.read(propertyId, value.getOrderNumber(), 200 * 1024);
InputStream etalon, tested;
- compareStream(etalon = new FileInputStream(testFile), tested =
fvalue.getAsStream());
+ compareStream(etalon = PrivilegedFileHelper.fileInputStream(testFile), tested =
fvalue.getAsStream());
etalon.close();
tested.close();
}
@@ -230,12 +232,13 @@
FileIOChannel fch = openCASChannel(digestType);
String propertyId = IdGenerator.generate();
- ValueData value = new StreamPersistedValueData(0, new FileInputStream(testFile));
+ ValueData value = new StreamPersistedValueData(0,
PrivilegedFileHelper.fileInputStream(testFile));
fch.write(propertyId, value);
fch.commit();
File vsfile =
- new File(rootDir, fch.makeFilePath(vcas.getIdentifier(propertyId, 0),
CASableIOSupport.HASHFILE_ORDERNUMBER)); // orderNum
+ PrivilegedFileHelper.file(rootDir,
fch.makeFilePath(vcas.getIdentifier(propertyId, 0),
+ CASableIOSupport.HASHFILE_ORDERNUMBER)); // orderNum
// =0
fch.delete(propertyId);
@@ -314,12 +317,13 @@
for (int i = 0; i < 20; i++)
{
- fch.write(propertyId, new StreamPersistedValueData(i, new
FileInputStream(testFile)));
+ fch.write(propertyId, new StreamPersistedValueData(i,
PrivilegedFileHelper.fileInputStream(testFile)));
}
fch.commit();
File vsfile =
- new File(rootDir, fch.makeFilePath(vcas.getIdentifier(propertyId, 15),
CASableIOSupport.HASHFILE_ORDERNUMBER));
+ PrivilegedFileHelper.file(rootDir,
fch.makeFilePath(vcas.getIdentifier(propertyId, 15),
+ CASableIOSupport.HASHFILE_ORDERNUMBER));
assertTrue("File should exists " + vsfile.getAbsolutePath(),
vsfile.exists());
assertEquals("Storage size must be increased on size of ONE file ",
initialSize + testFile.length(),
@@ -344,12 +348,13 @@
{
File f = createBLOBTempFile(300);
addedSize += f.length();
- fch.write(propertyId, new StreamPersistedValueData(i, new FileInputStream(f)));
+ fch.write(propertyId, new StreamPersistedValueData(i,
PrivilegedFileHelper.fileInputStream(f)));
}
fch.commit();
File vsfile =
- new File(rootDir, fch.makeFilePath(vcas.getIdentifier(propertyId, 15),
CASableIOSupport.HASHFILE_ORDERNUMBER));
+ PrivilegedFileHelper.file(rootDir,
fch.makeFilePath(vcas.getIdentifier(propertyId, 15),
+ CASableIOSupport.HASHFILE_ORDERNUMBER));
assertTrue("File should exists " + vsfile.getAbsolutePath(),
vsfile.exists());
assertEquals("Storage size must be increased on size of ALL files ",
initialSize + addedSize,
@@ -373,7 +378,7 @@
propertyId = IdGenerator.generate();
FileIOChannel fch = openCASChannel(digestType);
- fch.write(propertyId, new StreamPersistedValueData(0, new
FileInputStream(testFile)));
+ fch.write(propertyId, new StreamPersistedValueData(0,
PrivilegedFileHelper.fileInputStream(testFile)));
fch.commit();
}
@@ -402,7 +407,7 @@
addedSize += f.length();
FileIOChannel fch = openCASChannel(digestType);
- fch.write(propertyId, new StreamPersistedValueData(i, new FileInputStream(f)));
+ fch.write(propertyId, new StreamPersistedValueData(i,
PrivilegedFileHelper.fileInputStream(f)));
fch.commit();
}
@@ -432,7 +437,7 @@
propertyId = pid;
FileIOChannel fch = openCASChannel(digestType);
- fch.write(pid, new StreamPersistedValueData(0, new FileInputStream(testFile)));
+ fch.write(pid, new StreamPersistedValueData(0,
PrivilegedFileHelper.fileInputStream(testFile)));
fch.commit();
}
@@ -473,7 +478,7 @@
addedSize += (fileSize = f.length());
FileIOChannel fch = openCASChannel(digestType);
- fch.write(pid, new StreamPersistedValueData(i, new FileInputStream(f)));
+ fch.write(pid, new StreamPersistedValueData(i,
PrivilegedFileHelper.fileInputStream(f)));
fch.commit();
}
@@ -513,7 +518,7 @@
File f = createBLOBTempFile(450);
addedSize += (m1fileSize = f.length());
- StreamPersistedValueData v = new StreamPersistedValueData(i, new
FileInputStream(f));
+ StreamPersistedValueData v = new StreamPersistedValueData(i,
PrivilegedFileHelper.fileInputStream(f));
if (i == 1)
sharedValue = v;
@@ -544,7 +549,7 @@
m2filesCount++;
File f = createBLOBTempFile(350);
addedSize += (m2fileSize = f.length()); // add size
- v = new StreamPersistedValueData(i, new FileInputStream(f));
+ v = new StreamPersistedValueData(i,
PrivilegedFileHelper.fileInputStream(f));
}
fch.write(property2MultivaluedId, v);
}
@@ -572,7 +577,7 @@
{
File f = createBLOBTempFile(425);
addedSize += f.length();
- v = new StreamPersistedValueData(i, new FileInputStream(f));
+ v = new StreamPersistedValueData(i,
PrivilegedFileHelper.fileInputStream(f));
}
FileIOChannel vfch = openCASChannel(digestType);
vfch.write(pid, v);
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/Probe.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/Probe.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/Probe.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -18,6 +18,8 @@
*/
package org.exoplatform.services.jcr.impl.storage.value.fs;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
+
import java.io.File;
import java.io.FileInputStream;
@@ -45,12 +47,13 @@
this.file = file;
}
+ @Override
public void run()
{
System.out.println("Thread started " + this.getName());
try
{
- FileInputStream is = new FileInputStream(file);
+ FileInputStream is = PrivilegedFileHelper.fileInputStream(file);
while (is.read() > 0)
{
len++;
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileIOChannel.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileIOChannel.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileIOChannel.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -58,10 +58,10 @@
{
super.setUp();
- rootDir = new File(new File("target"), "vs1");
+ rootDir = PrivilegedFileHelper.file(PrivilegedFileHelper.file("target"),
"vs1");
rootDir.mkdirs();
- new File(rootDir, FileValueStorage.TEMP_DIR_NAME).mkdirs();
+ PrivilegedFileHelper.file(rootDir, FileValueStorage.TEMP_DIR_NAME).mkdirs();
if (!rootDir.exists())
throw new Exception("Folder does not exist " +
rootDir.getAbsolutePath());
@@ -72,7 +72,7 @@
{
byte[] buf = "0123456789".getBytes();
- File file = new File(rootDir, "testReadFromIOChannel0");
+ File file = PrivilegedFileHelper.file(rootDir,
"testReadFromIOChannel0");
file.deleteOnExit();
if (file.exists())
file.delete();
@@ -82,7 +82,7 @@
buf = "01234567890123456789".getBytes();
- file = new File(rootDir, "testReadFromIOChannel1");
+ file = PrivilegedFileHelper.file(rootDir, "testReadFromIOChannel1");
if (file.exists())
file.delete();
out = PrivilegedFileHelper.fileOutputStream(file);
@@ -136,11 +136,11 @@
}
channel.commit();
- assertTrue(new File(rootDir, "testWriteToIOChannel0").exists());
- assertTrue(new File(rootDir, "testWriteToIOChannel1").exists());
- assertTrue(new File(rootDir, "testWriteToIOChannel2").exists());
+ assertTrue(PrivilegedFileHelper.file(rootDir,
"testWriteToIOChannel0").exists());
+ assertTrue(PrivilegedFileHelper.file(rootDir,
"testWriteToIOChannel1").exists());
+ assertTrue(PrivilegedFileHelper.file(rootDir,
"testWriteToIOChannel2").exists());
- assertEquals(10, new File(rootDir, "testWriteToIOChannel0").length());
+ assertEquals(10, PrivilegedFileHelper.file(rootDir,
"testWriteToIOChannel0").length());
channel.delete("testWriteToIOChannel");
channel.commit();
@@ -199,16 +199,16 @@
}
channel.commit();
- assertTrue(new File(rootDir, "testDeleteFromIOChannel0").exists());
- assertTrue(new File(rootDir, "testDeleteFromIOChannel1").exists());
- assertTrue(new File(rootDir, "testDeleteFromIOChannel2").exists());
+ assertTrue(PrivilegedFileHelper.file(rootDir,
"testDeleteFromIOChannel0").exists());
+ assertTrue(PrivilegedFileHelper.file(rootDir,
"testDeleteFromIOChannel1").exists());
+ assertTrue(PrivilegedFileHelper.file(rootDir,
"testDeleteFromIOChannel2").exists());
channel.delete("testDeleteFromIOChannel");
channel.commit();
- assertFalse(new File(rootDir, "testDeleteFromIOChannel0").exists());
- assertFalse(new File(rootDir, "testDeleteFromIOChannel1").exists());
- assertFalse(new File(rootDir, "testDeleteFromIOChannel2").exists());
+ assertFalse(PrivilegedFileHelper.file(rootDir,
"testDeleteFromIOChannel0").exists());
+ assertFalse(PrivilegedFileHelper.file(rootDir,
"testDeleteFromIOChannel1").exists());
+ assertFalse(PrivilegedFileHelper.file(rootDir,
"testDeleteFromIOChannel2").exists());
channel.delete("testDeleteFromIOChannel");
channel.commit();
@@ -237,7 +237,7 @@
}
channel.commit();
- File f = new File(rootDir, "testConcurrentReadFromIOChannel0");
+ File f = PrivilegedFileHelper.file(rootDir,
"testConcurrentReadFromIOChannel0");
if (!f.exists())
throw new Exception("File does not exist " + f.getAbsolutePath());
@@ -283,7 +283,7 @@
}
channel.commit();
- File f = new File(rootDir, "testDeleteLockedFileFromIOChannel0");
+ File f = PrivilegedFileHelper.file(rootDir,
"testDeleteLockedFileFromIOChannel0");
Probe p = new Probe(f);
p.start();
@@ -295,10 +295,10 @@
// removed by FileCleaner
//Thread.sleep(3000);
- f = new File(rootDir, "testDeleteLockedFileFromIOChannel0");
+ f = PrivilegedFileHelper.file(rootDir,
"testDeleteLockedFileFromIOChannel0");
// assertFalse(f.exists());
System.out.println(">>>>>>>>>>>>>"
+ f.canRead() + " " + f.exists() + " " + f.canWrite());
- System.out.println(">>>>>>>>>>>>>"
+ new FileInputStream(f).read());
+ System.out.println(">>>>>>>>>>>>>"
+ PrivilegedFileHelper.fileInputStream(f).read());
// new Probe(f).start();
}
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileValueIO.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileValueIO.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileValueIO.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -85,7 +85,7 @@
{
byte[] buf = "0123456789".getBytes();
- File file = new File("target/testReadByteArrayValueData");
+ File file =
PrivilegedFileHelper.file("target/testReadByteArrayValueData");
if (file.exists())
file.delete();
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
@@ -107,7 +107,7 @@
{
byte[] buf = "0123456789".getBytes();
- File file = new File("target/testReadFileValueData");
+ File file = PrivilegedFileHelper.file("target/testReadFileValueData");
if (file.exists())
file.delete();
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
@@ -136,7 +136,7 @@
{
byte[] buf = "0123456789".getBytes();
- File file = new File("target/testWriteFileValueData");
+ File file = PrivilegedFileHelper.file("target/testWriteFileValueData");
if (file.exists())
file.delete();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/TestValueFileIOHelper.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/TestValueFileIOHelper.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/TestValueFileIOHelper.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -123,7 +123,7 @@
out.close();
}
- testDir = new File("target/TestValueFileIOHelper");
+ testDir = PrivilegedFileHelper.file("target/TestValueFileIOHelper");
testDir.mkdirs();
dest = File.createTempFile("vdftest", "", testDir);
@@ -145,7 +145,7 @@
// copy via InputStream
long start = System.currentTimeMillis();
- InputStream in = new FileInputStream(srcSerialization);
+ InputStream in = PrivilegedFileHelper.fileInputStream(srcSerialization);
OutputStream out = PrivilegedFileHelper.fileOutputStream(dest);
ObjectReader or = new ObjectReaderImpl(in);
@@ -179,7 +179,7 @@
// copy via NIO
start = System.currentTimeMillis();
- in = new BufferedInputStream(new FileInputStream(srcSerialization));
+ in = new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(srcSerialization));
out = PrivilegedFileHelper.fileOutputStream(dest);
openChannel(in, out);
@@ -210,14 +210,14 @@
public void testCopyFileToFile() throws Exception
{
- io.copyClose(new FileInputStream(src),
PrivilegedFileHelper.fileOutputStream(dest));
+ io.copyClose(PrivilegedFileHelper.fileInputStream(src),
PrivilegedFileHelper.fileOutputStream(dest));
// check length
assertEquals(src.length(), dest.length());
// check content
- // InputStream srcin = new FileInputStream(src);
- // InputStream destin = new FileInputStream(dest);
+ // InputStream srcin = PrivilegedFileHelper.fileInputStream(src);
+ // InputStream destin = PrivilegedFileHelper.fileInputStream(dest);
// try {
// compareStream(srcin, destin);
// } finally {
@@ -234,7 +234,7 @@
// copy via InputStream
long start = System.currentTimeMillis();
- InputStream in = new FileInputStream(src);
+ InputStream in = PrivilegedFileHelper.fileInputStream(src);
// InputStream in = new
URL("http://jboss1.exoua-int:8089/browser/02.zip").openStream();
OutputStream out = PrivilegedFileHelper.fileOutputStream(dest);
try
@@ -261,7 +261,7 @@
// copy via NIO
start = System.currentTimeMillis();
- io.copyClose(new BufferedInputStream(new FileInputStream(src)),
PrivilegedFileHelper.fileOutputStream(dest));
+ io.copyClose(new BufferedInputStream(PrivilegedFileHelper.fileInputStream(src)),
PrivilegedFileHelper.fileOutputStream(dest));
// io.copyClose(new
URL("http://jboss1.exoua-int:8089/browser/02.zip").openStream(), new
// FileOutputStream(dest));
System.out.println("\t=== NIO time " + (System.currentTimeMillis() -
start));
@@ -270,8 +270,8 @@
assertEquals(src.length(), dest.length());
// check content
- // InputStream srcin = new FileInputStream(src);
- // InputStream destin = new FileInputStream(dest);
+ // InputStream srcin = PrivilegedFileHelper.fileInputStream(src);
+ // InputStream destin = PrivilegedFileHelper.fileInputStream(dest);
// try {
// compareStream(srcin, destin);
// } finally {
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/tools/tree/generator/RandomValueNodeGenerator.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/tools/tree/generator/RandomValueNodeGenerator.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/tools/tree/generator/RandomValueNodeGenerator.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -94,7 +94,7 @@
else
{
file = createBLOBTempFile(size);
- inputStream = new BufferedInputStream(new FileInputStream(file));
+ inputStream = new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(file));
}
val = valueFactory.createValue(inputStream);
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestPersistedValueData.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestPersistedValueData.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestPersistedValueData.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -58,7 +58,7 @@
{
byte[] buf = "0123456789".getBytes();
- File file = new File("target/testCreateFileStreamValueData");
+ File file =
PrivilegedFileHelper.file("target/testCreateFileStreamValueData");
if (file.exists())
file.delete();
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
@@ -84,8 +84,8 @@
{
byte[] buf = "0123456789".getBytes();
- SwapFile file = SwapFile.get(new File("target"),
"testIfFinalizeRemovesTempFileStreamValueData");
- //File file = new
File("target/testIfFinalizeRemovesTempFileStreamValueData");
+ SwapFile file = SwapFile.get(PrivilegedFileHelper.file("target"),
"testIfFinalizeRemovesTempFileStreamValueData");
+ //File file =
PrivilegedFileHelper.file("target/testIfFinalizeRemovesTempFileStreamValueData");
//if (file.exists())
// file.delete();
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
@@ -111,7 +111,7 @@
byte[] buf =
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
.getBytes();
- File file = new File("target/testConcurrentFileStreamValueDataReading");
+ File file =
PrivilegedFileHelper.file("target/testConcurrentFileStreamValueDataReading");
if (file.exists())
file.delete();
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestTransientValueData.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestTransientValueData.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestTransientValueData.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -69,16 +69,16 @@
{
byte[] buf = "0123456789".getBytes();
- File file = new File("target/testCreateFileStreamTransientValueData");
+ File file =
PrivilegedFileHelper.file("target/testCreateFileStreamTransientValueData");
if (file.exists())
file.delete();
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
out.write(buf);
out.close();
- FileInputStream fs1 = new FileInputStream(file);
+ FileInputStream fs1 = PrivilegedFileHelper.fileInputStream(file);
TransientValueData vd =
- new TransientValueData(0, null, fs1, null, new FileCleaner(), 5, new
File("target"), true);
+ new TransientValueData(0, null, fs1, null, new FileCleaner(), 5,
PrivilegedFileHelper.file("target"), true);
// spool to file
InputStream fs2 = vd.getAsStream();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestTransientValueDataSpooling.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestTransientValueDataSpooling.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestTransientValueDataSpooling.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -54,7 +54,7 @@
private TransactionChangesLog cLog;
- private final File tmpdir = new File(System.getProperty("java.io.tmpdir"));
+ private final File tmpdir =
PrivilegedFileHelper.file(System.getProperty("java.io.tmpdir"));
private boolean haveValueStorage = false;
@@ -110,7 +110,7 @@
});
NodeImpl node = (NodeImpl)root.addNode("testNode");
- node.setProperty("testProp", new FileInputStream(tmpFile));
+ node.setProperty("testProp",
PrivilegedFileHelper.fileInputStream(tmpFile));
root.save();
System.gc();
@@ -149,7 +149,7 @@
});
Node node = root.addNode("testNode");
- node.setProperty("testProp", new FileInputStream(tmpFile));
+ node.setProperty("testProp",
PrivilegedFileHelper.fileInputStream(tmpFile));
node.getProperty("testProp").getStream().close();
root.save();
@@ -172,7 +172,7 @@
File tmpFile = createBLOBTempFile(250);
Node node = root.addNode("testNode");
- node.setProperty("testProp", new FileInputStream(tmpFile));
+ node.setProperty("testProp",
PrivilegedFileHelper.fileInputStream(tmpFile));
session.save();
TransactionChangesLog cl = new
TransactionChangesLog(cLog.getLogIterator().nextLog());
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestValueImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestValueImpl.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestValueImpl.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -45,7 +45,7 @@
public class TestValueImpl extends TestCase
{
- private File tempDirectory = new
File(System.getProperty("java.io.tmpdir"));
+ private File tempDirectory =
PrivilegedFileHelper.file(System.getProperty("java.io.tmpdir"));
private int maxFufferSize = 10;
@@ -53,14 +53,14 @@
{
byte[] buf = "012345678901234567890123456789".getBytes();
- File file = new File("target/testNewBinaryValue");
+ File file = PrivilegedFileHelper.file("target/testNewBinaryValue");
if (file.exists())
file.delete();
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
out.write(buf);
out.close();
- FileInputStream fs1 = new FileInputStream(file);
+ FileInputStream fs1 = PrivilegedFileHelper.fileInputStream(file);
BinaryValue val = new BinaryValue(fs1, new FileCleaner(), tempDirectory,
maxFufferSize);
InputStream str1 = val.getStream();
assertNotNull(str1);
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestBLOBValue.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestBLOBValue.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestBLOBValue.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -1,6 +1,7 @@
package org.exoplatform.services.jcr.lab.cluster.test;
import org.exoplatform.services.jcr.JcrAPIBaseTest;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.File;
import java.io.FileInputStream;
@@ -31,7 +32,7 @@
Node contentNode = file.addNode("jcr:content", "nt:resource");
// contentNode.setProperty("jcr:encoding", "UTF-8");
contentNode.setProperty("jcr:mimeType",
"application/octet-stream");
- InputStream is = new FileInputStream(blob);
+ InputStream is = PrivilegedFileHelper.fileInputStream(blob);
try
{
contentNode.setProperty("jcr:data", is);
@@ -81,7 +82,7 @@
{
children.nextNode().remove();
}
-
+
testRoot.save();
}
@@ -96,7 +97,7 @@
// write
Property text = testRoot.setProperty("text", "string
property");
- FileInputStream fis = new FileInputStream(testFile);
+ FileInputStream fis = PrivilegedFileHelper.fileInputStream(testFile);
Property blob = testRoot.setProperty("blob", fis);
testRoot.save();
@@ -182,4 +183,3 @@
}
}
}
-
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/java/TestFileLock.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/java/TestFileLock.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/java/TestFileLock.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -45,7 +45,7 @@
public void _testSameJVMlLock() throws IOException, InterruptedException
{
- File f = new File("\\\\storm\\public\\file1.tmp");
+ File f = PrivilegedFileHelper.file("\\\\storm\\public\\file1.tmp");
f.createNewFile();
FileOutputStream fout = PrivilegedFileHelper.fileOutputStream(f);
FileChannel fc = fout.getChannel();
@@ -56,7 +56,7 @@
fc.close();
// reopen
- FileInputStream fin = new FileInputStream(f);
+ FileInputStream fin = PrivilegedFileHelper.fileInputStream(f);
fc = fin.getChannel();
byte[] b = new byte[256];
@@ -82,7 +82,7 @@
try
{
Thread.sleep(25);
- FileOutputStream fout1 = PrivilegedFileHelper.fileOutputStream(new
File("\\\\storm\\public\\file1.tmp"));
+ FileOutputStream fout1 =
PrivilegedFileHelper.fileOutputStream(PrivilegedFileHelper.file("\\\\storm\\public\\file1.tmp"));
FileChannel fc1 = fout1.getChannel();
try
{
@@ -112,7 +112,7 @@
fc.close();
// print final content
- fin = new FileInputStream(f);
+ fin = PrivilegedFileHelper.fileInputStream(f);
fc = fin.getChannel();
res = -1;
@@ -134,8 +134,8 @@
final long timeout =
Long.valueOf(System.getProperty("exo.jcr.lab.testFileLockTimeout",
"20000"));
- // File f = new File("\\\\storm\\public\\file2.tmp");
- File f = new File("D:\\tmp\\file2.tmp");
+ // File f = PrivilegedFileHelper.file("\\\\storm\\public\\file2.tmp");
+ File f = PrivilegedFileHelper.file("D:\\tmp\\file2.tmp");
System.out.println("Try open file for write " +
System.currentTimeMillis());
FileOutputStream fout = PrivilegedFileHelper.fileOutputStream(f);
@@ -157,7 +157,7 @@
// reopen for read
Thread.sleep(timeout);
System.out.println("Try read file " + System.currentTimeMillis());
- FileInputStream fin = new FileInputStream(f);
+ FileInputStream fin = PrivilegedFileHelper.fileInputStream(f);
fc = fin.getChannel();
System.out.println("Try shared lock " + System.currentTimeMillis());
FileLock shlock = fc.lock(0, fc.size(), true);
@@ -196,7 +196,7 @@
// print final content
Thread.sleep(timeout);
System.out.println("Try read file " + System.currentTimeMillis());
- fin = new FileInputStream(f);
+ fin = PrivilegedFileHelper.fileInputStream(f);
fc = fin.getChannel();
System.out.println("Try shared lock " + System.currentTimeMillis());
shlock = fc.lock(0, fc.size(), true);
@@ -217,8 +217,8 @@
final long timeout =
Long.valueOf(System.getProperty("exo.jcr.lab.testFileLockTimeout",
"20000"));
- // File f = new File("\\\\storm\\public\\file3.tmp");
- File f = new File("D:\\tmp\\file3.tmp");
+ // File f = PrivilegedFileHelper.file("\\\\storm\\public\\file3.tmp");
+ File f = PrivilegedFileHelper.file("D:\\tmp\\file3.tmp");
// write new content
System.out.println("Try open file for write " +
System.currentTimeMillis());
@@ -238,7 +238,7 @@
// reopen for read
Thread.sleep(timeout);
System.out.println("Try read file " + System.currentTimeMillis());
- FileInputStream fin = new FileInputStream(f);
+ FileInputStream fin = PrivilegedFileHelper.fileInputStream(f);
fc = fin.getChannel();
System.out.println("Try shared lock " + System.currentTimeMillis());
FileLock shlock = fc.lock(0, fc.size(), true);
@@ -262,12 +262,12 @@
public void testInputStreamLock() throws IOException, InterruptedException
{
- // File f = new File("\\\\storm\\public\\file3.tmp");
- File f = new File("D:\\tmp\\file4.tmp");
+ // File f = PrivilegedFileHelper.file("\\\\storm\\public\\file3.tmp");
+ File f = PrivilegedFileHelper.file("D:\\tmp\\file4.tmp");
// write new content
System.out.println("Try open file for read " +
System.currentTimeMillis());
- FileInputStream fin = new FileInputStream(f);
+ FileInputStream fin = PrivilegedFileHelper.fileInputStream(f);
FileChannel fc = fin.getChannel();
System.out.println("Try lock file " + System.currentTimeMillis());
fin.read();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestBinaryValue.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestBinaryValue.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestBinaryValue.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.load.blob;
import org.exoplatform.services.jcr.JcrAPIBaseTest;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.FileInputStream;
import java.io.InputStream;
@@ -69,6 +70,7 @@
// -------------- TEST FILE ------------------
private static String TEST_FILE = null; // URL_SMALL_FILE
+ @Override
public void setUp() throws Exception
{
super.setUp();// .repository
@@ -96,7 +98,7 @@
Node localBigFile = testLocalBigFiles.addNode("bigFile" + i,
"nt:file");
Node contentNode = localBigFile.addNode("jcr:content",
"nt:resource");
// contentNode.setProperty("jcr:encoding", "UTF-8");
- InputStream is = new FileInputStream(TEST_FILE);
+ InputStream is = PrivilegedFileHelper.fileInputStream(TEST_FILE);
contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType", "application/octet-stream
");
is.close();
@@ -133,14 +135,14 @@
* "application/octet-stream ");
contentNode.setProperty("jcr:lastModified",
* Calendar.getInstance()); } session.save(); endTime = System.currentTimeMillis();
* log.info("Execution time after adding and saving: (local small)" +
((endTime - startTime) /
- * 1000) + "s"); // check streams //compareStream(new
FileInputStream(LOCAL_SMALL_FILE), //
+ * 1000) + "s"); // check streams
//compareStream(PrivilegedFileHelper.fileInputStream(LOCAL_SMALL_FILE), //
*
testLocalSmallFiles.getProperty("smallFile0/jcr:content/jcr:data").getStream());
} public void
* testRemoteBigFiles() throws Exception { Node testRemoteBigFiles =
* testBinaryValue.addNode("testRemoteBigFiles"); long startTime, endTime;
startTime =
* System.currentTimeMillis(); // to get the time of start for (int i = 0; i <
FILES_COUNT; i++) {
* Node remoteBigFile = testRemoteBigFiles.addNode("bigFile" + i,
"nt:file"); Node contentNode =
* remoteBigFile.addNode("jcr:content", "nt:resource");
//contentNode.setProperty("jcr:encoding",
- * "UTF-8"); contentNode.setProperty("jcr:data", new
FileInputStream(REMOTE_BIG_FILE));
+ * "UTF-8"); contentNode.setProperty("jcr:data",
PrivilegedFileHelper.fileInputStream(REMOTE_BIG_FILE));
* contentNode.setProperty("jcr:mimeType", "application/octet-stream
");
* contentNode.setProperty("jcr:lastModified", Calendar.getInstance()); }
session.save(); endTime
* = System.currentTimeMillis(); log.info("Execution time after adding and saving
(remote big):" +
@@ -157,7 +159,7 @@
* "application/octet-stream ");
contentNode.setProperty("jcr:lastModified",
* Calendar.getInstance()); } session.save(); endTime = System.currentTimeMillis();
* log.info("Execution time after adding and saving: (remote small)" +
((endTime - startTime) /
- * 1000) + "s"); // check streams compareStream(new
FileInputStream(LOCAL_SMALL_FILE),
+ * 1000) + "s"); // check streams
compareStream(PrivilegedFileHelper.fileInputStream(LOCAL_SMALL_FILE),
*
testRemoteSmallFiles.getProperty("smallFile0/jcr:content/jcr:data").getStream());
} public void
* testUrlBigFiles() throws Exception { Node testUrlBigFiles =
* testBinaryValue.addNode("testUrlBigFiles"); long startTime, endTime;
startTime =
@@ -181,6 +183,7 @@
* + "s"); }
*/
+ @Override
protected void tearDown() throws Exception
{
testBinaryValue.remove();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestBinaryValueMultiThreading.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestBinaryValueMultiThreading.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestBinaryValueMultiThreading.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -21,6 +21,7 @@
import org.exoplatform.services.jcr.JcrAPIBaseTest;
import org.exoplatform.services.jcr.core.CredentialsImpl;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.FileInputStream;
import java.util.ArrayList;
@@ -71,6 +72,7 @@
protected class TestJCRClient extends Thread
{
+ @Override
public void run()
{
log.info("Client started...");
@@ -92,13 +94,13 @@
{
// check streams
- compareStream(new FileInputStream(LOCAL_SMALL_FILE),
testLocalSmallFiles.getProperty(
+ compareStream(PrivilegedFileHelper.fileInputStream(LOCAL_SMALL_FILE),
testLocalSmallFiles.getProperty(
"smallFile" + i +
"/jcr:content/jcr:data").getStream());
- compareStream(new FileInputStream(LOCAL_BIG_FILE),
testLocalBigFiles.getProperty(
+ compareStream(PrivilegedFileHelper.fileInputStream(LOCAL_BIG_FILE),
testLocalBigFiles.getProperty(
"bigFile" + i +
"/jcr:content/jcr:data").getStream());
/*
- * compareStream(new FileInputStream(REMOTE_SMALL_FILE),
+ * compareStream(PrivilegedFileHelper.fileInputStream(REMOTE_SMALL_FILE),
* testRemoteSmallFiles.getProperty("smallFile" + i +
* "/jcr:content/jcr:data").getStream()); compareStream(new
* FileInputStream(REMOTE_BIG_FILE),
testRemoteBigFiles.getProperty("bigFile" + i +
@@ -129,7 +131,7 @@
{
Node localSmallFile = testLocalSmallFiles.addNode("smallFile" + i,
"nt:file");
Node contentNode = localSmallFile.addNode("jcr:content",
"nt:resource");
- contentNode.setProperty("jcr:data", new
FileInputStream(LOCAL_SMALL_FILE));
+ contentNode.setProperty("jcr:data",
PrivilegedFileHelper.fileInputStream(LOCAL_SMALL_FILE));
contentNode.setProperty("jcr:mimeType",
"application/octet-stream");
contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
}
@@ -145,7 +147,7 @@
{
Node localBigFile = testLocalBigFiles.addNode("bigFile" + i,
"nt:file");
Node contentNode = localBigFile.addNode("jcr:content",
"nt:resource");
- contentNode.setProperty("jcr:data", new
FileInputStream(LOCAL_BIG_FILE));
+ contentNode.setProperty("jcr:data",
PrivilegedFileHelper.fileInputStream(LOCAL_BIG_FILE));
contentNode.setProperty("jcr:mimeType",
"application/octet-stream");
contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
}
@@ -155,13 +157,13 @@
* Node testRemoteSmallFiles = root.addNode("testRemoteSmallFiles"); for
(int i = 0; i <
* FILES_COUNT; i++) { Node remoteSmallFile =
testRemoteSmallFiles.addNode("smallFile" + i,
* "nt:file"); Node contentNode =
remoteSmallFile.addNode("jcr:content", "nt:resource");
- * contentNode.setProperty("jcr:data", new
FileInputStream(REMOTE_SMALL_FILE));
+ * contentNode.setProperty("jcr:data",
PrivilegedFileHelper.fileInputStream(REMOTE_SMALL_FILE));
* contentNode.setProperty("jcr:mimeType", "application/octet-stream
");
* contentNode.setProperty("jcr:lastModified", Calendar.getInstance()); }
//Remote big files
* Node testRemoteBigFiles = root.addNode("testRemoteBigFiles"); for (int
i = 0; i <
* FILES_COUNT; i++) { Node remoteBigFile =
testRemoteBigFiles.addNode("bigFile" + i,
* "nt:file"); Node contentNode =
remoteBigFile.addNode("jcr:content", "nt:resource");
- * contentNode.setProperty("jcr:data", new
FileInputStream(REMOTE_BIG_FILE));
+ * contentNode.setProperty("jcr:data",
PrivilegedFileHelper.fileInputStream(REMOTE_BIG_FILE));
* contentNode.setProperty("jcr:mimeType", "application/octet-stream
");
* contentNode.setProperty("jcr:lastModified", Calendar.getInstance()); }
//Url small files Node
* testUrlSmallFiles = root.addNode("testUrlSmallFiles"); for (int i = 0;
i < FILES_COUNT; i++)
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestConcurrentItems.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestConcurrentItems.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestConcurrentItems.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -20,6 +20,7 @@
import org.exoplatform.services.jcr.JcrAPIBaseTest;
import org.exoplatform.services.jcr.impl.core.PropertyImpl;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.jcr.load.blob.thread.CreateThread;
import org.exoplatform.services.jcr.load.blob.thread.DeleteThread;
import org.exoplatform.services.jcr.load.blob.thread.NtFileCreatorThread;
@@ -74,6 +75,7 @@
private File testFile = null;
+ @Override
public void setUp() throws Exception
{
super.setUp();
@@ -95,7 +97,7 @@
byte[] buff = new byte[1024 * 4];
int read = 0;
// InputStream dataStream = new URL(TEST_FILE).openStream();
- InputStream dataStream = new FileInputStream(TEST_FILE);
+ InputStream dataStream = PrivilegedFileHelper.fileInputStream(TEST_FILE);
while ((read = dataStream.read(buff)) >= 0)
{
dataSize += read;
@@ -140,7 +142,7 @@
Node testRoot = csession.getRootNode().getNode(TestConcurrentItems.TEST_ROOT);
Node ntFile = testRoot.addNode(nodeName, "nt:file");
Node contentNode = ntFile.addNode("jcr:content",
"nt:resource");
- dataStream = new FileInputStream(TestConcurrentItems.TEST_FILE);
+ dataStream =
PrivilegedFileHelper.fileInputStream(TestConcurrentItems.TEST_FILE);
PropertyImpl data = (PropertyImpl)contentNode.setProperty("jcr:data",
dataStream);
contentNode.setProperty("jcr:mimeType", "video/avi");
contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
@@ -248,12 +250,14 @@
for (int i = 0; i < 5; i++)
{
ReadThread readed =
- new ReadThread(repository.login(
- this.credentials /*
-
* session.getCredentials(
-
* )
-
*/,
- "ws1"));
+ new ReadThread(
+ repository
+ .login(
+ this.credentials /*
+
* session.getCredentials(
+
* )
+
*/,
+ "ws1"));
readed.start();
readers.add(readed);
try
@@ -268,9 +272,9 @@
log.info("Begin cleaner...");
DeleteThread cleaner = new DeleteThread(repository.login(this.credentials /*
-
* session.getCredentials
-
* ()
-
*/, "ws1"));
+
* session.getCredentials
+
* ()
+
*/, "ws1"));
cleaner.start();
log.info("<<<<<<<<<<<<<<<<<<<<
Wait cycle
>>>>>>>>>>>>>>>>>>>>>");
@@ -411,6 +415,7 @@
Thread waiter = new Thread()
{
+ @Override
public void run()
{
try
@@ -448,7 +453,7 @@
Node testRoot = csession.getRootNode().getNode(TestConcurrentItems.TEST_ROOT);
Node ntFile = testRoot.addNode(nodeName, "nt:file");
Node contentNode = ntFile.addNode("jcr:content",
"nt:resource");
- dataStream = new FileInputStream(TEST_FILE);
+ dataStream = PrivilegedFileHelper.fileInputStream(TEST_FILE);
PropertyImpl data = (PropertyImpl)contentNode.setProperty("jcr:data",
dataStream);
contentNode.setProperty("jcr:mimeType", "video/avi");
contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestExportBigFiles.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestExportBigFiles.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestExportBigFiles.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -58,7 +58,7 @@
Node localBigFile = testLocalBigFiles.addNode("bigFile" + 1,
"nt:file");
Node contentNode = localBigFile.addNode("jcr:content",
"nt:resource");
// contentNode.setProperty("jcr:encoding", "UTF-8");
- InputStream is = new FileInputStream(TEST_FILE);
+ InputStream is = PrivilegedFileHelper.fileInputStream(TEST_FILE);
contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType", "application/octet-stream
");
is.close();
@@ -84,7 +84,7 @@
testLocalBigFiles.remove();
session.save();
- BufferedInputStream bufferedInputStream = new BufferedInputStream(new
FileInputStream(file));
+ BufferedInputStream bufferedInputStream = new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(file));
// importing content
session.importXML(root.getPath(), bufferedInputStream,
ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
@@ -96,7 +96,7 @@
Node content = lbf.getNode("jcr:content");
// comparing with source file
- compareStream(new BufferedInputStream(new FileInputStream(TEST_FILE)),
content.getProperty("jcr:data")
+ compareStream(new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(TEST_FILE)),
content.getProperty("jcr:data")
.getStream());
n1.remove();
@@ -122,7 +122,7 @@
Node localBigFile = testLocalBigFiles.addNode("bigFile" + 1,
"nt:file");
Node contentNode = localBigFile.addNode("jcr:content",
"nt:resource");
// contentNode.setProperty("jcr:encoding", "UTF-8");
- InputStream is = new FileInputStream(TEST_FILE2);
+ InputStream is = PrivilegedFileHelper.fileInputStream(TEST_FILE2);
contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType", "application/octet-stream
");
is.close();
@@ -148,7 +148,7 @@
testLocalBigFiles.remove();
session.save();
- BufferedInputStream bufferedInputStream = new BufferedInputStream(new
FileInputStream(file));
+ BufferedInputStream bufferedInputStream = new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(file));
// importing content
session.importXML(root.getPath(), bufferedInputStream,
ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
@@ -160,7 +160,7 @@
Node content = lbf.getNode("jcr:content");
// comparing with source file
- compareStream(new BufferedInputStream(new FileInputStream(TEST_FILE2)),
content.getProperty("jcr:data")
+ compareStream(new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(TEST_FILE2)),
content.getProperty("jcr:data")
.getStream());
n1.remove();
@@ -182,7 +182,7 @@
Node localBigFile = testLocalBigFiles.addNode("bigFile" + 1,
"nt:file");
Node contentNode = localBigFile.addNode("jcr:content",
"nt:resource");
// contentNode.setProperty("jcr:encoding", "UTF-8");
- InputStream is = new FileInputStream(TEST_FILE);
+ InputStream is = PrivilegedFileHelper.fileInputStream(TEST_FILE);
contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType", "application/octet-stream
");
is.close();
@@ -208,7 +208,7 @@
testLocalBigFiles.remove();
session.save();
- BufferedInputStream bufferedInputStream = new BufferedInputStream(new
FileInputStream(file));
+ BufferedInputStream bufferedInputStream = new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(file));
// importing content
session.importXML(root.getPath(), bufferedInputStream,
ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
@@ -220,7 +220,7 @@
Node content = lbf.getNode("jcr:content");
// comparing with source file
- compareStream(new BufferedInputStream(new FileInputStream(TEST_FILE)),
content.getProperty("jcr:data")
+ compareStream(new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(TEST_FILE)),
content.getProperty("jcr:data")
.getStream());
n1.remove();
@@ -251,7 +251,7 @@
Node localBigFile = testLocalBigFiles.addNode("bigFile" + i,
"nt:file");
Node contentNode = localBigFile.addNode("jcr:content",
"nt:resource");
// contentNode.setProperty("jcr:encoding", "UTF-8");
- InputStream is = new FileInputStream(TEST_FILE);
+ InputStream is = PrivilegedFileHelper.fileInputStream(TEST_FILE);
contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType", "application/octet-stream
");
is.close();
@@ -278,7 +278,7 @@
testLocalBigFiles.remove();
session.save();
- BufferedInputStream bufferedInputStream = new BufferedInputStream(new
FileInputStream(file));
+ BufferedInputStream bufferedInputStream = new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(file));
// importing content
session.importXML(root.getPath(), bufferedInputStream,
ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
@@ -292,7 +292,7 @@
Node lbf = n1.getNode("bigFile" + i);
Node content = lbf.getNode("jcr:content");
// comparing with source file
- compareStream(new BufferedInputStream(new FileInputStream(TEST_FILE)),
content.getProperty("jcr:data")
+ compareStream(new
BufferedInputStream(PrivilegedFileHelper.fileInputStream(TEST_FILE)),
content.getProperty("jcr:data")
.getStream());
}
n1.remove();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestLoadRepo.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestLoadRepo.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestLoadRepo.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -60,7 +60,7 @@
public void _testExport() throws Exception
{
Node testNode = root.addNode("testNode");
- File checkSummValue = new File(System.getProperty("java.io.tmpdir"),
"repo.ssh1");
+ File checkSummValue =
PrivilegedFileHelper.file(System.getProperty("java.io.tmpdir"),
"repo.ssh1");
BufferedOutputStream sshStrream = new
BufferedOutputStream(PrivilegedFileHelper.fileOutputStream(checkSummValue));
RandomValueNodeGenerator nodeGenerator =
new RandomValueNodeGenerator(session.getValueFactory(), 6, 5, 8, 5, 1024 *
1024);
@@ -70,7 +70,7 @@
ValueSsh1Generator ssh1Generator = new
ValueSsh1Generator(session.getTransientNodesManager(), sshStrream);
((NodeImpl)testNode).getData().accept(ssh1Generator);
sshStrream.close();
- File exportFile = new File(System.getProperty("java.io.tmpdir"),
"testExport.xml");
+ File exportFile =
PrivilegedFileHelper.file(System.getProperty("java.io.tmpdir"),
"testExport.xml");
OutputStream os = PrivilegedFileHelper.fileOutputStream(exportFile);
session.exportSystemView(testNode.getPath(), os, false, false);
os.close();
@@ -85,16 +85,16 @@
ConstraintViolationException, LockException, RepositoryException, IOException,
NoSuchAlgorithmException
{
- File importFile = new File(System.getProperty("java.io.tmpdir"),
"testExport.xml");
- InputStream is = new FileInputStream(importFile);
+ File importFile =
PrivilegedFileHelper.file(System.getProperty("java.io.tmpdir"),
"testExport.xml");
+ InputStream is = PrivilegedFileHelper.fileInputStream(importFile);
session.getWorkspace().getNamespaceRegistry().registerNamespace("exojcrtest_old",
"http://www.exoplatform.org/jcr/exojcrtest");
session.importXML(root.getPath(), is,
ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
session.save();
- File ssh1File = new File(System.getProperty("java.io.tmpdir"),
"repo.ssh1");
- InputStream isSSH1 = new FileInputStream(ssh1File);
+ File ssh1File =
PrivilegedFileHelper.file(System.getProperty("java.io.tmpdir"),
"repo.ssh1");
+ InputStream isSSH1 = PrivilegedFileHelper.fileInputStream(ssh1File);
ValueSsh1Comparator ssh1Comparator = new
ValueSsh1Comparator(session.getTransientNodesManager(), isSSH1);
((NodeImpl)root.getNode("testNode")).getData().accept(ssh1Comparator);
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestMoveBinaryValue.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestMoveBinaryValue.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestMoveBinaryValue.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.load.blob;
import org.exoplatform.services.jcr.JcrAPIBaseTest;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.FileInputStream;
import java.io.InputStream;
@@ -43,6 +44,7 @@
// -------------- TEST FILE ------------------
private static String TEST_FILE = null; // URL_SMALL_FILE
+ @Override
public void setUp() throws Exception
{
super.setUp();
@@ -64,7 +66,7 @@
Node localBigFile = testLocalBigFiles.addNode("bigFile" + i,
"nt:file");
Node contentNode = localBigFile.addNode("jcr:content",
"nt:resource");
// contentNode.setProperty("jcr:encoding", "UTF-8");
- InputStream is = new FileInputStream(TEST_FILE);
+ InputStream is = PrivilegedFileHelper.fileInputStream(TEST_FILE);
contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType", "application/octet-stream
");
is.close();
@@ -94,6 +96,7 @@
}
}
+ @Override
protected void tearDown() throws Exception
{
testBinaryValue.remove();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestMoveBinaryValue1.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestMoveBinaryValue1.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestMoveBinaryValue1.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.load.blob;
import org.exoplatform.services.jcr.JcrAPIBaseTest;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.FileInputStream;
import java.io.InputStream;
@@ -41,6 +42,7 @@
// -------------- TEST FILE ------------------
private static String TEST_FILE = null; // URL_SMALL_FILE
+ @Override
public void setUp() throws Exception
{
super.setUp();
@@ -62,7 +64,7 @@
Node localBigFile = testLocalBigFiles.addNode("bigFile" + i,
"nt:file");
Node contentNode = localBigFile.addNode("jcr:content",
"nt:resource");
// contentNode.setProperty("jcr:encoding", "UTF-8");
- InputStream is = new FileInputStream(TEST_FILE);
+ InputStream is = PrivilegedFileHelper.fileInputStream(TEST_FILE);
contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType", "application/octet-stream
");
is.close();
@@ -106,7 +108,7 @@
Node localBigFile = testLocalBigFiles.addNode("bigFile" + i,
"nt:file");
Node contentNode = localBigFile.addNode("jcr:content",
"nt:resource");
// contentNode.setProperty("jcr:encoding", "UTF-8");
- InputStream is = new FileInputStream(TEST_FILE);
+ InputStream is = PrivilegedFileHelper.fileInputStream(TEST_FILE);
contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType", "application/octet-stream
");
is.close();
@@ -139,6 +141,7 @@
}
}
+ @Override
protected void tearDown() throws Exception
{
testBinaryValue.remove();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/thread/CreateThread.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/thread/CreateThread.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/thread/CreateThread.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.load.blob.thread;
import org.exoplatform.services.jcr.impl.core.PropertyImpl;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.jcr.load.blob.TestConcurrentItems;
import org.exoplatform.services.jcr.util.IdGenerator;
@@ -46,6 +47,7 @@
super(threadSession);
}
+ @Override
public void testAction()
{
while (process)
@@ -73,7 +75,7 @@
Node ntFile = testRoot.addNode(nodeName, "nt:file");
Node contentNode = ntFile.addNode("jcr:content",
"nt:resource");
// dataStream = new URL(TestSwap.URL_BIG_MEDIA_FILE).openStream();
- dataStream = new FileInputStream(TestConcurrentItems.TEST_FILE);
+ dataStream =
PrivilegedFileHelper.fileInputStream(TestConcurrentItems.TEST_FILE);
PropertyImpl data = (PropertyImpl)contentNode.setProperty("jcr:data",
dataStream);
contentNode.setProperty("jcr:mimeType", "video/avi");
contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/thread/NtFileCreatorThread.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/thread/NtFileCreatorThread.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/thread/NtFileCreatorThread.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.load.blob.thread;
import org.exoplatform.services.jcr.impl.core.PropertyImpl;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.jcr.load.blob.TestConcurrentItems;
import org.exoplatform.services.jcr.util.IdGenerator;
@@ -48,6 +49,7 @@
this.testRootName = testRootName;
}
+ @Override
public void testAction()
{
while (process)
@@ -76,7 +78,7 @@
Node ntFile = testRoot.addNode(nodeName, "nt:file");
Node contentNode = ntFile.addNode("jcr:content",
"nt:resource");
// dataStream = new URL(TestSwap.URL_BIG_MEDIA_FILE).openStream();
- dataStream = new FileInputStream(TestConcurrentItems.TEST_FILE);
+ dataStream =
PrivilegedFileHelper.fileInputStream(TestConcurrentItems.TEST_FILE);
PropertyImpl data = (PropertyImpl)contentNode.setProperty("jcr:data",
dataStream);
contentNode.setProperty("jcr:mimeType", "video/avi");
contentNode.setProperty("jcr:lastModified", Calendar.getInstance());
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/dataflow/persistent/TestGetNodesConcurrentModification.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/dataflow/persistent/TestGetNodesConcurrentModification.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/dataflow/persistent/TestGetNodesConcurrentModification.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -22,6 +22,7 @@
import org.exoplatform.services.jcr.JcrImplBaseTest;
import org.exoplatform.services.jcr.impl.core.NodeImpl;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.File;
import java.io.IOException;
@@ -164,7 +165,8 @@
super.setUp();
fails = new ArrayList<String>();
- contentFile = new URL("file:///" + new
File("src/test/resources/index/test_index.doc").getAbsolutePath());
+ contentFile =
+ new URL("file:///" +
PrivilegedFileHelper.file("src/test/resources/index/test_index.doc").getAbsolutePath());
initDB();
}
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestBulkItemsAdd.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestBulkItemsAdd.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestBulkItemsAdd.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -26,6 +26,7 @@
import javax.jcr.Node;
import org.exoplatform.services.jcr.JcrAPIBaseTest;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
/**
* Created by The eXo Platform SAS Author : Peter Nedonosko
peter.nedonosko(a)exoplatform.com.ua
@@ -74,7 +75,7 @@
log.info("Nodes saved " + nodesCount + ", " +
(System.currentTimeMillis() - startTime) + "ms");
// save stats
- PrintWriter statFile = new PrintWriter(new File("stats.txt"));
+ PrintWriter statFile = new
PrintWriter(PrivilegedFileHelper.file("stats.txt"));
statFile.write(stats.toString());
statFile.close();
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestPerformance.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestPerformance.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestPerformance.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.load.perf;
import org.exoplatform.services.jcr.JcrAPIBaseTest;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.jcr.util.IdGenerator;
import java.io.FileInputStream;
@@ -45,6 +46,7 @@
private static String TEST_FILE = null;
+ @Override
public void setUp() throws Exception
{
super.setUp();
@@ -65,6 +67,7 @@
}
}
+ @Override
public void tearDown() throws Exception
{
}
@@ -437,7 +440,7 @@
Node cool = testAddNtFilePlusNtResource.addNode(name, "nt:file");
Node contentNode = cool.addNode("jcr:content",
"nt:resource");
contentNode.setProperty("jcr:encoding", "UTF-8");
- InputStream is = new FileInputStream(TEST_FILE);
+ InputStream is = PrivilegedFileHelper.fileInputStream(TEST_FILE);
contentNode.setProperty("jcr:data", is);
contentNode.setProperty("jcr:mimeType", "text/plain");
contentNode.setProperty("jcr:lastModified",
session.getValueFactory().createValue(Calendar.getInstance()));
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/storage/fs/TestFSReadWrite.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/storage/fs/TestFSReadWrite.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/storage/fs/TestFSReadWrite.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -111,7 +111,7 @@
{
super.setUp();
- testRoot = new File("target/fstest");
+ testRoot = PrivilegedFileHelper.file("target/fstest");
testRoot.mkdirs();
testRoot.deleteOnExit();
}
@@ -137,7 +137,7 @@
for (File f : filesList)
{
f.delete();
- deleteFileParent(new File(f.getParent()));
+ deleteFileParent(PrivilegedFileHelper.file(f.getParent()));
}
}
@@ -151,7 +151,7 @@
{
// log.info("del " + fp.getAbsolutePath());
fp.delete();
- deleteFileParent(new File(fp.getParent()));
+ deleteFileParent(PrivilegedFileHelper.file(fp.getParent()));
}
}
else
@@ -168,7 +168,7 @@
}
for (String fn : ls)
{
- File f = new File(dir.getAbsolutePath() + File.separator + fn);
+ File f = PrivilegedFileHelper.file(dir.getAbsolutePath() + File.separator +
fn);
if (f.isDirectory())
{
deleteDir(f);
@@ -184,7 +184,7 @@
List<File> files = new ArrayList<File>();
for (int i = 0; i < FILES_COUNT; i++)
{
- File f = new File(testRoot.getAbsolutePath() + File.separator +
SIDGenerator.generate());
+ File f = PrivilegedFileHelper.file(testRoot.getAbsolutePath() + File.separator +
SIDGenerator.generate());
try
{
// f.createNewFile();
@@ -213,9 +213,9 @@
for (int i = 0; i < FILES_COUNT; i++)
{
String fileName = SIDGenerator.generate();
- File dir = new File(testRoot.getAbsolutePath() + buildPathX(fileName));
+ File dir = PrivilegedFileHelper.file(testRoot.getAbsolutePath() +
buildPathX(fileName));
dir.mkdirs();
- File f = new File(dir.getAbsolutePath() + File.separator + fileName);
+ File f = PrivilegedFileHelper.file(dir.getAbsolutePath() + File.separator +
fileName);
try
{
// f.createNewFile();
@@ -255,9 +255,9 @@
for (int i = 0; i < FILES_COUNT; i++)
{
String fileName = SIDGenerator.generate();
- File dir = new File(testRoot.getAbsolutePath() + buildPathXX(fileName));
+ File dir = PrivilegedFileHelper.file(testRoot.getAbsolutePath() +
buildPathXX(fileName));
dir.mkdirs();
- File f = new File(dir.getAbsolutePath() + File.separator + fileName);
+ File f = PrivilegedFileHelper.file(dir.getAbsolutePath() + File.separator +
fileName);
try
{
// f.createNewFile();
@@ -301,9 +301,9 @@
String fileName = SIDGenerator.generate();
String prefix = fileName.substring(0, 24); // time + addr hash prefix
String rnd = fileName.substring(24); // random name
- File dir = new File(testRoot.getAbsolutePath() + File.separator + prefix +
File.separator + buildPathX(rnd));
+ File dir = PrivilegedFileHelper.file(testRoot.getAbsolutePath() + File.separator
+ prefix + File.separator + buildPathX(rnd));
dir.mkdirs();
- File f = new File(dir.getAbsolutePath() + File.separator + fileName);
+ File f = PrivilegedFileHelper.file(dir.getAbsolutePath() + File.separator +
fileName);
try
{
// f.createNewFile();
@@ -345,9 +345,9 @@
for (int i = 0; i < FILES_COUNT; i++)
{
String fileName = SIDGenerator.generate();
- File dir = new File(testRoot.getAbsolutePath() + File.separator +
buildPathX8(fileName));
+ File dir = PrivilegedFileHelper.file(testRoot.getAbsolutePath() + File.separator
+ buildPathX8(fileName));
dir.mkdirs();
- File f = new File(dir.getAbsolutePath() + File.separator + fileName);
+ File f = PrivilegedFileHelper.file(dir.getAbsolutePath() + File.separator +
fileName);
try
{
FileOutputStream fos = PrivilegedFileHelper.fileOutputStream(f);
@@ -382,7 +382,7 @@
String[] ls = filter != null ? root.list(filter) : root.list();
for (String file : ls)
{
- File f = new File(testRoot.getAbsolutePath() + File.separator + file);
+ File f = PrivilegedFileHelper.file(testRoot.getAbsolutePath() + File.separator +
file);
if (f.isDirectory())
{
// dir
@@ -393,7 +393,7 @@
// file
try
{
- FileInputStream fis = new FileInputStream(f);
+ FileInputStream fis = PrivilegedFileHelper.fileInputStream(f);
fis.close();
}
catch (FileNotFoundException e)
@@ -418,7 +418,7 @@
protected void readTreeXFiles(File root, NameFilter filter)
{
String dirPath = root.getAbsolutePath() + buildPathX(filter.getName());
- File dir = new File(dirPath);
+ File dir = PrivilegedFileHelper.file(dirPath);
String[] ls = filter != null ? dir.list(filter) : dir.list();
if (ls == null)
{
@@ -428,7 +428,7 @@
for (String file : ls)
{
- File f = new File(dir.getAbsolutePath() + File.separator + file);
+ File f = PrivilegedFileHelper.file(dir.getAbsolutePath() + File.separator +
file);
if (f.isDirectory())
{
// dir
@@ -439,7 +439,7 @@
// file
try
{
- FileInputStream fis = new FileInputStream(f);
+ FileInputStream fis = PrivilegedFileHelper.fileInputStream(f);
fis.close();
}
catch (FileNotFoundException e)
@@ -457,7 +457,7 @@
protected void readTreeX8Files(File root, NameFilter filter)
{
String dirPath = root.getAbsolutePath() + buildPathX8(filter.getName());
- File dir = new File(dirPath);
+ File dir = PrivilegedFileHelper.file(dirPath);
String[] ls = filter != null ? dir.list(filter) : dir.list();
if (ls == null)
{
@@ -467,7 +467,7 @@
for (String file : ls)
{
- File f = new File(dir.getAbsolutePath() + File.separator + file);
+ File f = PrivilegedFileHelper.file(dir.getAbsolutePath() + File.separator +
file);
if (f.isDirectory())
{
// dir
@@ -478,7 +478,7 @@
// file
try
{
- FileInputStream fis = new FileInputStream(f);
+ FileInputStream fis = PrivilegedFileHelper.fileInputStream(f);
fis.close();
}
catch (FileNotFoundException e)
@@ -501,7 +501,7 @@
protected void readTreeXXFiles(File root, NameFilter filter)
{
String dirPath = root.getAbsolutePath() + buildPathXX(filter.getName());
- File dir = new File(dirPath);
+ File dir = PrivilegedFileHelper.file(dirPath);
String[] ls = filter != null ? dir.list(filter) : dir.list();
if (ls == null)
{
@@ -511,7 +511,7 @@
for (String file : ls)
{
- File f = new File(dir.getAbsolutePath() + File.separator + file);
+ File f = PrivilegedFileHelper.file(dir.getAbsolutePath() + File.separator +
file);
if (f.isDirectory())
{
// dir
@@ -522,7 +522,7 @@
// file
try
{
- FileInputStream fis = new FileInputStream(f);
+ FileInputStream fis = PrivilegedFileHelper.fileInputStream(f);
fis.close();
}
catch (FileNotFoundException e)
@@ -547,7 +547,7 @@
String fileName = filter.getName();
String prefix = fileName.substring(0, 24); // time + addr hash prefix
String rnd = fileName.substring(24); // random name
- File dir = new File(testRoot.getAbsolutePath() + File.separator + prefix +
File.separator + buildPathX(rnd));
+ File dir = PrivilegedFileHelper.file(testRoot.getAbsolutePath() + File.separator +
prefix + File.separator + buildPathX(rnd));
String[] ls = filter != null ? dir.list(filter) : dir.list();
if (ls == null)
{
@@ -557,7 +557,7 @@
for (String file : ls)
{
- File f = new File(dir.getAbsolutePath() + File.separator + file);
+ File f = PrivilegedFileHelper.file(dir.getAbsolutePath() + File.separator +
file);
if (f.isDirectory())
{
// dir
@@ -568,7 +568,7 @@
// file
try
{
- FileInputStream fis = new FileInputStream(f);
+ FileInputStream fis = PrivilegedFileHelper.fileInputStream(f);
fis.close();
}
catch (FileNotFoundException e)
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/RemoveVDTest.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/RemoveVDTest.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/RemoveVDTest.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -68,7 +68,7 @@
vd = null;
// read first time
- ObjectReader or = new ObjectReaderImpl(new FileInputStream(serf));
+ ObjectReader or = new
ObjectReaderImpl(PrivilegedFileHelper.fileInputStream(serf));
FilePersistedValueData vd1 = null;
@@ -87,7 +87,7 @@
((StreamPersistedValueData)vd1).setPersistedFile(((StreamPersistedValueData)vd1).getTempFile());
// read second time
- or = new ObjectReaderImpl(new FileInputStream(serf));
+ or = new ObjectReaderImpl(PrivilegedFileHelper.fileInputStream(serf));
FilePersistedValueData vd2 = null;
try
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/TestRollbackBigFiles.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/TestRollbackBigFiles.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/TestRollbackBigFiles.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -34,6 +34,7 @@
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.jcr.util.IdGenerator;
import java.io.File;
@@ -83,7 +84,7 @@
File f = this.createBLOBTempFile(1024);
TransientPropertyData newProperty =
new TransientPropertyData(propPath.getInternalPath(), IdGenerator.generate(),
-1, PropertyType.BINARY, newNode
- .getIdentifier(), false, new TransientValueData(new FileInputStream(f)));
+ .getIdentifier(), false, new
TransientValueData(PrivilegedFileHelper.fileInputStream(f)));
list.add(new ItemState(newProperty, ItemState.ADDED, false, parent.getQPath()));
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/common/TestExportImportAmongSessions.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/common/TestExportImportAmongSessions.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/common/TestExportImportAmongSessions.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -75,7 +75,7 @@
try
{
- session1.importXML("/", new FileInputStream(outputFile),
ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
+ session1.importXML("/",
PrivilegedFileHelper.fileInputStream(outputFile),
ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
session1.save();
testNode = session1.getRootNode().getNode(TEST_NODE);
@@ -124,7 +124,7 @@
try
{
- session1.importXML("/", new FileInputStream(outputFile),
ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
+ session1.importXML("/",
PrivilegedFileHelper.fileInputStream(outputFile),
ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
testNode = session1.getRootNode().getNode(TEST_NODE);
ntFile = testNode.getNode(TEST_NTFILE);
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/export/ExportWorkspaceSystemViewTest.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/export/ExportWorkspaceSystemViewTest.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/export/ExportWorkspaceSystemViewTest.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -56,7 +56,7 @@
sessionWS1.save();
// 1-st export
- File f1 = new File("target/1.xml");
+ File f1 = PrivilegedFileHelper.file("target/1.xml");
sessionWS1.exportWorkspaceSystemView(PrivilegedFileHelper.fileOutputStream(f1),
false, false);
// 1-st import
@@ -77,7 +77,7 @@
{
// 2-st export
SessionImpl back1 = (SessionImpl)repository.login(credentials,
"ws1_restore_1");
- File f2 = new File("target/2.xml");
+ File f2 = PrivilegedFileHelper.file("target/2.xml");
back1.exportWorkspaceSystemView(PrivilegedFileHelper.fileOutputStream(f2),
false, false);
// 2-st import
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/version/FileRestoreTest.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/version/FileRestoreTest.java 2010-06-14
07:38:11 UTC (rev 2563)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/version/FileRestoreTest.java 2010-06-14
08:17:58 UTC (rev 2564)
@@ -76,7 +76,7 @@
Node file = root.addNode("nt_file_node", "nt:file");
Node contentNode = file.addNode("jcr:content", "nt:resource");
- contentNode.setProperty("jcr:data", new FileInputStream(tempFile));
+ contentNode.setProperty("jcr:data",
PrivilegedFileHelper.fileInputStream(tempFile));
contentNode.setProperty("jcr:mimeType", "text/plain");
contentNode.setProperty("jcr:lastModified",
session.getValueFactory().createValue(Calendar.getInstance()));
file.addMixin("mix:versionable");
@@ -86,37 +86,37 @@
file.checkin(); // v1
file.checkout(); //
file.getNode("jcr:content").getProperty("jcr:data").getStream()
- file.getNode("jcr:content").setProperty("jcr:data", new
FileInputStream(tempFile2));
+ file.getNode("jcr:content").setProperty("jcr:data",
PrivilegedFileHelper.fileInputStream(tempFile2));
session.save();
log
.info("ADD VERSION #2 : file size = " +
contentNode.getProperty("jcr:data").getStream().available() + "
bytes");
- compareStream(new FileInputStream(tempFile2),
contentNode.getProperty("jcr:data").getStream());
+ compareStream(PrivilegedFileHelper.fileInputStream(tempFile2),
contentNode.getProperty("jcr:data").getStream());
file.checkin(); // v2
file.checkout();
- file.getNode("jcr:content").setProperty("jcr:data", new
FileInputStream(tempFile3));
+ file.getNode("jcr:content").setProperty("jcr:data",
PrivilegedFileHelper.fileInputStream(tempFile3));
session.save();
log
.info("ADD VERSION #3 : file size = " +
contentNode.getProperty("jcr:data").getStream().available() + "
bytes");
- compareStream(new FileInputStream(tempFile3),
contentNode.getProperty("jcr:data").getStream());
+ compareStream(PrivilegedFileHelper.fileInputStream(tempFile3),
contentNode.getProperty("jcr:data").getStream());
// restore version v2
Version v2 = file.getBaseVersion();
file.restore(v2, true);
- compareStream(new FileInputStream(tempFile2),
contentNode.getProperty("jcr:data").getStream());
+ compareStream(PrivilegedFileHelper.fileInputStream(tempFile2),
contentNode.getProperty("jcr:data").getStream());
// restore version v1
Version v1 = file.getBaseVersion().getPredecessors()[0];
file.restore(v1, true); // HERE
- compareStream(new FileInputStream(tempFile),
contentNode.getProperty("jcr:data").getStream());
+ compareStream(PrivilegedFileHelper.fileInputStream(tempFile),
contentNode.getProperty("jcr:data").getStream());
// restore version v2 again
file.restore(v2, true);
- compareStream(new FileInputStream(tempFile2),
file.getNode("jcr:content").getProperty("jcr:data").getStream());
+ compareStream(PrivilegedFileHelper.fileInputStream(tempFile2),
file.getNode("jcr:content").getProperty("jcr:data").getStream());
}
}