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

DMV-13 Introducing StoreItemLocation and modify IFileStore.

SVN: 6080
parent 1ae0efba
No related branches found
No related tags found
No related merge requests found
......@@ -77,12 +77,17 @@ public abstract class FileStore implements IFileStore
}
}
public final File getPath()
public final StoreItemLocation getStoreItemLocation(StoreItem item)
{
return new StoreItemLocation(hostOrNull, StoreItem.asFile(getPath(), item).getAbsolutePath());
}
protected final File getPath()
{
return fileWithHighwaterMark.getFile();
}
public final String tryGetHost()
protected final String tryGetHost()
{
return hostOrNull;
}
......
......@@ -16,8 +16,6 @@
package ch.systemsx.cisd.datamover.filesystem.intf;
import java.io.File;
import ch.systemsx.cisd.common.exceptions.Status;
import ch.systemsx.cisd.common.highwatermark.HighwaterMarkWatcher;
import ch.systemsx.cisd.common.logging.ISimpleLogger;
......@@ -45,16 +43,9 @@ public interface IFileStore extends ISelfTestable
public boolean isRemote();
/**
* Returns the path of this file store.
*/
public File getPath();
/**
* Tries to return the host.
*
* @return <code>null</code> if {@link #isRemote()} return <code>false</code>.
* Returns the location of the specified store item.
*/
public String tryGetHost();
public StoreItemLocation getStoreItemLocation(StoreItem item);
/**
* Returns <code>true</code> if this file store is the parent directory of
......
/*
* Copyright 2008 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.datamover.filesystem.intf;
import ch.systemsx.cisd.common.utilities.StoreItem;
/**
* Bean for the location of a {@link StoreItem} on a local or remote file system.
*
* @author Franz-Josef Elmer
*/
public class StoreItemLocation
{
private final String host;
private final String absolutePath;
/**
* Creates a new instance for the specified host and absolute path.
*
* @param hostOrNull If not <code>null</code> the file is on a remote file system.
*/
public StoreItemLocation(String hostOrNull, String absolutePath)
{
if (absolutePath == null)
{
throw new IllegalArgumentException("Absolute path not specified.");
}
host = hostOrNull;
this.absolutePath = absolutePath;
}
/**
* Returns the host if this location is on a remote file system. Otherwise <code>null</code>
* is returned.
*/
public final String getHost()
{
return host;
}
public final String getAbsolutePath()
{
return absolutePath;
}
}
......@@ -28,6 +28,7 @@ import ch.systemsx.cisd.common.process.ProcessResult;
import ch.systemsx.cisd.common.utilities.AbstractHashable;
import ch.systemsx.cisd.common.utilities.StoreItem;
import ch.systemsx.cisd.datamover.filesystem.intf.IFileStore;
import ch.systemsx.cisd.datamover.filesystem.intf.StoreItemLocation;
/**
*
......@@ -152,12 +153,12 @@ public class DataCompletedFilter implements IStoreItemFilter
private List<String> createCommand(StoreItem item)
{
String absolutePath = StoreItem.asFile(fileStore.getPath(), item).getAbsolutePath();
String host = fileStore.tryGetHost();
StoreItemLocation storeItemLocation = fileStore.getStoreItemLocation(item);
List<String> command = new ArrayList<String>();
command.add("sh");
command.add(dataCompletedScript);
command.add(absolutePath);
command.add(storeItemLocation.getAbsolutePath());
String host = storeItemLocation.getHost();
if (host != null)
{
command.add(host);
......
......@@ -49,7 +49,6 @@ public class IncomingProcessorTest
private static final String COPY_COMPLETE_DIR = "copy-complete";
private static final String READY_TO_MOVE_DIR = "ready-to-move";
private static final String TEMP_DIR = "temp";
private static final String EXAMPLE_SCRIPT = "example-script";
private Mockery context;
private IFileSysOperationsFactory fileSysOpertationFactory;
......
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