diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/MarkerFileUtility.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/MarkerFileUtility.java index 9a3b812be1a2440d9c6fdca6d239b665b46bcf11..7705dde558235f7e4169001341583de93dbe084f 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/MarkerFileUtility.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/MarkerFileUtility.java @@ -56,6 +56,11 @@ public class MarkerFileUtility 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. * @@ -64,8 +69,7 @@ public class MarkerFileUtility */ public final File getIncomingDataSetPathFromMarker(final File isFinishedPath) { - final File incomingDataSetPath = - FileUtilities.removePrefixFromFileName(isFinishedPath, IS_FINISHED_PREFIX); + final File incomingDataSetPath = getIncomingFromMarkerFile(isFinishedPath); if (operationLog.isDebugEnabled()) { operationLog.debug(String.format( @@ -84,6 +88,13 @@ public class MarkerFileUtility return incomingDataSetPath; } + static File getIncomingFromMarkerFile(final File isFinishedPath) + { + final File incomingDataSetPath = + FileUtilities.removePrefixFromFileName(isFinishedPath, IS_FINISHED_PREFIX); + return incomingDataSetPath; + } + public boolean deleteAndLogIsFinishedMarkerFile(File isFinishedFile) { if (fileOperations.exists(isFinishedFile) == false) diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/MarkerFileUtilityTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/MarkerFileUtilityTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5bd030e4b39e584e0b4aa81adcf1b3b4f6ffa138 --- /dev/null +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/MarkerFileUtilityTest.java @@ -0,0 +1,43 @@ +/* + * 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)); + } +}