Skip to content
Snippets Groups Projects
Commit 078d6631 authored by jakubs's avatar jakubs
Browse files

SP-45, BIS-21 small update of markerFileUtilities interface

SVN: 25284
parent bd1bae52
No related branches found
No related tags found
No related merge requests found
...@@ -56,6 +56,11 @@ public class MarkerFileUtility ...@@ -56,6 +56,11 @@ public class MarkerFileUtility
this.storeRootDirectory = storeRootDirectory; this.storeRootDirectory = storeRootDirectory;
} }
public static File getMarkerFileFromIncoming(final File incoming)
{
return new File(incoming.getParentFile(), IS_FINISHED_PREFIX + incoming.getName());
}
/** /**
* From given <var>isFinishedPath</var> gets the incoming data set path and checks it. * From given <var>isFinishedPath</var> gets the incoming data set path and checks it.
* *
...@@ -64,8 +69,7 @@ public class MarkerFileUtility ...@@ -64,8 +69,7 @@ public class MarkerFileUtility
*/ */
public final File getIncomingDataSetPathFromMarker(final File isFinishedPath) public final File getIncomingDataSetPathFromMarker(final File isFinishedPath)
{ {
final File incomingDataSetPath = final File incomingDataSetPath = getIncomingFromMarkerFile(isFinishedPath);
FileUtilities.removePrefixFromFileName(isFinishedPath, IS_FINISHED_PREFIX);
if (operationLog.isDebugEnabled()) if (operationLog.isDebugEnabled())
{ {
operationLog.debug(String.format( operationLog.debug(String.format(
...@@ -84,6 +88,13 @@ public class MarkerFileUtility ...@@ -84,6 +88,13 @@ public class MarkerFileUtility
return incomingDataSetPath; return incomingDataSetPath;
} }
static File getIncomingFromMarkerFile(final File isFinishedPath)
{
final File incomingDataSetPath =
FileUtilities.removePrefixFromFileName(isFinishedPath, IS_FINISHED_PREFIX);
return incomingDataSetPath;
}
public boolean deleteAndLogIsFinishedMarkerFile(File isFinishedFile) public boolean deleteAndLogIsFinishedMarkerFile(File isFinishedFile)
{ {
if (fileOperations.exists(isFinishedFile) == false) if (fileOperations.exists(isFinishedFile) == false)
......
/*
* Copyright 2012 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.etlserver.registrator;
import java.io.File;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
import static ch.systemsx.cisd.common.Constants.IS_FINISHED_PREFIX;
/**
*
*
* @author jakubs
*/
public class MarkerFileUtilityTest extends AssertJUnit
{
@Test
public void testMarkerFileNameGeneration()
{
File original = new File("a/b/c/d");
File markerPath = MarkerFileUtility.getMarkerFileFromIncoming(original);
assertEquals(markerPath, new File("a/b/c", IS_FINISHED_PREFIX + original.getName()));
assertEquals(original, MarkerFileUtility.getIncomingFromMarkerFile(markerPath));
}
}
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