Author: tolusha
Date: 2010-06-14 06:52:13 -0400 (Mon, 14 Jun 2010)
New Revision: 2570
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/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/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/CleanableFilePersistedValueData.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/PersistedValueDataReader.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/FileValueStorage.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/TreeFileIOChannel.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFileValueStorage.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/storage/value/fs/operations/WriteValue.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/FileCleaner.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/util/io/SwapFile.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/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/directory/DirectoryManagerTest.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/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/TestWorkspaceManagement.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/TestExcelFileSearch.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/lucene/TestErrorLog.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/storage/ValueStoragePluginTest.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/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/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/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/dataflow/persistent/TestGetNodesConcurrentModification.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
Log:
EXOJCR-756: replace file operations on privileged file operations
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/RepositoryServiceConfigurationImpl.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -173,8 +173,9 @@
File sourceConfig = new File(filePath.toURI());
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmm");
File backUp = new File(sourceConfig.getAbsoluteFile() + "_" +
format.format(new Date()));
- if (!sourceConfig.renameTo(backUp))
- throw new RepositoryException("Can't back up configuration on
path " + sourceConfig.getAbsolutePath());
+ if (!PrivilegedFileHelper.renameTo(sourceConfig, backUp))
+ throw new RepositoryException("Can't back up configuration on
path "
+ + PrivilegedFileHelper.getAbsolutePath(sourceConfig));
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/BackupWorkspaceInitializer.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -314,7 +314,7 @@
{
Matcher m = p.matcher(f.getName());
if (m.matches())
- return f.getAbsolutePath();
+ return PrivilegedFileHelper.getAbsolutePath(f);
}
return null;
@@ -450,8 +450,8 @@
(TransientValueData)(propertyData.getValues().get(listFixupStream.get(i).getValueDataId()));
// re-init the value
- tvd.delegate(new TransientValueData(tvd.getOrderNumber(), null, null, new
SpoolFile(listFile.get(i)
- .getAbsolutePath()), fileCleaner, -1, null, true));
+ tvd.delegate(new TransientValueData(tvd.getOrderNumber(), null, null, new
SpoolFile(PrivilegedFileHelper
+ .getAbsolutePath(listFile.get(i))), fileCleaner, -1, null, true));
}
for (int i = 0; i < listFile.size(); i++)
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -783,7 +783,8 @@
{
vdata =
new
TransientValueData(currentProperty.getValues().size(), null, null,
- new SpoolFile(pfile.getAbsolutePath()),
fileCleaner, maxBufferSize, null, true);
+ new
SpoolFile(PrivilegedFileHelper.getAbsolutePath(pfile)), fileCleaner,
+ maxBufferSize, null, true);
}
else
{
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/FileSystemLockPersister.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -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;
@@ -119,7 +120,7 @@
log.debug("add event fire");
File lockFile = new File(rootDir, lock.getNodeIdentifier());
- if (lockFile.exists())
+ if (PrivilegedFileHelper.exists(lockFile))
{
throw new LockException("Persistent lock information already
exists");
}
@@ -144,13 +145,13 @@
{
log.debug("remove event fire");
File lockFile = new File(rootDir, lock.getNodeIdentifier());
- if (!lockFile.exists())
+ if (!PrivilegedFileHelper.exists(lockFile))
{
// throw new LockException("Persistent lock information not exists");
log.warn("Persistent lock information for node " +
lock.getNodeIdentifier() + " doesn't exists");
return;
}
- if (!lockFile.delete())
+ if (!PrivilegedFileHelper.delete(lockFile))
throw new LockException("Fail to remove lock information");
}
@@ -168,7 +169,7 @@
TransactionChangesLog transactionChangesLog = new TransactionChangesLog();
- String[] list = rootDir.list();
+ String[] list = PrivilegedFileHelper.list(rootDir);
try
{
@@ -214,11 +215,11 @@
for (int i = 0; i < list.length; i++)
{
File lockFile = new File(rootDir, list[i]);
- if (!lockFile.exists())
+ if (!PrivilegedFileHelper.exists(lockFile))
{
log.warn("Persistent lock information for node id " + list[i] +
" doesn't exists");
}
- if (!lockFile.delete())
+ if (!PrivilegedFileHelper.delete(lockFile))
throw new LockException("Fail to remove lock information");
}
}
@@ -288,7 +289,7 @@
throw new RepositoryConfigurationException("Repository service
configuration." + " Source name ("
+ PARAM_ROOT_DIR + ") is expected");
rootDir = new File(root);
- if (rootDir.exists())
+ if (PrivilegedFileHelper.exists(rootDir))
{
if (!rootDir.isDirectory())
{
@@ -297,7 +298,7 @@
}
else
{
- if (!rootDir.mkdirs())
+ if (!PrivilegedFileHelper.mkdirs(rootDir))
throw new RepositoryException("Can't create dir" + root);
}
}
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -26,7 +26,6 @@
import java.io.ByteArrayInputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -436,7 +435,7 @@
else
{
LOG.warn("Could not remove temporary file on switch to bytes,
fileCleaner not found. "
- + spoolFile.getAbsolutePath());
+ + PrivilegedFileHelper.getAbsolutePath(spoolFile));
}
}
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -34,9 +34,7 @@
import java.io.ByteArrayInputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -697,7 +695,7 @@
(spoolFile).release(this);
}
- if (deleteSpoolFile && spoolFile.exists())
+ if (deleteSpoolFile && PrivilegedFileHelper.exists(spoolFile))
{
if (!spoolFile.delete())
{
@@ -707,12 +705,14 @@
if (LOG.isDebugEnabled())
{
- LOG.debug("Could not remove file. Add to fileCleaner "
+ spoolFile.getAbsolutePath());
+ LOG.debug("Could not remove file. Add to fileCleaner "
+ + PrivilegedFileHelper.getAbsolutePath(spoolFile));
}
}
else
{
- LOG.warn("Could not remove temporary file on finalize " +
spoolFile.getAbsolutePath());
+ LOG.warn("Could not remove temporary file on finalize "
+ + PrivilegedFileHelper.getAbsolutePath(spoolFile));
}
}
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CleanableFilePersistedValueData.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CleanableFilePersistedValueData.java 2010-06-14
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CleanableFilePersistedValueData.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -20,6 +20,7 @@
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
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.SwapFile;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -72,6 +73,7 @@
/**
* {@inheritDoc}
*/
+ @Override
protected void finalize() throws Throwable
{
try
@@ -79,7 +81,7 @@
// release file
((SwapFile)file).release(this);
- if (!file.delete())
+ if (!PrivilegedFileHelper.delete(file))
{
//TODO FileCleaner maybe null.
if (cleaner != null)
@@ -89,7 +91,7 @@
if (LOG.isDebugEnabled())
{
LOG.debug("Could not remove temporary file on finalize:
inUse=" + (((SwapFile)file).inUse()) + ", "
- + file.getAbsolutePath());
+ + PrivilegedFileHelper.getAbsolutePath(file));
}
}
}
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -237,7 +237,7 @@
File f = new File(new String(buf, "UTF-8"));
// validate if exists
- if (f.exists())
+ if (PrivilegedFileHelper.exists(f))
{
file = f;
}
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedValueDataReader.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -88,7 +88,7 @@
public AbstractPersistedValueData read(ObjectReader in) throws
UnknownClassIdException, IOException
{
File tempDirectory = new File(SerializationConstants.TEMP_DIR);
- tempDirectory.mkdirs();
+ PrivilegedFileHelper.mkdirs(tempDirectory);
// read id
int key;
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -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;
@@ -387,8 +388,8 @@
{
this.swapDirectory = new File(DEF_SWAPDIR);
}
- if (!swapDirectory.exists())
- swapDirectory.mkdirs();
+ if (!PrivilegedFileHelper.exists(swapDirectory))
+ PrivilegedFileHelper.mkdirs(swapDirectory);
this.swapCleaner = new FileCleaner(false);
@@ -814,7 +815,7 @@
+ "data source JNDI name: " + dbSourceName + "\n" +
"is multi database: " + multiDb + "\n"
+ "storage version: " + storageVersion + "\n" +
"value storage provider: " + valueStorageProvider + "\n"
+ "max buffer size (bytes): " + maxBufferSize + "\n" +
"swap directory path: "
- + swapDirectory.getAbsolutePath();
+ + PrivilegedFileHelper.getAbsolutePath(swapDirectory);
return str;
}
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/FileValueStorage.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -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;
@@ -107,22 +108,23 @@
{
this.rootDir = new File(rootDirPath);
- if (!rootDir.exists())
+ if (!PrivilegedFileHelper.exists(rootDir))
{
- if (rootDir.mkdirs())
+ if (PrivilegedFileHelper.mkdirs(rootDir))
{
- log.info("Directory created: " + rootDir.getAbsolutePath());
+ log.info("Directory created: " +
PrivilegedFileHelper.getAbsolutePath(rootDir));
// create internal temp dir
File tempDir = new File(rootDir, TEMP_DIR_NAME);
- tempDir.mkdirs();
+ PrivilegedFileHelper.mkdirs(tempDir);
- if (tempDir.exists() && tempDir.isDirectory())
+ if (PrivilegedFileHelper.exists(tempDir) && tempDir.isDirectory())
{
// care about storage temp dir cleanup
for (File tmpf : tempDir.listFiles())
if (!tmpf.delete())
- log.warn("Storage temporary directory contains un-deletable
file " + tmpf.getAbsolutePath()
+ log.warn("Storage temporary directory contains un-deletable
file "
+ + PrivilegedFileHelper.getAbsolutePath(tmpf)
+ ". It's recommended to leave this directory for JCR
External Values Storage private use.");
}
else
@@ -131,7 +133,7 @@
}
else
{
- log.warn("Directory IS NOT created: " +
rootDir.getAbsolutePath());
+ log.warn("Directory IS NOT created: " +
PrivilegedFileHelper.getAbsolutePath(rootDir));
}
}
else
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFile.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -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;
@@ -73,12 +74,12 @@
protected boolean deleteParent(File fp)
{
boolean res = false;
- String fpPath = fp.getAbsolutePath();
- String rootPath = rootDir.getAbsolutePath();
+ String fpPath = PrivilegedFileHelper.getAbsolutePath(fp);
+ String rootPath = PrivilegedFileHelper.getAbsolutePath(rootDir);
if (fpPath.startsWith(rootPath) && fpPath.length() > rootPath.length())
if (fp.isDirectory())
{
- String[] ls = fp.list();
+ String[] ls = PrivilegedFileHelper.list(fp);;
if (ls != null && ls.length <= 0)
{
if (res = fp.delete())
@@ -87,13 +88,13 @@
}
else
{
- fLog.warn("Parent directory can not be deleted now. " +
fp.getAbsolutePath());
- cleaner.addFile(new TreeFile(fp.getAbsolutePath(), cleaner, rootDir));
+ fLog.warn("Parent directory can not be deleted now. " +
PrivilegedFileHelper.getAbsolutePath(fp));
+ cleaner.addFile(new TreeFile(PrivilegedFileHelper.getAbsolutePath(fp),
cleaner, rootDir));
}
}
}
else
- fLog.warn("Parent can not be a file but found " +
fp.getAbsolutePath());
+ fLog.warn("Parent can not be a file but found " +
PrivilegedFileHelper.getAbsolutePath(fp));
return res;
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFileIOChannel.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFileIOChannel.java 2010-06-14
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFileIOChannel.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -164,13 +164,14 @@
try
{
mkdirsLock.acquire();
- return dir.mkdirs();
+ return PrivilegedFileHelper.mkdirs(dir);
}
catch (InterruptedException e)
{
// chLog.error("mkdirs error on " + dir.getAbsolutePath() + ".
" + e, e);
// return false;
- throw new IllegalStateException("mkdirs error on " +
dir.getAbsolutePath() + " due to " + e, e);
+ throw new IllegalStateException("mkdirs error on " +
PrivilegedFileHelper.getAbsolutePath(dir) + " due to "
+ + e, e);
}
finally
{
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFileValueStorage.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFileValueStorage.java 2010-06-14
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFileValueStorage.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -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.jcr.storage.value.ValueIOChannel;
import java.io.File;
@@ -38,7 +39,7 @@
@Override
public synchronized void addFile(File file)
{
- super.addFile(new TreeFile(file.getAbsolutePath(), cleaner, rootDir));
+ super.addFile(new TreeFile(PrivilegedFileHelper.getAbsolutePath(file), cleaner,
rootDir));
}
}
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -161,9 +161,10 @@
}
catch (RecordAlreadyExistsException e)
{
- if (tempFile != null && tempFile.exists() &&
!tempFile.delete())
+ if (tempFile != null && PrivilegedFileHelper.exists(tempFile)
&& !tempFile.delete())
{
- LOG.warn("Can't delete CAS temp file. Added to file cleaner.
" + tempFile.getAbsolutePath());
+ LOG.warn("Can't delete CAS temp file. Added to file cleaner.
"
+ + PrivilegedFileHelper.getAbsolutePath(tempFile));
cleaner.addFile(tempFile);
}
throw new RecordAlreadyExistsException("Write error: " + e, e);
@@ -179,8 +180,8 @@
// rename propetynamed file to hashnamed one
if (!PrivilegedFileHelper.renameTo(tempFile, vcasFile))
{
- throw new VCASException("File " + tempFile.getAbsolutePath()
+ " can't be renamed to VCAS-named "
- + vcasFile.getAbsolutePath());
+ throw new VCASException("File " +
PrivilegedFileHelper.getAbsolutePath(tempFile)
+ + " can't be renamed to VCAS-named " +
PrivilegedFileHelper.getAbsolutePath(vcasFile));
}
} // else - CASed Value already exists
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileIOHelper.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -241,14 +241,16 @@
if ((tempFile = streamed.getTempFile()) != null)
{
// it's spooled Value, try move its file to VS
- if (!tempFile.renameTo(file))
+ if (!PrivilegedFileHelper.renameTo(tempFile, file))
{
// not succeeded - copy bytes, temp file will be deleted by
transient ValueData
if (LOG.isDebugEnabled())
{
LOG
.debug("Value spool file move (rename) to Values
Storage is not succeeded. Trying bytes copy. Spool file: "
- + tempFile.getAbsolutePath() + ". Destination:
" + file.getAbsolutePath());
+ + PrivilegedFileHelper.getAbsolutePath(tempFile)
+ + ". Destination: "
+ + PrivilegedFileHelper.getAbsolutePath(file));
}
copyClose(PrivilegedFileHelper.fileInputStream(tempFile),
PrivilegedFileHelper
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileOperation.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -191,7 +191,8 @@
if (!lockFile.delete())
{ // TODO don't use FileCleaner, delete should be enough
- LOG.warn("Cannot delete lock file " +
lockFile.getAbsolutePath() + ". Add to the FileCleaner");
+ LOG.warn("Cannot delete lock file " +
PrivilegedFileHelper.getAbsolutePath(lockFile)
+ + ". Add to the FileCleaner");
cleaner.addFile(lockFile);
}
@@ -261,7 +262,7 @@
}
catch (InterruptedException e)
{
- throw new FileLockException("Lock error on " +
file.getAbsolutePath(), e);
+ throw new FileLockException("Lock error on " +
PrivilegedFileHelper.getAbsolutePath(file), e);
}
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/WriteValue.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/WriteValue.java 2010-06-14
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/WriteValue.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -21,12 +21,10 @@
import org.exoplatform.services.jcr.datamodel.ValueData;
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.IOException;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
/**
* Created by The eXo Platform SAS.
@@ -100,37 +98,9 @@
if (fileLock != null)
try
{
- PrivilegedExceptionAction<Object> action = new
PrivilegedExceptionAction<Object>()
- {
- public Object run() throws Exception
- {
- // be sure the destination dir exists (case for Tree-style storage)
- file.getParentFile().mkdirs();
+ // be sure the destination dir exists (case for Tree-style storage)
+ PrivilegedFileHelper.mkdirs(file.getParentFile());
- return null;
- }
- };
- try
- {
- AccessController.doPrivileged(action);
- }
- catch (PrivilegedActionException pae)
- {
- Throwable cause = pae.getCause();
- if (cause instanceof IOException)
- {
- throw (IOException)cause;
- }
- else if (cause instanceof RuntimeException)
- {
- throw (RuntimeException)cause;
- }
- else
- {
- throw new RuntimeException(cause);
- }
- }
-
// write value to the file
writeValue(file, value);
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/FileCleaner.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/FileCleaner.java 2010-06-14
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/FileCleaner.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -91,7 +91,7 @@
*/
public void addFile(File file)
{
- if (file.exists())
+ if (PrivilegedFileHelper.exists(file))
{
files.offer(file);
}
@@ -124,7 +124,7 @@
Set<File> notRemovedFiles = new HashSet<File>();
while ((file = files.poll()) != null)
{
- if (file.exists())
+ if (PrivilegedFileHelper.exists(file))
{
if (!file.delete())
{
@@ -132,11 +132,12 @@
if (log.isDebugEnabled())
log.debug("Could not delete " + (file.isDirectory() ?
"directory" : "file")
- + ". Will try next time: " + file.getAbsolutePath());
+ + ". Will try next time: " +
PrivilegedFileHelper.getAbsolutePath(file));
}
else if (log.isDebugEnabled())
{
- log.debug((file.isDirectory() ? "Directory" : "File")
+ " deleted : " + file.getAbsolutePath());
+ log.debug((file.isDirectory() ? "Directory" : "File")
+ " deleted : "
+ + PrivilegedFileHelper.getAbsolutePath(file));
}
}
}
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/PrivilegedFileHelper.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -22,6 +22,7 @@
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.io.FilenameFilter;
import java.io.IOException;
import java.security.AccessController;
import java.security.PrivilegedAction;
@@ -325,17 +326,16 @@
return AccessController.doPrivileged(action);
}
- public static void mkdirs(final File file)
+ public static boolean mkdirs(final File file)
{
- PrivilegedAction<Object> action = new PrivilegedAction<Object>()
+ PrivilegedAction<Boolean> action = new PrivilegedAction<Boolean>()
{
- public Object run()
+ public Boolean run()
{
- file.mkdirs();
- return null;
+ return file.mkdirs();
}
};
- AccessController.doPrivileged(action);
+ return AccessController.doPrivileged(action);
}
public static boolean renameTo(final File srcFile, final File dstfile)
@@ -361,4 +361,16 @@
};
return AccessController.doPrivileged(action);
}
+
+ public static String[] list(final File file, final FilenameFilter filter)
+ {
+ PrivilegedAction<String[]> action = new PrivilegedAction<String[]>()
+ {
+ public String[] run()
+ {
+ return file.list(filter);
+ }
+ };
+ return AccessController.doPrivileged(action);
+ }
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SwapFile.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SwapFile.java 2010-06-14
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SwapFile.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -89,7 +89,7 @@
synchronized (inShare)
{
SwapFile newsf = new SwapFile(parent, child);
- String absPath = newsf.getAbsolutePath();
+ String absPath = PrivilegedFileHelper.getAbsolutePath(newsf);
SwapFile swapped = inShare.get(absPath);
if (swapped != null)
@@ -104,7 +104,8 @@
catch (final InterruptedException e)
{
// thinking that is ok, i.e. this thread is interrupted
- throw new IOException("Swap file read error " +
swapped.getAbsolutePath() + ". " + e)
+ throw new IOException("Swap file read error " +
PrivilegedFileHelper.getAbsolutePath(swapped) + ". "
+ + e)
{
@Override
public Throwable getCause()
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/BufferedDecoder.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -26,7 +26,6 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -117,11 +116,12 @@
*/
public void remove() throws IOException
{
- if ((fileBuffer != null) && fileBuffer.exists())
+ if ((fileBuffer != null) && PrivilegedFileHelper.exists(fileBuffer))
{
- if (!fileBuffer.delete())
+ if (!PrivilegedFileHelper.delete(fileBuffer))
{
- throw new IOException("Cannot remove file " +
fileBuffer.getAbsolutePath() + " Close all streams.");
+ throw new IOException("Cannot remove file " +
PrivilegedFileHelper.getAbsolutePath(fileBuffer)
+ + " Close all streams.");
}
}
}
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/TextExtractorTest.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -41,7 +41,7 @@
{
File sourceFolder = new File(TEST_FOLDER);
// only run if there is test data
- if (!sourceFolder.exists())
+ if (!PrivilegedFileHelper.exists(sourceFolder))
{
return;
}
@@ -57,7 +57,7 @@
*/
private void addContents(File folder, Node n) throws Exception
{
- String[] names = folder.list();
+ String[] names = PrivilegedFileHelper.list(folder);
for (int i = 0; i < names.length; i++)
{
File f = new File(folder, names[i]);
@@ -65,13 +65,13 @@
{
if (f.isDirectory())
{
- log.println("Added folder: " + f.getAbsolutePath());
+ log.println("Added folder: " +
PrivilegedFileHelper.getAbsolutePath(f));
addContents(f, n.addNode(names[i], "nt:folder"));
}
else
{
addFile(n, f);
- log.println("Added file: " + f.getAbsolutePath());
+ log.println("Added file: " +
PrivilegedFileHelper.getAbsolutePath(f));
// save after 100 files
if (++fileCount % 100 == 0)
{
@@ -89,7 +89,7 @@
public void testRepeatedUpdate() throws Exception
{
File testFile = new File("test.pdf");
- if (!testFile.exists())
+ if (!PrivilegedFileHelper.exists(testFile))
{
return;
}
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/directory/DirectoryManagerTest.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -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;
@@ -47,7 +48,7 @@
static
{
- INDEX.setPath(new File(new File("target"),
"directory-factory-test").getAbsolutePath());
+ INDEX.setPath(PrivilegedFileHelper.getAbsolutePath(new File(new
File("target"), "directory-factory-test")));
}
@Override
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/nodetypes/TestValueConstraints.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -25,7 +25,6 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.FileInputStream;
import java.io.InputStream;
import javax.jcr.Node;
@@ -60,9 +59,9 @@
{
super.setUp();
- LOCAL_SMALL_FILE = createBLOBTempFile(16).getAbsolutePath(); // 16Kb
- LOCAL_BIG_FILE = createBLOBTempFile(16 * 1024).getAbsolutePath(); // 16Mb
- LOCAL_NORMAL_FILE = createBLOBTempFile(17).getAbsolutePath(); // 17Kb
+ LOCAL_SMALL_FILE = PrivilegedFileHelper.getAbsolutePath(createBLOBTempFile(16)); //
16Kb
+ LOCAL_BIG_FILE = PrivilegedFileHelper.getAbsolutePath(createBLOBTempFile(16 *
1024)); // 16Mb
+ LOCAL_NORMAL_FILE = PrivilegedFileHelper.getAbsolutePath(createBLOBTempFile(17));
// 17Kb
byte[] xmlData =
readXmlContent("/org/exoplatform/services/jcr/api/nodetypes/nodetypes-api-test.xml");
ByteArrayInputStream xmlInput = new ByteArrayInputStream(xmlData);
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestMoveNode.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -23,7 +23,6 @@
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
-import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Calendar;
@@ -220,7 +219,7 @@
for (int i = 0; i < FILES_COUNT; i++)
{
- TEST_FILE = createBLOBTempFile("testMove",
random.nextInt(1024)).getAbsolutePath();
+ TEST_FILE =
PrivilegedFileHelper.getAbsolutePath(createBLOBTempFile("testMove",
random.nextInt(1024)));
filesList.add(TEST_FILE);
Node localBigFile = testLocalBigFiles.addNode("bigFile" + i,
"nt:file");
Node contentNode = localBigFile.addNode("jcr:content",
"nt:resource");
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestRestoreWorkspaceInitializer.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -70,7 +70,7 @@
root.save();
is.close();
- f.renameTo(new File("./sv_export_binary.bin"));
+ PrivilegedFileHelper.renameTo(f, new File("./sv_export_binary.bin"));
File outf = new File("./sv_export_root.xml");
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(outf);
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceManagement.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceManagement.java 2010-06-14
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceManagement.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -144,8 +144,10 @@
PrivilegedFileHelper.deleteOnExit(file);
WorkspaceEntry workspaceEntry =
- helper.getNewWs("WsInvalidVs", isDefaultWsMultiDb,
wsEntry.getContainer().getParameterValue(
- JDBCWorkspaceDataContainer.SOURCE_NAME), file.getAbsolutePath(),
wsEntry.getContainer());
+ helper
+ .getNewWs("WsInvalidVs", isDefaultWsMultiDb,
wsEntry.getContainer().getParameterValue(
+ JDBCWorkspaceDataContainer.SOURCE_NAME),
PrivilegedFileHelper.getAbsolutePath(file), wsEntry
+ .getContainer());
try
{
helper.createWorkspace(workspaceEntry, container);
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestArabicSearch.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -50,7 +50,7 @@
{
File file = new File("src/test/resources/ArabicUTF8.txt");
- assertTrue("/test/resources/ArabicUTF8.txt not found", file.exists());
+ assertTrue("/test/resources/ArabicUTF8.txt not found",
PrivilegedFileHelper.exists(file));
FileInputStream fis = PrivilegedFileHelper.fileInputStream(file);
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestDateSearch.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -49,7 +49,7 @@
public void testSearchDate() throws Exception
{
File file = new File("src/test/resources/test.xls");
- assertTrue("/test/resources/test.xls not found", file.exists());
+ assertTrue("/test/resources/test.xls not found",
PrivilegedFileHelper.exists(file));
FileInputStream fis = PrivilegedFileHelper.fileInputStream(file);
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestExcelFileSearch.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -46,7 +46,7 @@
public void testFindFileContent() throws Exception
{
File file = new File("src/test/resources/test.xls");
- assertTrue("/test/resources/book.xls not found", file.exists());
+ assertTrue("/test/resources/book.xls not found",
PrivilegedFileHelper.exists(file));
FileInputStream fis = PrivilegedFileHelper.fileInputStream(file);
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/lucene/TestErrorLog.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/lucene/TestErrorLog.java 2010-06-14
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/lucene/TestErrorLog.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -45,7 +45,7 @@
{
super.setUp();
file = PrivilegedFileHelper.createTempFile("error", "log");
- if (file.exists())
+ if (PrivilegedFileHelper.exists(file))
{
file.delete();
}
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCleanableFileStreamValueData.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -103,7 +103,7 @@
testCleaner.halt();
testCleaner = null;
- if (testFile.exists())
+ if (PrivilegedFileHelper.exists(testFile))
{
testFile.delete();
}
@@ -121,7 +121,7 @@
public void testFileCleaned() throws InterruptedException
{
- assertTrue(testFile.exists());
+ assertTrue(PrivilegedFileHelper.exists(testFile));
cleanableValueData = null; // CleanableVD dies
@@ -131,20 +131,20 @@
Thread.yield();
System.gc();
- assertFalse(testFile.exists()); // file released and deleted
+ assertFalse(PrivilegedFileHelper.exists(testFile)); // file released and deleted
}
public void testSharedFileNotCleaned() throws InterruptedException, IOException
{
- assertTrue(testFile.exists());
+ assertTrue(PrivilegedFileHelper.exists(testFile));
System.gc();
Thread.sleep(CLEANER_TIMEOUT / 2);
CleanableFilePersistedValueData cfvd2 =
new CleanableFilePersistedValueData(1, SwapFile.get(parentDir, FILE_NAME),
testCleaner);
- assertTrue(testFile.exists());
+ assertTrue(PrivilegedFileHelper.exists(testFile));
cleanableValueData = null; // CleanableVD dies but another instance points swapped
file
@@ -154,7 +154,7 @@
Thread.yield();
System.gc();
- assertTrue(testFile.exists());
+ assertTrue(PrivilegedFileHelper.exists(testFile));
// clean ValueData
cfvd2 = null;
@@ -165,19 +165,19 @@
Thread.yield();
System.gc();
- assertFalse(testFile.exists());
+ assertFalse(PrivilegedFileHelper.exists(testFile));
}
public void testTransientFileNotCleaned() throws InterruptedException, IOException,
RepositoryException
{
- assertTrue(testFile.exists());
+ assertTrue(PrivilegedFileHelper.exists(testFile));
System.gc();
Thread.sleep(CLEANER_TIMEOUT / 2);
TransientValueData trvd = cleanableValueData.createTransientCopy();
- assertTrue(testFile.exists());
+ assertTrue(PrivilegedFileHelper.exists(testFile));
trvd = null; // TransientVD dies
@@ -187,19 +187,19 @@
Thread.yield();
System.gc();
- assertTrue(testFile.exists()); // but Swapped CleanableVD lives and uses the file
+ assertTrue(PrivilegedFileHelper.exists(testFile)); // but Swapped CleanableVD lives
and uses the file
}
public void testTransientFileCleaned() throws InterruptedException, IOException,
RepositoryException
{
- assertTrue(testFile.exists());
+ assertTrue(PrivilegedFileHelper.exists(testFile));
System.gc();
Thread.sleep(CLEANER_TIMEOUT / 2);
TransientValueData trvd = cleanableValueData.createTransientCopy();
- assertTrue(testFile.exists());
+ assertTrue(PrivilegedFileHelper.exists(testFile));
cleanableValueData = null; // CleanableVD dies but TransientVD still uses swapped
file
@@ -209,7 +209,7 @@
Thread.yield();
System.gc();
- assertTrue(testFile.exists());
+ assertTrue(PrivilegedFileHelper.exists(testFile));
trvd = null; // TransientVD dies
@@ -219,13 +219,13 @@
Thread.yield();
System.gc();
- assertFalse(testFile.exists()); // swapped file deleted
+ assertFalse(PrivilegedFileHelper.exists(testFile)); // swapped file deleted
}
public void testTransientSharedFileCleaned() throws InterruptedException, IOException,
RepositoryException
{
- assertTrue(testFile.exists());
+ assertTrue(PrivilegedFileHelper.exists(testFile));
System.gc();
Thread.sleep(CLEANER_TIMEOUT / 2);
@@ -233,7 +233,7 @@
// file shared with TransientVD
TransientValueData trvd = cleanableValueData.createTransientCopy();
- assertTrue(testFile.exists());
+ assertTrue(PrivilegedFileHelper.exists(testFile));
// 1st CleanableVD die
cleanableValueData = null;
@@ -247,7 +247,7 @@
// file shared with third CleanableVD, i.e. file still exists (aquired by
TransientVD)
CleanableFilePersistedValueData cfvd2 =
new CleanableFilePersistedValueData(1, SwapFile.get(parentDir, FILE_NAME),
testCleaner);
- assertTrue(testFile.exists());
+ assertTrue(PrivilegedFileHelper.exists(testFile));
trvd = null; // TransientVD dies
@@ -257,7 +257,7 @@
Thread.yield();
System.gc();
- assertTrue(testFile.exists()); // still exists, aquired by 2nd CleanableVD
+ assertTrue(PrivilegedFileHelper.exists(testFile)); // still exists, aquired by 2nd
CleanableVD
cfvd2 = null; // 2nd CleanableVD dies
@@ -267,7 +267,7 @@
Thread.yield();
System.gc();
- assertFalse(testFile.exists()); // file should be deleted
+ assertFalse(PrivilegedFileHelper.exists(testFile)); // file should be deleted
}
}
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/ValueStoragePluginTest.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -33,7 +33,6 @@
import java.io.BufferedInputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -247,7 +246,8 @@
}
tempOut.close();
PrivilegedFileHelper.deleteOnExit(testFile);
- log.info("Temp file created: " + testFile.getAbsolutePath() + "
size: " + PrivilegedFileHelper.length(testFile));
+ log.info("Temp file created: " +
PrivilegedFileHelper.getAbsolutePath(testFile) + " size: "
+ + PrivilegedFileHelper.length(testFile));
return testFile;
}
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -70,12 +70,12 @@
if (rootDir == null)
{
rootDir = new File("target/temp/values-test");
- rootDir.mkdirs();
+ PrivilegedFileHelper.mkdirs(rootDir);
- new File(rootDir, FileValueStorage.TEMP_DIR_NAME).mkdirs();
+ PrivilegedFileHelper.mkdirs(new File(rootDir, FileValueStorage.TEMP_DIR_NAME));
- if (!rootDir.exists())
- throw new Exception("Folder does not exist " +
rootDir.getAbsolutePath());
+ if (!PrivilegedFileHelper.exists(rootDir))
+ throw new Exception("Folder does not exist " +
PrivilegedFileHelper.getAbsolutePath(rootDir));
}
if (storageId == null)
@@ -118,7 +118,8 @@
File vsfile =
new File(rootDir, fch.makeFilePath(vcas.getIdentifier(propertyId, 0),
CASableIOSupport.HASHFILE_ORDERNUMBER)); // orderNum
// =0
- assertTrue("File should exists " + vsfile.getAbsolutePath(),
vsfile.exists());
+ assertTrue("File should exists " +
PrivilegedFileHelper.getAbsolutePath(vsfile), PrivilegedFileHelper
+ .exists(vsfile));
InputStream etalon, tested;
compareStream(etalon = PrivilegedFileHelper.fileInputStream(testFile), tested =
@@ -243,7 +244,8 @@
fch.delete(propertyId);
fch.commit();
- assertFalse("File should not exists " + vsfile.getAbsolutePath(),
vsfile.exists());
+ assertFalse("File should not exists " +
PrivilegedFileHelper.getAbsolutePath(vsfile), PrivilegedFileHelper
+ .exists(vsfile));
}
/**
@@ -322,7 +324,8 @@
File vsfile =
new File(rootDir, fch.makeFilePath(vcas.getIdentifier(propertyId, 15),
CASableIOSupport.HASHFILE_ORDERNUMBER));
- assertTrue("File should exists " + vsfile.getAbsolutePath(),
vsfile.exists());
+ assertTrue("File should exists " +
PrivilegedFileHelper.getAbsolutePath(vsfile), PrivilegedFileHelper
+ .exists(vsfile));
assertEquals("Storage size must be increased on size of ONE file ",
initialSize
+ PrivilegedFileHelper.length(testFile), calcDirSize(rootDir));
@@ -352,7 +355,8 @@
File vsfile =
new File(rootDir, fch.makeFilePath(vcas.getIdentifier(propertyId, 15),
CASableIOSupport.HASHFILE_ORDERNUMBER));
- assertTrue("File should exists " + vsfile.getAbsolutePath(),
vsfile.exists());
+ assertTrue("File should exists " +
PrivilegedFileHelper.getAbsolutePath(vsfile), PrivilegedFileHelper
+ .exists(vsfile));
assertEquals("Storage size must be increased on size of ALL files ",
initialSize + addedSize,
calcDirSize(rootDir));
@@ -622,12 +626,12 @@
long count = 0;
for (File sf : dir.listFiles())
{
- if (sf.isDirectory() && sf.list().length > 0)
+ if (sf.isDirectory() && PrivilegedFileHelper.list(sf).length > 0)
count += deleteRecursive(sf);
else if (sf.delete())
count += 1;
else
- LOG.warn("Can't delete file " + sf.getAbsolutePath());
+ LOG.warn("Can't delete file " +
PrivilegedFileHelper.getAbsolutePath(sf));
}
count += dir.delete() ? 1 : 0;
return count;
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileIOChannel.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -58,12 +58,12 @@
super.setUp();
rootDir = new File(new File("target"), "vs1");
- rootDir.mkdirs();
+ PrivilegedFileHelper.mkdirs(rootDir);
- new File(rootDir, FileValueStorage.TEMP_DIR_NAME).mkdirs();
+ PrivilegedFileHelper.mkdirs(new File(rootDir, FileValueStorage.TEMP_DIR_NAME));
- if (!rootDir.exists())
- throw new Exception("Folder does not exist " +
rootDir.getAbsolutePath());
+ if (!PrivilegedFileHelper.exists(rootDir))
+ throw new Exception("Folder does not exist " +
PrivilegedFileHelper.getAbsolutePath(rootDir));
}
@@ -73,7 +73,7 @@
byte[] buf = "0123456789".getBytes();
File file = new File(rootDir, "testReadFromIOChannel0");
PrivilegedFileHelper.deleteOnExit(file);
- if (file.exists())
+ if (PrivilegedFileHelper.exists(file))
file.delete();
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
out.write(buf);
@@ -82,7 +82,7 @@
buf = "01234567890123456789".getBytes();
file = new File(rootDir, "testReadFromIOChannel1");
- if (file.exists())
+ if (PrivilegedFileHelper.exists(file))
file.delete();
out = PrivilegedFileHelper.fileOutputStream(file);
out.write(buf);
@@ -135,9 +135,9 @@
}
channel.commit();
- assertTrue(new File(rootDir, "testWriteToIOChannel0").exists());
- assertTrue(new File(rootDir, "testWriteToIOChannel1").exists());
- assertTrue(new File(rootDir, "testWriteToIOChannel2").exists());
+ assertTrue(PrivilegedFileHelper.exists(new File(rootDir,
"testWriteToIOChannel0")));
+ assertTrue(PrivilegedFileHelper.exists(new File(rootDir,
"testWriteToIOChannel1")));
+ assertTrue(PrivilegedFileHelper.exists(new File(rootDir,
"testWriteToIOChannel2")));
assertEquals(10, PrivilegedFileHelper.length(new File(rootDir,
"testWriteToIOChannel0")));
@@ -156,7 +156,7 @@
channel.commit();
File f = channel.getFile("testWriteUpdate", 0);
- assertTrue(f.exists());
+ assertTrue(PrivilegedFileHelper.exists(f));
assertEquals(10, PrivilegedFileHelper.length(f));
byte[] buf1 = "qwerty".getBytes();
@@ -164,7 +164,7 @@
channel.commit();
f = channel.getFile("testWriteUpdate", 0);
- assertTrue(f.exists());
+ assertTrue(PrivilegedFileHelper.exists(f));
assertEquals(6, PrivilegedFileHelper.length(f));
channel.delete("testWriteUpdate");
@@ -198,16 +198,16 @@
}
channel.commit();
- assertTrue(new File(rootDir, "testDeleteFromIOChannel0").exists());
- assertTrue(new File(rootDir, "testDeleteFromIOChannel1").exists());
- assertTrue(new File(rootDir, "testDeleteFromIOChannel2").exists());
+ assertTrue(PrivilegedFileHelper.exists(new File(rootDir,
"testDeleteFromIOChannel0")));
+ assertTrue(PrivilegedFileHelper.exists(new File(rootDir,
"testDeleteFromIOChannel1")));
+ assertTrue(PrivilegedFileHelper.exists(new File(rootDir,
"testDeleteFromIOChannel2")));
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.exists(new File(rootDir,
"testDeleteFromIOChannel0")));
+ assertFalse(PrivilegedFileHelper.exists(new File(rootDir,
"testDeleteFromIOChannel1")));
+ assertFalse(PrivilegedFileHelper.exists(new File(rootDir,
"testDeleteFromIOChannel2")));
channel.delete("testDeleteFromIOChannel");
channel.commit();
@@ -237,8 +237,8 @@
channel.commit();
File f = new File(rootDir, "testConcurrentReadFromIOChannel0");
- if (!f.exists())
- throw new Exception("File does not exist " + f.getAbsolutePath());
+ if (!PrivilegedFileHelper.exists(f))
+ throw new Exception("File does not exist " +
PrivilegedFileHelper.getAbsolutePath(f));
Probe[] p = new Probe[10];
for (int i = 0; i < 10; i++)
@@ -296,7 +296,7 @@
f = new File(rootDir, "testDeleteLockedFileFromIOChannel0");
// assertFalse(f.exists());
- System.out.println(">>>>>>>>>>>>>"
+ f.canRead() + " " + f.exists() + " " + f.canWrite());
+ System.out.println(">>>>>>>>>>>>>"
+ f.canRead() + " " + PrivilegedFileHelper.exists(f) + " " +
f.canWrite());
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileValueIO.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -86,7 +86,7 @@
byte[] buf = "0123456789".getBytes();
File file = new File("target/testReadByteArrayValueData");
- if (file.exists())
+ if (PrivilegedFileHelper.exists(file))
file.delete();
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
out.write(buf);
@@ -108,7 +108,7 @@
byte[] buf = "0123456789".getBytes();
File file = new File("target/testReadFileValueData");
- if (file.exists())
+ if (PrivilegedFileHelper.exists(file))
file.delete();
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
out.write(buf);
@@ -137,7 +137,7 @@
byte[] buf = "0123456789".getBytes();
File file = new File("target/testWriteFileValueData");
- if (file.exists())
+ if (PrivilegedFileHelper.exists(file))
file.delete();
TransientValueData vd = new TransientValueData(0, buf, null, null, null, 1024,
null, false);
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/TestValueFileIOHelper.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -93,13 +93,13 @@
io = new ValueFileIOHelper();
- if (src == null || !src.exists())
+ if (src == null || !PrivilegedFileHelper.exists(src))
{
src = createBLOBTempFile(7 * 1024); // 7M
PrivilegedFileHelper.deleteOnExit(src);
}
- if (srcSerialization == null || !srcSerialization.exists())
+ if (srcSerialization == null || !PrivilegedFileHelper.exists(srcSerialization))
{
srcSerialization =
PrivilegedFileHelper.createTempFile("srcSerialization", ".tmp");
PrivilegedFileHelper.deleteOnExit(srcSerialization);
@@ -124,7 +124,7 @@
}
testDir = new File("target/TestValueFileIOHelper");
- testDir.mkdirs();
+ PrivilegedFileHelper.mkdirs(testDir);
dest = PrivilegedFileHelper.createTempFile("vdftest", "",
testDir);
}
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/tools/tree/generator/RandomValueNodeGenerator.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -26,7 +26,6 @@
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -193,7 +192,8 @@
}
tempOut.close();
PrivilegedFileHelper.deleteOnExit(testFile);
- log.info("Temp file created: " + testFile.getAbsolutePath() + "
size: " + PrivilegedFileHelper.length(testFile));
+ log.info("Temp file created: " +
PrivilegedFileHelper.getAbsolutePath(testFile) + " size: "
+ + PrivilegedFileHelper.length(testFile));
return testFile;
}
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestPersistedValueData.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -59,7 +59,7 @@
byte[] buf = "0123456789".getBytes();
File file = new File("target/testCreateFileStreamValueData");
- if (file.exists())
+ if (PrivilegedFileHelper.exists(file))
file.delete();
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
out.write(buf);
@@ -93,7 +93,7 @@
out.close();
CleanableFilePersistedValueData vd = new CleanableFilePersistedValueData(0, file,
new FileCleaner(1000, true));
- assertTrue(file.exists());
+ assertTrue(PrivilegedFileHelper.exists(file));
vd = null;
System.gc();
@@ -102,7 +102,7 @@
Thread.sleep(2500);
System.gc();
- assertFalse(file.exists());
+ assertFalse(PrivilegedFileHelper.exists(file));
}
public void testConcurrentFileStreamValueDataReading() throws Exception
@@ -112,7 +112,7 @@
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
.getBytes();
File file = new File("target/testConcurrentFileStreamValueDataReading");
- if (file.exists())
+ if (PrivilegedFileHelper.exists(file))
file.delete();
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
// approx. 10Kb 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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestTransientValueData.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -70,7 +70,7 @@
byte[] buf = "0123456789".getBytes();
File file = new File("target/testCreateFileStreamTransientValueData");
- if (file.exists())
+ if (PrivilegedFileHelper.exists(file))
file.delete();
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
out.write(buf);
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestTransientValueDataSpooling.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -99,7 +99,7 @@
System.gc();
Thread.sleep(2000);
- String[] countBefore = tmpdir.list(new FilenameFilter()
+ String[] countBefore = PrivilegedFileHelper.list(tmpdir, new FilenameFilter()
{
public boolean accept(File dir, String name)
{
@@ -114,7 +114,7 @@
System.gc();
Thread.sleep(2000);
- String[] countAfter = tmpdir.list(new FilenameFilter()
+ String[] countAfter = PrivilegedFileHelper.list(tmpdir, new FilenameFilter()
{
public boolean accept(File dir, String name)
{
@@ -138,7 +138,7 @@
System.gc();
Thread.sleep(2000);
- String[] countBefore = tmpdir.list(new FilenameFilter()
+ String[] countBefore = PrivilegedFileHelper.list(tmpdir, new FilenameFilter()
{
public boolean accept(File dir, String name)
{
@@ -154,7 +154,7 @@
System.gc();
Thread.sleep(2000);
- String[] countAfter = tmpdir.list(new FilenameFilter()
+ String[] countAfter = PrivilegedFileHelper.list(tmpdir, new FilenameFilter()
{
public boolean accept(File dir, String name)
{
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestValueImpl.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -54,7 +54,7 @@
byte[] buf = "012345678901234567890123456789".getBytes();
File file = new File("target/testNewBinaryValue");
- if (file.exists())
+ if (PrivilegedFileHelper.exists(file))
file.delete();
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
out.write(buf);
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestBinaryValue.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -21,7 +21,6 @@
import org.exoplatform.services.jcr.JcrAPIBaseTest;
import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
-import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Calendar;
@@ -80,7 +79,7 @@
if (TEST_FILE == null)
{
// create test file
- TEST_FILE = createBLOBTempFile(2).getAbsolutePath();
+ TEST_FILE = PrivilegedFileHelper.getAbsolutePath(createBLOBTempFile(2));
}
}
@@ -91,7 +90,7 @@
startTime = System.currentTimeMillis(); // to get the time of start
// 300 Kb
- TEST_FILE = createBLOBTempFile(300).getAbsolutePath();
+ TEST_FILE = PrivilegedFileHelper.getAbsolutePath(createBLOBTempFile(300));
for (int i = 0; i < FILES_COUNT; i++)
{
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestBinaryValueMultiThreading.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -23,7 +23,6 @@
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;
import java.util.Calendar;
@@ -140,7 +139,7 @@
if (LOCAL_BIG_FILE == null)
{
// create test file
- LOCAL_BIG_FILE = createBLOBTempFile(3).getAbsolutePath();
+ LOCAL_BIG_FILE = PrivilegedFileHelper.getAbsolutePath(createBLOBTempFile(3));
}
Node testLocalBigFiles = root.addNode("testLocalBigFiles");
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestConcurrentItems.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -28,7 +28,6 @@
import org.exoplatform.services.jcr.util.IdGenerator;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@@ -89,7 +88,7 @@
// create test file
testFile = createBLOBTempFile(1024);
dataSize = (int)PrivilegedFileHelper.length(testFile);
- TEST_FILE = testFile.getAbsolutePath();
+ TEST_FILE = PrivilegedFileHelper.getAbsolutePath(testFile);
}
else
{
@@ -254,9 +253,9 @@
repository
.login(
this.credentials /*
-
*
session.getCredentials(
-
* )
-
*/,
+
*
session.getCredentials(
+
* )
+
*/,
"ws1"));
readed.start();
readers.add(readed);
@@ -272,11 +271,14 @@
log.info("Begin cleaner...");
DeleteThread cleaner =
- new DeleteThread(repository.login(this.credentials /*
-
* session.getCredentials
-
* ()
-
*/,
- "ws1"));
+ new DeleteThread(
+ repository
+ .login(
+ this.credentials /*
+
* session.getCredentials
+
* ()
+
*/,
+ "ws1"));
cleaner.start();
log.info("<<<<<<<<<<<<<<<<<<<<
Wait cycle
>>>>>>>>>>>>>>>>>>>>>");
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestExportBigFiles.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -24,7 +24,6 @@
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -49,7 +48,7 @@
*/
public void testBigExportSysView() throws Exception
{
- String TEST_FILE = createBLOBTempFile(1024 * 5).getAbsolutePath();// 5M
+ String TEST_FILE = PrivilegedFileHelper.getAbsolutePath(createBLOBTempFile(1024 *
5));// 5M
Node testLocalBigFiles = root.addNode("testLocalBigFiles");
// add file to repository
@@ -113,7 +112,7 @@
*/
public void testBigImportExportDocView() throws Exception
{
- String TEST_FILE2 = createBLOBTempFile(1024 * 5).getAbsolutePath(); // 5M
+ String TEST_FILE2 = PrivilegedFileHelper.getAbsolutePath(createBLOBTempFile(1024 *
5)); // 5M
Node testLocalBigFiles = root.addNode("testDocView");
// add file to repository
@@ -238,7 +237,7 @@
for (int i = 0; i < FILES_COUNT; i++)
{
- fileList.add(createBLOBTempFile(random.nextInt(1024 *
1024)).getAbsolutePath());
+
fileList.add(PrivilegedFileHelper.getAbsolutePath(createBLOBTempFile(random.nextInt(1024 *
1024))));
}
Node testLocalBigFiles = root.addNode("testLocalBigFiles");
@@ -326,7 +325,8 @@
}
tempOut.close();
PrivilegedFileHelper.deleteOnExit(testFile);
- log.info("Temp file created: " + testFile.getAbsolutePath() + "
size: " + PrivilegedFileHelper.length(testFile));
+ log.info("Temp file created: " +
PrivilegedFileHelper.getAbsolutePath(testFile) + " size: "
+ + PrivilegedFileHelper.length(testFile));
return testFile;
}
}
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestMoveBinaryValue.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -21,7 +21,6 @@
import org.exoplatform.services.jcr.JcrAPIBaseTest;
import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
-import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Calendar;
@@ -59,7 +58,7 @@
startTime = System.currentTimeMillis(); // to get the time of start
// 300 Kb
- TEST_FILE = createBLOBTempFile(300).getAbsolutePath();
+ TEST_FILE = PrivilegedFileHelper.getAbsolutePath(createBLOBTempFile(300));
for (int i = 0; i < FILES_COUNT; i++)
{
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestMoveBinaryValue1.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -21,7 +21,6 @@
import org.exoplatform.services.jcr.JcrAPIBaseTest;
import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
-import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Calendar;
@@ -57,7 +56,7 @@
startTime = System.currentTimeMillis(); // to get the time of start
// 300 Kb
- TEST_FILE = createBLOBTempFile(300).getAbsolutePath();
+ TEST_FILE = PrivilegedFileHelper.getAbsolutePath(createBLOBTempFile(300));
for (int i = 0; i < FILES_COUNT; i++)
{
@@ -101,7 +100,7 @@
startTime = System.currentTimeMillis(); // to get the time of start
// 45 Kb
- TEST_FILE = createBLOBTempFile(45).getAbsolutePath();
+ TEST_FILE = PrivilegedFileHelper.getAbsolutePath(createBLOBTempFile(45));
for (int i = 0; i < FILES_COUNT; i++)
{
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/dataflow/persistent/TestGetNodesConcurrentModification.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -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.getAbsolutePath(new
File("src/test/resources/index/test_index.doc")));
initDB();
}
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/perf/TestPerformance.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -22,7 +22,6 @@
import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import org.exoplatform.services.jcr.util.IdGenerator;
-import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Calendar;
@@ -432,7 +431,7 @@
// variables for the execution time
int FILE_SIZE = 100;// 100 K
Node testAddNtFilePlusNtResource =
testRoot.addNode("testAddNtFilePlusNtResource", "nt:unstructured");
- TEST_FILE = createBLOBTempFile(FILE_SIZE).getAbsolutePath();
+ TEST_FILE = PrivilegedFileHelper.getAbsolutePath(createBLOBTempFile(FILE_SIZE));
long startTime = System.currentTimeMillis();
for (int i = 0; i < NODES_COUNT_SHORT_SESSION; i++)
{
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/storage/fs/TestFSReadWrite.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -112,7 +112,7 @@
super.setUp();
testRoot = new File("target/fstest");
- testRoot.mkdirs();
+ PrivilegedFileHelper.mkdirs(testRoot);
PrivilegedFileHelper.deleteOnExit(testRoot);
}
@@ -121,7 +121,7 @@
{
long time = System.currentTimeMillis();
- if (testRoot.exists())
+ if (PrivilegedFileHelper.exists(testRoot))
{
deleteDir(testRoot);
// deleteFiles(files);
@@ -143,10 +143,10 @@
protected void deleteFileParent(File fp)
{
- if (fp.getAbsolutePath().startsWith(testRoot.getAbsolutePath()))
+ if
(PrivilegedFileHelper.getAbsolutePath(fp).startsWith(PrivilegedFileHelper.getAbsolutePath(testRoot)))
if (fp.isDirectory())
{
- String[] ls = fp.list();
+ String[] ls = PrivilegedFileHelper.list(fp);
if (ls.length <= 0)
{
// log.info("del " + fp.getAbsolutePath());
@@ -155,20 +155,20 @@
}
}
else
- fail("Dir can't be a file but found " + fp.getAbsolutePath());
+ fail("Dir can't be a file but found " +
PrivilegedFileHelper.getAbsolutePath(fp));
}
protected void deleteDir(File dir)
{
- String[] ls = dir.list();
+ String[] ls = PrivilegedFileHelper.list(dir);
if (ls == null)
{
- log.log(Level.WARNING, "Dir not found " + dir.getAbsolutePath());
- fail("Dir not found " + dir.getAbsolutePath());
+ log.log(Level.WARNING, "Dir not found " +
PrivilegedFileHelper.getAbsolutePath(dir));
+ fail("Dir not found " + PrivilegedFileHelper.getAbsolutePath(dir));
}
for (String fn : ls)
{
- File f = new File(dir.getAbsolutePath() + File.separator + fn);
+ File f = new File(PrivilegedFileHelper.getAbsolutePath(dir) + File.separator +
fn);
if (f.isDirectory())
{
deleteDir(f);
@@ -184,14 +184,14 @@
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 = new File(PrivilegedFileHelper.getAbsolutePath(testRoot) +
File.separator + SIDGenerator.generate());
try
{
// f.createNewFile();
FileOutputStream fos = PrivilegedFileHelper.fileOutputStream(f);
try
{
- fos.write(("File content " + f.getAbsolutePath()).getBytes());
+ fos.write(("File content " +
PrivilegedFileHelper.getAbsolutePath(f)).getBytes());
}
finally
{
@@ -213,16 +213,16 @@
for (int i = 0; i < FILES_COUNT; i++)
{
String fileName = SIDGenerator.generate();
- File dir = new File(testRoot.getAbsolutePath() + buildPathX(fileName));
- dir.mkdirs();
- File f = new File(dir.getAbsolutePath() + File.separator + fileName);
+ File dir = new File(PrivilegedFileHelper.getAbsolutePath(testRoot) +
buildPathX(fileName));
+ PrivilegedFileHelper.mkdirs(dir);
+ File f = new File(PrivilegedFileHelper.getAbsolutePath(dir) + File.separator +
fileName);
try
{
// f.createNewFile();
FileOutputStream fos = PrivilegedFileHelper.fileOutputStream(f);
try
{
- fos.write(("File content " + f.getAbsolutePath()).getBytes());
+ fos.write(("File content " +
PrivilegedFileHelper.getAbsolutePath(f)).getBytes());
}
finally
{
@@ -255,16 +255,16 @@
for (int i = 0; i < FILES_COUNT; i++)
{
String fileName = SIDGenerator.generate();
- File dir = new File(testRoot.getAbsolutePath() + buildPathXX(fileName));
- dir.mkdirs();
- File f = new File(dir.getAbsolutePath() + File.separator + fileName);
+ File dir = new File(PrivilegedFileHelper.getAbsolutePath(testRoot) +
buildPathXX(fileName));
+ PrivilegedFileHelper.mkdirs(dir);
+ File f = new File(PrivilegedFileHelper.getAbsolutePath(dir) + File.separator +
fileName);
try
{
// f.createNewFile();
FileOutputStream fos = PrivilegedFileHelper.fileOutputStream(f);
try
{
- fos.write(("File content " + f.getAbsolutePath()).getBytes());
+ fos.write(("File content " +
PrivilegedFileHelper.getAbsolutePath(f)).getBytes());
}
finally
{
@@ -301,16 +301,18 @@
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));
- dir.mkdirs();
- File f = new File(dir.getAbsolutePath() + File.separator + fileName);
+ File dir =
+ new File(PrivilegedFileHelper.getAbsolutePath(testRoot) + File.separator +
prefix + File.separator
+ + buildPathX(rnd));
+ PrivilegedFileHelper.mkdirs(dir);
+ File f = new File(PrivilegedFileHelper.getAbsolutePath(dir) + File.separator +
fileName);
try
{
// f.createNewFile();
FileOutputStream fos = PrivilegedFileHelper.fileOutputStream(f);
try
{
- fos.write(("File content " + f.getAbsolutePath()).getBytes());
+ fos.write(("File content " +
PrivilegedFileHelper.getAbsolutePath(f)).getBytes());
}
finally
{
@@ -345,9 +347,9 @@
for (int i = 0; i < FILES_COUNT; i++)
{
String fileName = SIDGenerator.generate();
- File dir = new File(testRoot.getAbsolutePath() + File.separator +
buildPathX8(fileName));
- dir.mkdirs();
- File f = new File(dir.getAbsolutePath() + File.separator + fileName);
+ File dir = new File(PrivilegedFileHelper.getAbsolutePath(testRoot) +
File.separator + buildPathX8(fileName));
+ PrivilegedFileHelper.mkdirs(dir);
+ File f = new File(PrivilegedFileHelper.getAbsolutePath(dir) + File.separator +
fileName);
try
{
FileOutputStream fos = PrivilegedFileHelper.fileOutputStream(f);
@@ -379,10 +381,10 @@
// long time = System.currentTimeMillis();
// log.info(">>> Step into directory " + root.getAbsolutePath()
+
// (filter != null ? ", searched file " + filter.getName() :
""));
- String[] ls = filter != null ? root.list(filter) : root.list();
+ String[] ls = filter != null ? PrivilegedFileHelper.list(root, filter) :
root.list();
for (String file : ls)
{
- File f = new File(testRoot.getAbsolutePath() + File.separator + file);
+ File f = new File(PrivilegedFileHelper.getAbsolutePath(testRoot) +
File.separator + file);
if (f.isDirectory())
{
// dir
@@ -417,22 +419,22 @@
protected void readTreeXFiles(File root, NameFilter filter)
{
- String dirPath = root.getAbsolutePath() + buildPathX(filter.getName());
+ String dirPath = PrivilegedFileHelper.getAbsolutePath(root) +
buildPathX(filter.getName());
File dir = new File(dirPath);
- String[] ls = filter != null ? dir.list(filter) : dir.list();
+ String[] ls = filter != null ? PrivilegedFileHelper.list(dir, filter) :
dir.list();
if (ls == null)
{
- log.log(Level.WARNING, "Dir not found " + dir.getAbsolutePath());
- fail("Dir not found " + dir.getAbsolutePath());
+ log.log(Level.WARNING, "Dir not found " +
PrivilegedFileHelper.getAbsolutePath(dir));
+ fail("Dir not found " + PrivilegedFileHelper.getAbsolutePath(dir));
}
for (String file : ls)
{
- File f = new File(dir.getAbsolutePath() + File.separator + file);
+ File f = new File(PrivilegedFileHelper.getAbsolutePath(dir) + File.separator +
file);
if (f.isDirectory())
{
// dir
- fail("The file can't be a dir but found " +
f.getAbsolutePath());
+ fail("The file can't be a dir but found " +
PrivilegedFileHelper.getAbsolutePath(f));
}
else
{
@@ -456,22 +458,22 @@
protected void readTreeX8Files(File root, NameFilter filter)
{
- String dirPath = root.getAbsolutePath() + buildPathX8(filter.getName());
+ String dirPath = PrivilegedFileHelper.getAbsolutePath(root) +
buildPathX8(filter.getName());
File dir = new File(dirPath);
- String[] ls = filter != null ? dir.list(filter) : dir.list();
+ String[] ls = filter != null ? PrivilegedFileHelper.list(dir, filter) :
dir.list();
if (ls == null)
{
- log.log(Level.WARNING, "Dir not found " + dir.getAbsolutePath());
- fail("Dir not found " + dir.getAbsolutePath());
+ log.log(Level.WARNING, "Dir not found " +
PrivilegedFileHelper.getAbsolutePath(dir));
+ fail("Dir not found " + PrivilegedFileHelper.getAbsolutePath(dir));
}
for (String file : ls)
{
- File f = new File(dir.getAbsolutePath() + File.separator + file);
+ File f = new File(PrivilegedFileHelper.getAbsolutePath(dir) + File.separator +
file);
if (f.isDirectory())
{
// dir
- fail("The file can't be a dir but found " +
f.getAbsolutePath());
+ fail("The file can't be a dir but found " +
PrivilegedFileHelper.getAbsolutePath(f));
}
else
{
@@ -500,22 +502,22 @@
protected void readTreeXXFiles(File root, NameFilter filter)
{
- String dirPath = root.getAbsolutePath() + buildPathXX(filter.getName());
+ String dirPath = PrivilegedFileHelper.getAbsolutePath(root) +
buildPathXX(filter.getName());
File dir = new File(dirPath);
- String[] ls = filter != null ? dir.list(filter) : dir.list();
+ String[] ls = filter != null ? PrivilegedFileHelper.list(dir, filter) :
dir.list();
if (ls == null)
{
- log.log(Level.WARNING, "Dir not found " + dir.getAbsolutePath());
- fail("Dir not found " + dir.getAbsolutePath());
+ log.log(Level.WARNING, "Dir not found " +
PrivilegedFileHelper.getAbsolutePath(dir));
+ fail("Dir not found " + PrivilegedFileHelper.getAbsolutePath(dir));
}
for (String file : ls)
{
- File f = new File(dir.getAbsolutePath() + File.separator + file);
+ File f = new File(PrivilegedFileHelper.getAbsolutePath(dir) + File.separator +
file);
if (f.isDirectory())
{
// dir
- fail("The file can't be a dir but found " +
f.getAbsolutePath());
+ fail("The file can't be a dir but found " +
PrivilegedFileHelper.getAbsolutePath(f));
}
else
{
@@ -547,21 +549,23 @@
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));
- String[] ls = filter != null ? dir.list(filter) : dir.list();
+ File dir =
+ new File(PrivilegedFileHelper.getAbsolutePath(testRoot) + File.separator +
prefix + File.separator
+ + buildPathX(rnd));
+ String[] ls = filter != null ? PrivilegedFileHelper.list(dir, filter) :
dir.list();
if (ls == null)
{
- log.log(Level.WARNING, "Dir not found " + dir.getAbsolutePath());
- fail("Dir not found " + dir.getAbsolutePath());
+ log.log(Level.WARNING, "Dir not found " +
PrivilegedFileHelper.getAbsolutePath(dir));
+ fail("Dir not found " + PrivilegedFileHelper.getAbsolutePath(dir));
}
for (String file : ls)
{
- File f = new File(dir.getAbsolutePath() + File.separator + file);
+ File f = new File(PrivilegedFileHelper.getAbsolutePath(dir) + File.separator +
file);
if (f.isDirectory())
{
// dir
- fail("The file can't be a dir but found " +
f.getAbsolutePath());
+ fail("The file can't be a dir but found " +
PrivilegedFileHelper.getAbsolutePath(f));
}
else
{
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
09:34:01 UTC (rev 2569)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/RemoveVDTest.java 2010-06-14
10:52:13 UTC (rev 2570)
@@ -21,20 +21,15 @@
import org.exoplatform.services.jcr.dataflow.serialization.ObjectReader;
import org.exoplatform.services.jcr.dataflow.serialization.ObjectWriter;
import org.exoplatform.services.jcr.dataflow.serialization.UnknownClassIdException;
-import org.exoplatform.services.jcr.impl.dataflow.AbstractPersistedValueData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import org.exoplatform.services.jcr.impl.dataflow.persistent.FilePersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.persistent.StreamPersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.serialization.ObjectReaderImpl;
import org.exoplatform.services.jcr.impl.dataflow.serialization.ObjectWriterImpl;
import
org.exoplatform.services.jcr.impl.dataflow.serialization.PersistedValueDataReader;
import
org.exoplatform.services.jcr.impl.dataflow.serialization.PersistedValueDataWriter;
-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.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
/**
@@ -102,9 +97,8 @@
// Imitation save
((StreamPersistedValueData)vd2).setPersistedFile(((StreamPersistedValueData)vd2).getTempFile());
- assertTrue(vd1.getFile().exists());
- assertTrue(vd2.getFile().exists());
-
+ assertTrue(PrivilegedFileHelper.exists(vd1.getFile()));
+ assertTrue(PrivilegedFileHelper.exists(vd2.getFile()));
// remove first one
vd1 = null;
try
@@ -116,7 +110,7 @@
// TODO Auto-generated catch block
e.printStackTrace();
}
- assertTrue(vd2.getFile().exists());
+ assertTrue(PrivilegedFileHelper.exists(vd2.getFile()));
f.delete();
}