Skip to content
Snippets Groups Projects
Commit a9b28c15 authored by felmer's avatar felmer
Browse files

SSDM-8473: check acces rights before copying data set to pre-staging area

parent cf3eea1a
No related branches found
No related tags found
No related merge requests found
...@@ -20,6 +20,7 @@ import static ch.systemsx.cisd.etlserver.IStorageProcessorTransactional.STORAGE_ ...@@ -20,6 +20,7 @@ import static ch.systemsx.cisd.etlserver.IStorageProcessorTransactional.STORAGE_
import static ch.systemsx.cisd.etlserver.ThreadParameters.ON_ERROR_DECISION_KEY; import static ch.systemsx.cisd.etlserver.ThreadParameters.ON_ERROR_DECISION_KEY;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
...@@ -27,6 +28,7 @@ import java.util.concurrent.locks.ReentrantLock; ...@@ -27,6 +28,7 @@ import java.util.concurrent.locks.ReentrantLock;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel;
import ch.systemsx.cisd.base.exceptions.InterruptedExceptionUnchecked; import ch.systemsx.cisd.base.exceptions.InterruptedExceptionUnchecked;
import ch.systemsx.cisd.common.action.AbstractDelegatedActionWithResult; import ch.systemsx.cisd.common.action.AbstractDelegatedActionWithResult;
import ch.systemsx.cisd.common.action.IDelegatedActionWithResult; import ch.systemsx.cisd.common.action.IDelegatedActionWithResult;
...@@ -384,6 +386,8 @@ public abstract class AbstractOmniscientTopLevelDataSetRegistrator<T extends Dat ...@@ -384,6 +386,8 @@ public abstract class AbstractOmniscientTopLevelDataSetRegistrator<T extends Dat
markerFileCleanupAction = new DoNothingDelegatedAction(); markerFileCleanupAction = new DoNothingDelegatedAction();
} }
checkAccessRightsRecursively(incomingDataSetFile);
// read from configuration prestaging parameter. // read from configuration prestaging parameter.
DataSetRegistrationPreStagingBehavior preStagingUsage = DataSetRegistrationPreStagingBehavior preStagingUsage =
state.getGlobalState().getThreadParameters() state.getGlobalState().getThreadParameters()
...@@ -414,6 +418,28 @@ public abstract class AbstractOmniscientTopLevelDataSetRegistrator<T extends Dat ...@@ -414,6 +418,28 @@ public abstract class AbstractOmniscientTopLevelDataSetRegistrator<T extends Dat
cleanupAction); cleanupAction);
} }
} }
private void checkAccessRightsRecursively(File file)
{
if (file.canRead() == false)
{
throw CheckedExceptionTunnel.wrapIfNecessary(new IOException(
"No reading rights for data set file '" + file.getAbsolutePath() + "'."));
}
if (file.isDirectory())
{
if (file.canWrite() == false)
{
throw CheckedExceptionTunnel.wrapIfNecessary(new IOException(
"No writing rights for data set folder '" + file.getAbsolutePath() + "'."));
}
File[] files = file.listFiles();
for (File child : files)
{
checkAccessRightsRecursively(child);
}
}
}
/** /**
* Make a copy of the file to the prestaging directory. * Make a copy of the file to the prestaging directory.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment