diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/cifs/CifsServerConfig.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/cifs/CifsServerConfig.java index 03b0b2fba4e550bfa184a8b7865751a538a4d240..520f684f5293c2e1454ed9985b94816db85f243b 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/cifs/CifsServerConfig.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/cifs/CifsServerConfig.java @@ -24,6 +24,7 @@ import ch.systemsx.cisd.common.collection.MapBuilder; import ch.systemsx.cisd.common.properties.PropertyParametersUtil; import ch.systemsx.cisd.common.properties.PropertyUtils; import ch.systemsx.cisd.common.string.Template; +import ch.systemsx.cisd.openbis.dss.generic.shared.utils.DssPropertyParametersUtil; /** * @@ -84,6 +85,12 @@ class CifsServerConfig .entry("share-name", "STORE") .getMap(); + static Properties getServerProperties() + { + return PropertyParametersUtil.extractSingleSectionProperties( + DssPropertyParametersUtil.loadServiceProperties(), SECTION_NAME, false).getProperties(); + } + private final boolean enabled; private final Properties serverProperties; diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/cifs/DSSFileSearchContext.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/cifs/DSSFileSearchContext.java new file mode 100644 index 0000000000000000000000000000000000000000..0ff9e7bd1e1df693626959dde95ea873c7c60d56 --- /dev/null +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/cifs/DSSFileSearchContext.java @@ -0,0 +1,125 @@ +/* + * Copyright 2016 ETH Zuerich, SIS + * + * 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.openbis.dss.generic.server.cifs; + +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.jlan.server.filesys.FileAttribute; +import org.alfresco.jlan.server.filesys.FileInfo; +import org.alfresco.jlan.server.filesys.FileName; +import org.alfresco.jlan.server.filesys.SearchContext; +import org.alfresco.jlan.util.WildCard; +import org.apache.ftpserver.ftplet.FtpException; +import org.apache.ftpserver.ftplet.FtpFile; + +import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel; +import ch.systemsx.cisd.openbis.dss.generic.server.ftp.DSSFileSystemView; + +/** + * @author Franz-Josef Elmer + */ +public class DSSFileSearchContext extends SearchContext +{ + private List<FtpFile> files = new ArrayList<>(); + + private int index; + + public DSSFileSearchContext(DSSFileSystemView view, String normalizedSearchPath, int fileAttributes) + { + String[] pathStr = FileName.splitPath(normalizedSearchPath, java.io.File.separatorChar); + try + { + if (pathStr[1] != null && WildCard.containsWildcards(pathStr[1])) + { + WildCard wildCard = new WildCard(pathStr[1], true); + FtpFile directory = view.getFile(pathStr[0]); + for (FtpFile file : directory.listFiles()) + { + if (matches(wildCard, fileAttributes, file)) + { + files.add(file); + } + } + } else + { + FtpFile file = view.getFile(normalizedSearchPath); + if (matches(null, fileAttributes, file)) + { + files.add(file); + } + } + } catch (FtpException ex) + { + throw CheckedExceptionTunnel.wrapIfNecessary(ex); + } + } + + private boolean matches(WildCard wildcardOrNull, int fileAttributes, FtpFile file) + { + if (wildcardOrNull != null && wildcardOrNull.matchesPattern(file.getName()) == false) + { + return false; + } + return FileAttribute.isDirectory(fileAttributes) && file.isDirectory(); + } + + @Override + public int getResumeId() + { + return index; + } + + @Override + public boolean hasMoreFiles() + { + return index < files.size(); + } + + @Override + public boolean nextFileInfo(FileInfo info) + { + if (hasMoreFiles() == false) + { + return false; + } + Utils.populateFileInfo(info, files.get(index++)); + return true; + } + + @Override + public String nextFileName() + { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean restartAt(int resumeId) + { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean restartAt(FileInfo info) + { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/cifs/DataSetCifsView.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/cifs/DataSetCifsView.java index 76e990b42a15bb1368c8476bfb04b51e1d3f4ea0..f98a92b7be9db212badf094dffb3cc1d60200d59 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/cifs/DataSetCifsView.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/cifs/DataSetCifsView.java @@ -26,16 +26,25 @@ import org.alfresco.jlan.server.core.DeviceContext; import org.alfresco.jlan.server.core.DeviceContextException; import org.alfresco.jlan.server.filesys.DiskDeviceContext; import org.alfresco.jlan.server.filesys.DiskInterface; +import org.alfresco.jlan.server.filesys.FileAttribute; import org.alfresco.jlan.server.filesys.FileInfo; import org.alfresco.jlan.server.filesys.FileName; import org.alfresco.jlan.server.filesys.FileOpenParams; +import org.alfresco.jlan.server.filesys.FileStatus; import org.alfresco.jlan.server.filesys.NetworkFile; import org.alfresco.jlan.server.filesys.SearchContext; import org.alfresco.jlan.server.filesys.TreeConnection; +import org.apache.ftpserver.ftplet.FtpException; +import org.apache.ftpserver.ftplet.FtpFile; import org.apache.log4j.Logger; +import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel; import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogFactory; +import ch.systemsx.cisd.openbis.dss.generic.server.ftp.DSSFileSystemView; +import ch.systemsx.cisd.openbis.dss.generic.server.ftp.FtpPathResolverConfig; +import ch.systemsx.cisd.openbis.dss.generic.server.ftp.FtpPathResolverRegistry; +import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService; import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider; import ch.systemsx.cisd.openbis.generic.shared.IServiceForDataStoreServer; import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService; @@ -49,16 +58,21 @@ public class DataSetCifsView implements DiskInterface { private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION, DataSetCifsView.class); - private IServiceForDataStoreServer openBisService; + private IServiceForDataStoreServer dssService; private IGeneralInformationService generalInfoService; + private IEncapsulatedOpenBISService openBISService; + + private FtpPathResolverRegistry pathResolverRegistry; + public DataSetCifsView() { + System.err.println("create a new CIFS view instance"); } DataSetCifsView(IServiceForDataStoreServer openBisService, IGeneralInformationService generalInfoService) { - this.openBisService = openBisService; + this.dssService = openBisService; this.generalInfoService = generalInfoService; } @@ -67,6 +81,8 @@ public class DataSetCifsView implements DiskInterface { operationLog.info("create context for share " + shareName); System.out.println(Utils.render(args)); + FtpPathResolverConfig resolverConfig = new FtpPathResolverConfig(CifsServerConfig.getServerProperties()); + pathResolverRegistry = new FtpPathResolverRegistry(resolverConfig); return new DiskDeviceContext(shareName); } @@ -87,24 +103,25 @@ public class DataSetCifsView implements DiskInterface @Override public FileInfo getFileInformation(SrvSession sess, TreeConnection tree, String path) throws IOException { - String sessionToken = getSessionToken(sess); - System.err.println("session token:"+sessionToken); - String normalizedPath = FileName.buildPath(null, path, null, java.io.File.separatorChar); - System.out.println("DataSetCifsView.getFileInformation("+path+") "+normalizedPath); - System.out.println(sess.getClientInformation()); - if (normalizedPath.equals("/")) + DSSFileSystemView view = createView(sess); + String normalizedPath = normalizePath(path); + try { - System.out.println("ROOT"); + FtpFile file = view.getFile(normalizedPath); + FileInfo fileInfo = new FileInfo(); + Utils.populateFileInfo(fileInfo, file); + System.out.println("fileInfo:" + fileInfo+" file:"+file.getAbsolutePath()); + return fileInfo; + } catch (FtpException ex) + { + throw new IOException(ex); } - return new FileInfo(normalizedPath, 0, 0); } - + @Override public SearchContext startSearch(SrvSession sess, TreeConnection tree, String searchPath, int attrib) throws FileNotFoundException { - System.out.println("DataSetCifsView.startSearch() "+searchPath+" "+attrib); - // TODO Auto-generated method stub - return null; + return new DSSFileSearchContext(createView(sess), normalizePath(searchPath), attrib); } @Override @@ -117,8 +134,6 @@ public class DataSetCifsView implements DiskInterface public void closeFile(SrvSession sess, TreeConnection tree, NetworkFile param) throws IOException { System.out.println("DataSetCifsView.closeFile()"); - // TODO Auto-generated method stub - } @Override @@ -156,9 +171,22 @@ public class DataSetCifsView implements DiskInterface @Override public int fileExists(SrvSession sess, TreeConnection tree, String name) { - System.out.println("DataSetCifsView.fileExists()"); - // TODO Auto-generated method stub - return 0; + FtpFile file; + try + { + file = createView(sess).getFile(normalizePath(name)); + if (file == null) + { + return FileStatus.NotExist; + } else if (file.isDirectory()) + { + return FileStatus.DirectoryExists; + } + return FileStatus.FileExists; + } catch (FtpException ex) + { + throw CheckedExceptionTunnel.wrapIfNecessary(ex); + } } @Override @@ -172,9 +200,93 @@ public class DataSetCifsView implements DiskInterface @Override public NetworkFile openFile(SrvSession sess, TreeConnection tree, FileOpenParams params) throws IOException { - System.out.println("DataSetCifsView.openFile()"); - // TODO Auto-generated method stub - return null; + final String fullPath = normalizePath(params.getFullPath()); + String path = normalizePath(params.getPath()); + System.out.println("DataSetCifsView.openFile() "+params+" path:"+path+" fullPath:"+fullPath); + NetworkFile networkFile = new NetworkFile(path) + { + + @Override + public void writeFile(byte[] buf, int len, int pos, long fileOff) throws IOException + { + System.out.println("DataSetCifsView..openFile("+fullPath+").new NetworkFile() {...}.writeFile()"); + // TODO Auto-generated method stub + + } + + @Override + public void truncateFile(long siz) throws IOException + { + System.out.println("DataSetCifsView..openFile("+fullPath+").new NetworkFile() {...}.truncateFile()"); + // TODO Auto-generated method stub + + } + + @Override + public long seekFile(long pos, int typ) throws IOException + { + System.out.println("DataSetCifsView..openFile("+fullPath+").new NetworkFile() {...}.seekFile()"); + // TODO Auto-generated method stub + return 0; + } + + @Override + public int readFile(byte[] buf, int len, int pos, long fileOff) throws IOException + { + System.out.println("DataSetCifsView..openFile("+fullPath+").new NetworkFile() {...}.readFile()"); + // TODO Auto-generated method stub + return 0; + } + + @Override + public void openFile(boolean createFlag) throws IOException + { + System.out.println("DataSetCifsView..openFile("+fullPath+").new NetworkFile() {...}.openFile()"); + // TODO Auto-generated method stub + + } + + @Override + public void flushFile() throws IOException + { + System.out.println("DataSetCifsView..openFile("+fullPath+").new NetworkFile() {...}.flushFile()"); + // TODO Auto-generated method stub + + } + + @Override + public void closeFile() throws IOException + { + System.out.println("DataSetCifsView..openFile("+fullPath+").new NetworkFile() {...}.closeFile()"); + // TODO Auto-generated method stub + + } + + @Override + public String getName() + { + System.out.println("DataSetCifsView..openFile("+fullPath+").new NetworkFile() {...}.getName()"); + return super.getName(); + } + + @Override + public boolean hasModifyDate() + { + System.out.println("DataSetCifsView..openFile("+fullPath+").new NetworkFile() {...}.hasModifyDate()"); + return true; + } + + @Override + public void close() throws IOException + { + System.out.println("DataSetCifsView..openFile("+fullPath+").new NetworkFile() {...}.close()"); + // TODO Auto-generated method stub + super.close(); + } + + }; + networkFile.setAttributes(FileAttribute.Directory | FileAttribute.ReadOnly); + return networkFile; } @Override @@ -225,13 +337,30 @@ public class DataSetCifsView implements DiskInterface return 0; } - private IServiceForDataStoreServer getServiceForDataStoreServer() + private DSSFileSystemView createView(SrvSession session) { - if (openBisService == null) + try { - openBisService = ServiceProvider.getServiceForDSS(); + String sessionToken = getSessionToken(session); + return new DSSFileSystemView(sessionToken, getDssService(), getGeneralInfoService(), pathResolverRegistry); + } catch (FtpException ex) + { + throw CheckedExceptionTunnel.wrapIfNecessary(ex); } - return openBisService; + } + + private String normalizePath(String path) + { + return FileName.buildPath(null, path, null, java.io.File.separatorChar); + } + + private IServiceForDataStoreServer getDssService() + { + if (dssService == null) + { + dssService = ServiceProvider.getServiceForDSS(); + } + return dssService; } private IGeneralInformationService getGeneralInfoService() @@ -252,6 +381,4 @@ public class DataSetCifsView implements DiskInterface } return null; } - - } diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/cifs/Test.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/cifs/Test.java new file mode 100644 index 0000000000000000000000000000000000000000..bdd5395d8196181fa1777d21ede387f9eefec20d --- /dev/null +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/cifs/Test.java @@ -0,0 +1,123 @@ +/* + * Copyright 2016 ETH Zuerich, SIS + * + * 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.openbis.dss.generic.server.cifs; + +import java.io.StringReader; +import java.util.StringTokenizer; + +import javax.xml.bind.DatatypeConverter; + +import org.alfresco.jlan.app.XMLServerConfiguration; +import org.alfresco.jlan.server.auth.PasswordEncryptor; +import org.alfresco.jlan.server.auth.UserAccount; +import org.alfresco.jlan.server.config.ConfigurationListener; +import org.alfresco.jlan.server.config.InvalidConfigurationException; +import org.alfresco.jlan.server.config.ServerConfiguration; +import org.alfresco.jlan.smb.Dialect; +import org.alfresco.jlan.smb.DialectSelector; +import org.alfresco.jlan.smb.server.SMBServer; +import org.apache.commons.lang3.StringUtils; + +import ch.systemsx.cisd.common.logging.LogInitializer; +import ch.systemsx.cisd.common.string.Template; + + +/** + * + * + * @author Franz-Josef Elmer + */ +public class Test +{ + private static final Template CONFIG_TEMPLATE_XML = new Template("<jlanserver>\n" + + "<servers><SMB/></servers>\n" + + "<SMB>\n" + + " <host name='${host.name}' domain='${host.domain}'>\n" + + " <broadcast>${broadcast-mask}</broadcast>\n" + + " <smbdialects>${smb-dialects}</smbdialects>\n" + + " <tcpipSMB port='${smb-port}'/>\n" + + " </host>\n" + + " <authenticator type='enterprise'>\n" + + " <mode>USER</mode>\n" + + " </authenticator>\n" + + " <sessionDebug flags='${session-log-flags}'/>" + + "</SMB>\n" + + "<shares>\n" + + " <diskshare name='${share-name}'>\n" + + " <driver>\n" + + " <!--class>ch.systemsx.cisd.openbis.dss.generic.server.cifs.DataSetCifsView</class-->\n" + + " <class>org.alfresco.jlan.smb.server.disk.JavaFileDiskDriver</class>\n" + + " <LocalPath>/Users/felmer/tmp/playgrounds/unix</LocalPath>\n" + + " </driver>\n" + + " </diskshare>\n" + + "</shares>\n" + + "<debug>\n" + + " <output>\n" + + " <class>ch.systemsx.cisd.openbis.dss.generic.server.cifs.CifsServerLogger</class>\n" + + " <log-level>${log-level}</log-level>\n" + + " </output>\n" + + "</debug>\n" + + "<security>\n" + + " <JCEProvider>org.bouncycastle.jce.provider.BouncyCastleProvider</JCEProvider>\n" + + " <authenticator>\n" + + " <class>org.alfresco.jlan.server.auth.LocalAuthenticator</class>\n" + + " <mode>USER</mode>\n" + + " </authenticator>\n" + + " <users>\n" + + " <user name=\"jlansrv\">\n" + + " <password>jlan</password>\n" + + " <comment>System administrator</comment>\n" + + " <administrator/>\n" + + " </user>\n" + + " <user name=\"felmer\">\n" + + " <md4>e0fba38268d0ec66ef1cb452d5885e53</md4>\n" + + " </user>\n" + + " <user name=\"normal\">\n" + + " <password>normal</password>\n" + + " </user>\n" + + " </users>\n" + + " </security>\n" + + "</jlanserver>\n" + + ""); + + + public static void main(String[] args) throws Exception + { + LogInitializer.init(); + Template template = CONFIG_TEMPLATE_XML.createFreshCopy(); + template.bind("host.name", "ETHZ"); + template.bind("host.domain", "OPENBIS"); + template.bind("broadcast-mask", "255.255.255.255"); + template.bind("smb-dialects", "LanMan,NT"); + template.bind("smb-port", "1445"); + template.bind("session-log-flags", "Negotiate,Socket,Tree"); + template.bind("log-level", "INFO"); + template.bind("share-name", "STORE"); + XMLServerConfiguration configuration = new XMLServerConfiguration(); + configuration.loadConfiguration(new StringReader(template.createText())); + SMBServer server = new SMBServer(configuration); +// server.startServer(); + byte[] encryptedPassword = new PasswordEncryptor().generateEncryptedPassword("abc", null, PasswordEncryptor.MD4, "felmer", null); + UserAccount userAccount = new UserAccount(); + userAccount.setMD4Password(encryptedPassword); + System.out.println(userAccount); + byte[] bytes = DatatypeConverter.parseHexBinary("0f6f34abcd"); + System.out.println(DatatypeConverter.printHexBinary(bytes)); + System.out.println(">"+DatatypeConverter.printHexBinary(new byte[0])+"<"); + } + +} diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/cifs/Utils.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/cifs/Utils.java index 25462e3eeb36ee39dd013e487654173e70489d75..1133aeb12b402f65dc9943e98b9459fcc831d411 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/cifs/Utils.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/cifs/Utils.java @@ -20,6 +20,9 @@ import java.util.List; import java.util.Map; import org.alfresco.config.ConfigElement; +import org.alfresco.jlan.server.filesys.FileAttribute; +import org.alfresco.jlan.server.filesys.FileInfo; +import org.apache.ftpserver.ftplet.FtpFile; /** * @@ -54,5 +57,27 @@ class Utils } } + static void populateFileInfo(FileInfo fileInfo, FtpFile file) + { + fileInfo.setFileName(file.getName()); + fileInfo.setModifyDateTime(file.getLastModified()); + fileInfo.setSize(file.getSize()); + int attr = 0; + if (file.isDirectory()) + { + attr |= FileAttribute.Directory; + } + if (file.isHidden()) + { + attr |= FileAttribute.Hidden; + } + if (file.isWritable() == false) + { + attr |= FileAttribute.ReadOnly; + } + fileInfo.setFileAttributes(attr); + fileInfo.setFileId(file.getAbsolutePath().hashCode()); + } + } diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/DSSFileSystemView.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/DSSFileSystemView.java index 8c05d972492e1e59469be0b5b8fdc411e8b03a5a..39887e7fc842f58bfb5e17eacb67203675c1e473 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/DSSFileSystemView.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/DSSFileSystemView.java @@ -104,7 +104,7 @@ public class DSSFileSystemView implements FileSystemView private final IFtpPathResolverRegistry pathResolverRegistry; - DSSFileSystemView(String sessionToken, final IServiceForDataStoreServer service, + public DSSFileSystemView(String sessionToken, final IServiceForDataStoreServer service, IGeneralInformationService generalInfoService, IFtpPathResolverRegistry pathResolverRegistry) throws FtpException { diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpPathResolverConfig.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpPathResolverConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..e553f1105b93772109fc8a929e5c952875c8d454 --- /dev/null +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpPathResolverConfig.java @@ -0,0 +1,129 @@ +/* + * Copyright 2016 ETH Zuerich, SIS + * + * 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.openbis.dss.generic.server.ftp; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.Map.Entry; + +import org.apache.log4j.Logger; + +import ch.systemsx.cisd.common.logging.LogCategory; +import ch.systemsx.cisd.common.logging.LogFactory; +import ch.systemsx.cisd.common.properties.ExtendedProperties; +import ch.systemsx.cisd.common.properties.PropertyUtils; + +/** + * + * + * @author Franz-Josef Elmer + */ +public class FtpPathResolverConfig +{ + final static String DATASET_DISPLAY_TEMPLATE_KEY = "dataset.display.template"; + + final static String SHOW_PARENTS_AND_CHILDREN_KEY = "dataset.show-parents-and-children"; + + final static String DATASET_FILELIST_SUBPATH_KEY = "dataset.filelist.subpath."; + + final static String DATASET_FILELIST_FILTER_KEY = "dataset.filelist.filter."; + + private static final String DEFAULT_DATASET_TEMPLATE = "${dataSetCode}"; + + private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION, + FtpPathResolverConfig.class); + + private boolean showParentsAndChildren; + + private String dataSetDisplayTemplate = ""; + + private Map<String /* dataset type */, String /* path */> fileListSubPaths = + new HashMap<String, String>(); + + private Map<String /* dataset type */, String /* filter pattern */> fileListFilters = + new HashMap<String, String>(); + + public FtpPathResolverConfig(Properties props) + { + dataSetDisplayTemplate = + PropertyUtils.getProperty(props, DATASET_DISPLAY_TEMPLATE_KEY, DEFAULT_DATASET_TEMPLATE); + showParentsAndChildren = PropertyUtils.getBoolean(props, SHOW_PARENTS_AND_CHILDREN_KEY, false); + + ExtendedProperties fileListSubPathProps = + ExtendedProperties.getSubset(props, DATASET_FILELIST_SUBPATH_KEY, true); + for (Object key : fileListSubPathProps.keySet()) + { + String dataSetType = key.toString(); + String subPath = fileListSubPathProps.getProperty(dataSetType); + fileListSubPaths.put(dataSetType, subPath); + + } + + ExtendedProperties fileListFilterProps = + ExtendedProperties.getSubset(props, DATASET_FILELIST_FILTER_KEY, true); + for (Object key : fileListFilterProps.keySet()) + { + String dataSetType = key.toString(); + String filter = fileListFilterProps.getProperty(dataSetType); + fileListFilters.put(dataSetType, filter); + } + } + + public String getDataSetDisplayTemplate() + { + return dataSetDisplayTemplate; + } + + public boolean isShowParentsAndChildren() + { + return showParentsAndChildren; + } + + public Map<String, String> getFileListSubPaths() + { + return Collections.unmodifiableMap(fileListSubPaths); + } + + public Map<String, String> getFileListFilters() + { + return Collections.unmodifiableMap(fileListFilters); + } + + public void logStartupInfo(String serverType) + { + operationLog.info(serverType + " Server data set display template : " + dataSetDisplayTemplate); + + for (Entry<String, String> subpathEntry : fileListSubPaths.entrySet()) + { + String message = + String.format("%s Server subpath configuration for data " + + "set type '%s' : '%s'", serverType, subpathEntry.getKey(), + subpathEntry.getValue()); + operationLog.info(message); + } + for (Entry<String, String> filterEntry : fileListFilters.entrySet()) + { + String message = + String.format("%s Server file filter configuration for data " + + "set type '%s' : '%s'", serverType, filterEntry.getKey(), filterEntry.getValue()); + operationLog.info(message); + } + + } +} diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpPathResolverRegistry.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpPathResolverRegistry.java index 4cc09ea8f077871275f86e34b7c28ac7344b353c..9bb84f1f5d04b449067423abb93c6b7e2258ece5 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpPathResolverRegistry.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpPathResolverRegistry.java @@ -51,13 +51,13 @@ public class FtpPathResolverRegistry implements IFtpPathResolverRegistry /** * initializes the registry with all known {@link IFtpPathResolver}-s. */ - public FtpPathResolverRegistry(FtpServerConfig ftpServerConfig) + public FtpPathResolverRegistry(FtpPathResolverConfig config) { pathResolvers.add(new RootFolderResolver()); pathResolvers.add(new SpaceFolderResolver()); pathResolvers.add(new ProjectFolderResolver()); TemplateBasedDataSetResourceResolver dataSetResolver = - new TemplateBasedDataSetResourceResolver(ftpServerConfig); + new TemplateBasedDataSetResourceResolver(config); pathResolvers.add(new ExperimentFolderResolver(dataSetResolver)); pathResolvers.add(dataSetResolver); } diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpServer.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpServer.java index 3116df6c32f0c729e292e77b79d1287d4f5ae737..9faca9395dae552d872b5d5a2a38c77a5feb6302 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpServer.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpServer.java @@ -31,6 +31,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.Enumeration; import java.util.List; +import java.util.Properties; import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManagerFactory; @@ -73,6 +74,7 @@ import ch.systemsx.cisd.common.exceptions.ConfigurationFailureException; import ch.systemsx.cisd.common.filesystem.FileUtilities; import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogFactory; +import ch.systemsx.cisd.common.properties.PropertyParametersUtil; import ch.systemsx.cisd.common.utilities.SystemTimeProvider; import ch.systemsx.cisd.openbis.dss.generic.shared.utils.DssPropertyParametersUtil; import ch.systemsx.cisd.openbis.generic.shared.IServiceForDataStoreServer; @@ -110,12 +112,16 @@ public class FtpServer implements FileSystemFactory, org.apache.sshd.server.File this.openBisService = openBisService; this.generalInfoService = generalInfoService; this.userManager = userManager; - this.config = new FtpServerConfig(DssPropertyParametersUtil.loadServiceProperties()); - this.pathResolverRegistry = new FtpPathResolverRegistry(config); + Properties ftpProperties = PropertyParametersUtil.extractSingleSectionProperties( + DssPropertyParametersUtil.loadServiceProperties(), "ftp.server", false).getProperties(); + this.config = new FtpServerConfig(ftpProperties); + FtpPathResolverConfig resolverConfig = new FtpPathResolverConfig(ftpProperties); + this.pathResolverRegistry = new FtpPathResolverRegistry(resolverConfig); if (config.isStartServer()) { config.logStartupInfo(); + resolverConfig.logStartupInfo("SFTP/FTP"); start(); } } diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpServerConfig.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpServerConfig.java index 4d7be7e0b0bc353d76c2c52b1422cfcc5433cc28..ca1d9c734ae2034409f0ad844588475ce0120f7a 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpServerConfig.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpServerConfig.java @@ -17,17 +17,12 @@ package ch.systemsx.cisd.openbis.dss.generic.server.ftp; import java.io.File; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; import java.util.Properties; import org.apache.log4j.Logger; import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogFactory; -import ch.systemsx.cisd.common.properties.ExtendedProperties; import ch.systemsx.cisd.common.properties.PropertyUtils; import ch.systemsx.cisd.openbis.dss.generic.server.ConfigParameters; @@ -39,35 +34,25 @@ public class FtpServerConfig private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION, FtpServerConfig.class); - private final static String PREFIX = "ftp.server."; + final static String ENABLE_KEY = "enable"; - final static String ENABLE_KEY = PREFIX + "enable"; + final static String SFTP_PORT_KEY = "sftp-port"; - final static String SFTP_PORT_KEY = PREFIX + "sftp-port"; + final static String LEGACY_FTP_PORT_KEY = "port"; - final static String LEGACY_FTP_PORT_KEY = PREFIX + "port"; + final static String FTP_PORT_KEY = "ftp-port"; - final static String FTP_PORT_KEY = PREFIX + "ftp-port"; + final static String USE_SSL_KEY = "use-ssl"; - final static String USE_SSL_KEY = PREFIX + "use-ssl"; + final static String IMPLICIT_SSL_KEY = "implicit-ssl"; - final static String IMPLICIT_SSL_KEY = PREFIX + "implicit-ssl"; + final static String MAX_THREADS_KEY = "maxThreads"; - final static String MAX_THREADS_KEY = PREFIX + "maxThreads"; + final static String ACTIVE_MODE_ENABLE_KEY = "activemode.enable"; - final static String DATASET_DISPLAY_TEMPLATE_KEY = PREFIX + "dataset.display.template"; + final static String ACTIVE_PORT_KEY = "activemode.port"; - final static String DATASET_FILELIST_SUBPATH_KEY = PREFIX + "dataset.filelist.subpath."; - - final static String DATASET_FILELIST_FILTER_KEY = PREFIX + "dataset.filelist.filter."; - - final static String ACTIVE_MODE_ENABLE_KEY = PREFIX + "activemode.enable"; - - final static String ACTIVE_PORT_KEY = PREFIX + "activemode.port"; - - final static String PASSIVE_MODE_PORT_RANGE_KEY = PREFIX + "passivemode.port.range"; - - final static String SHOW_PARENTS_AND_CHILDREN_KEY = PREFIX + "dataset.show-parents-and-children"; + final static String PASSIVE_MODE_PORT_RANGE_KEY = "passivemode.port.range"; private static final int DEFAULT_ACTIVE_PORT = 2122; @@ -77,8 +62,6 @@ public class FtpServerConfig private static final int DEFAULT_MAX_THREADS = 25; - private static final String DEFAULT_DATASET_TEMPLATE = "${dataSetCode}"; - private static final String DEFAULT_PASSIVE_PORTS = "2130-2140"; private boolean startServer; @@ -103,18 +86,8 @@ public class FtpServerConfig private String keyStorePassword; - private String dataSetDisplayTemplate = ""; - private int maxThreads; - private Map<String /* dataset type */, String /* path */> fileListSubPaths = - new HashMap<String, String>(); - - private Map<String /* dataset type */, String /* filter pattern */> fileListFilters = - new HashMap<String, String>(); - - private boolean showParentsAndChildren; - private boolean sftpMode; private int sftpPort; @@ -149,29 +122,6 @@ public class FtpServerConfig PropertyUtils .getProperty(props, PASSIVE_MODE_PORT_RANGE_KEY, DEFAULT_PASSIVE_PORTS); maxThreads = PropertyUtils.getPosInt(props, MAX_THREADS_KEY, DEFAULT_MAX_THREADS); - dataSetDisplayTemplate = - PropertyUtils.getProperty(props, DATASET_DISPLAY_TEMPLATE_KEY, DEFAULT_DATASET_TEMPLATE); - showParentsAndChildren = PropertyUtils.getBoolean(props, SHOW_PARENTS_AND_CHILDREN_KEY, false); - - ExtendedProperties fileListSubPathProps = - ExtendedProperties.getSubset(props, DATASET_FILELIST_SUBPATH_KEY, true); - for (Object key : fileListSubPathProps.keySet()) - { - String dataSetType = key.toString(); - String subPath = fileListSubPathProps.getProperty(dataSetType); - fileListSubPaths.put(dataSetType, subPath); - - } - - ExtendedProperties fileListFilterProps = - ExtendedProperties.getSubset(props, DATASET_FILELIST_FILTER_KEY, true); - for (Object key : fileListFilterProps.keySet()) - { - String dataSetType = key.toString(); - String filter = fileListFilterProps.getProperty(dataSetType); - fileListFilters.put(dataSetType, filter); - } - } private void initializeSSLProperties(Properties props) @@ -242,26 +192,6 @@ public class FtpServerConfig return maxThreads; } - public String getDataSetDisplayTemplate() - { - return dataSetDisplayTemplate; - } - - public boolean isShowParentsAndChildren() - { - return showParentsAndChildren; - } - - public Map<String, String> getFileListSubPaths() - { - return Collections.unmodifiableMap(fileListSubPaths); - } - - public Map<String, String> getFileListFilters() - { - return Collections.unmodifiableMap(fileListFilters); - } - /** * information being logged on FTP server startup. */ @@ -282,23 +212,6 @@ public class FtpServerConfig { operationLog.info("SFTP Server port: " + sftpPort); } - operationLog.info("SFTP/FTP Server data set display template : " + dataSetDisplayTemplate); - - for (Entry<String, String> subpathEntry : fileListSubPaths.entrySet()) - { - String message = - String.format("SFTP/FTP Server subpath configuration for data " - + "set type '%s' : '%s'", subpathEntry.getKey(), - subpathEntry.getValue()); - operationLog.info(message); - } - for (Entry<String, String> filterEntry : fileListFilters.entrySet()) - { - String message = - String.format("SFTP/FTP Server file filter configuration for data " - + "set type '%s' : '%s'", filterEntry.getKey(), filterEntry.getValue()); - operationLog.info(message); - } } public boolean isActiveModeEnabled() diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/resolver/TemplateBasedDataSetResourceResolver.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/resolver/TemplateBasedDataSetResourceResolver.java index 59639f67d8395a733f5d50f359293c356d65bcaf..0fbb210d817db610b963228b3da244a03dce7515 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/resolver/TemplateBasedDataSetResourceResolver.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/resolver/TemplateBasedDataSetResourceResolver.java @@ -41,9 +41,9 @@ import ch.systemsx.cisd.openbis.common.io.hierarchical_content.api.IHierarchical import ch.systemsx.cisd.openbis.common.io.hierarchical_content.api.IHierarchicalContentNode; import ch.systemsx.cisd.openbis.dss.generic.server.ftp.FtpConstants; import ch.systemsx.cisd.openbis.dss.generic.server.ftp.FtpFileFactory; +import ch.systemsx.cisd.openbis.dss.generic.server.ftp.FtpPathResolverConfig; import ch.systemsx.cisd.openbis.dss.generic.server.ftp.FtpPathResolverContext; import ch.systemsx.cisd.openbis.dss.generic.server.ftp.FtpPathResolverRegistry; -import ch.systemsx.cisd.openbis.dss.generic.server.ftp.FtpServerConfig; import ch.systemsx.cisd.openbis.dss.generic.server.ftp.IFtpPathResolver; import ch.systemsx.cisd.openbis.dss.generic.server.ftp.resolver.FtpFileEvaluationContext.EvaluatedElement; import ch.systemsx.cisd.openbis.dss.generic.shared.IHierarchicalContentProvider; @@ -51,8 +51,8 @@ import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider; import ch.systemsx.cisd.openbis.generic.shared.IServiceForDataStoreServer; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.AbstractExternalData; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment; /** * Resolves paths like @@ -200,17 +200,17 @@ public class TemplateBasedDataSetResourceResolver implements IFtpPathResolver, private IHierarchicalContentProvider contentProvider; - public TemplateBasedDataSetResourceResolver(FtpServerConfig ftpServerConfig) + public TemplateBasedDataSetResourceResolver(FtpPathResolverConfig resolverConfig) { - this.template = new Template(ftpServerConfig.getDataSetDisplayTemplate()); - showParentsAndChildren = ftpServerConfig.isShowParentsAndChildren(); + this.template = new Template(resolverConfig.getDataSetDisplayTemplate()); + showParentsAndChildren = resolverConfig.isShowParentsAndChildren(); fileNamePresent = template.getPlaceholderNames().contains(FILE_NAME_VARNAME); if (fileNamePresent && showParentsAndChildren) { throw new ConfigurationFailureException("Template contains file name variable and " + "the flag to show parents/children data sets is set."); } - this.dataSetTypeConfigs = initializeDataSetTypeConfigs(ftpServerConfig); + this.dataSetTypeConfigs = initializeDataSetTypeConfigs(resolverConfig); this.defaultDSTypeConfig = new DataSetTypeConfig(); } @@ -598,11 +598,11 @@ public class TemplateBasedDataSetResourceResolver implements IFtpPathResolver, } private Map<String, DataSetTypeConfig> initializeDataSetTypeConfigs( - FtpServerConfig ftpServerConfig) + FtpPathResolverConfig resolverConfig) { Map<String, DataSetTypeConfig> result = new HashMap<String, DataSetTypeConfig>(); - Map<String, String> fileListSubPaths = ftpServerConfig.getFileListSubPaths(); - Map<String, String> fileListFilters = ftpServerConfig.getFileListFilters(); + Map<String, String> fileListSubPaths = resolverConfig.getFileListSubPaths(); + Map<String, String> fileListFilters = resolverConfig.getFileListFilters(); for (Entry<String, String> subPathEntry : fileListSubPaths.entrySet()) { diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpServerConfigBuilder.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/ResolverConfigBuilder.java similarity index 50% rename from datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpServerConfigBuilder.java rename to datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/ResolverConfigBuilder.java index 26b25e453eb0ce65b949a1cd6514980cad721b0c..fab9ff464d2d18aff6abed413e1ace8174f70d86 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpServerConfigBuilder.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/ResolverConfigBuilder.java @@ -23,50 +23,43 @@ import java.util.Properties; * * @author Kaloyan Enimanev */ -public class FtpServerConfigBuilder +public class ResolverConfigBuilder { private Properties props = new Properties(); - public FtpServerConfig getConfig() + public FtpPathResolverConfig getConfig() { - return new FtpServerConfig(props); + return new FtpPathResolverConfig(props); } - public FtpServerConfigBuilder() + public ResolverConfigBuilder() { - this(true, false); } - public FtpServerConfigBuilder(boolean enable, boolean useSSL) + public ResolverConfigBuilder showParentsAndChildren() { - props.put(FtpServerConfig.ENABLE_KEY, String.valueOf(enable)); - props.put(FtpServerConfig.USE_SSL_KEY, String.valueOf(useSSL)); - } - - public FtpServerConfigBuilder showParentsAndChildren() - { - props.setProperty(FtpServerConfig.SHOW_PARENTS_AND_CHILDREN_KEY, Boolean.TRUE.toString()); + props.setProperty(FtpPathResolverConfig.SHOW_PARENTS_AND_CHILDREN_KEY, Boolean.TRUE.toString()); return this; } - public FtpServerConfigBuilder withTemplate(String template) + public ResolverConfigBuilder withTemplate(String template) { - props.setProperty(FtpServerConfig.DATASET_DISPLAY_TEMPLATE_KEY, template); + props.setProperty(FtpPathResolverConfig.DATASET_DISPLAY_TEMPLATE_KEY, template); return this; } - public FtpServerConfigBuilder withFileListFilter(String dataSetType, String filterPattern) + public ResolverConfigBuilder withFileListFilter(String dataSetType, String filterPattern) { - String key = FtpServerConfig.DATASET_FILELIST_FILTER_KEY + dataSetType; + String key = FtpPathResolverConfig.DATASET_FILELIST_FILTER_KEY + dataSetType; props.setProperty(key, filterPattern); return this; } - public FtpServerConfigBuilder withFileListSubPath(String dataSetType, String subPathPattern) + public ResolverConfigBuilder withFileListSubPath(String dataSetType, String subPathPattern) { - String key = FtpServerConfig.DATASET_FILELIST_SUBPATH_KEY + dataSetType; + String key = FtpPathResolverConfig.DATASET_FILELIST_SUBPATH_KEY + dataSetType; props.setProperty(key, subPathPattern); return this; } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/resolver/TemplateBasedDataSetResourceResolverTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/resolver/TemplateBasedDataSetResourceResolverTest.java index b8142cf933c0928434ca18dc55b1a731f2983e6f..1d5c934fb23fcde6d5a52e5faa4130a32dcf3f7a 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/resolver/TemplateBasedDataSetResourceResolverTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/resolver/TemplateBasedDataSetResourceResolverTest.java @@ -27,6 +27,7 @@ import java.util.Collections; import java.util.Date; import java.util.EnumSet; import java.util.List; +import java.util.Properties; import org.apache.commons.io.IOUtils; import org.apache.ftpserver.ftplet.FtpFile; @@ -49,9 +50,9 @@ import ch.systemsx.cisd.openbis.common.io.hierarchical_content.api.IHierarchical import ch.systemsx.cisd.openbis.common.io.hierarchical_content.api.IHierarchicalContentNode; import ch.systemsx.cisd.openbis.dss.generic.server.ftp.Cache; import ch.systemsx.cisd.openbis.dss.generic.server.ftp.FtpConstants; +import ch.systemsx.cisd.openbis.dss.generic.server.ftp.FtpPathResolverConfig; import ch.systemsx.cisd.openbis.dss.generic.server.ftp.FtpPathResolverContext; -import ch.systemsx.cisd.openbis.dss.generic.server.ftp.FtpServerConfig; -import ch.systemsx.cisd.openbis.dss.generic.server.ftp.FtpServerConfigBuilder; +import ch.systemsx.cisd.openbis.dss.generic.server.ftp.ResolverConfigBuilder; import ch.systemsx.cisd.openbis.dss.generic.shared.IHierarchicalContentProvider; import ch.systemsx.cisd.openbis.generic.shared.IServiceForDataStoreServer; import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService; @@ -59,11 +60,11 @@ import ch.systemsx.cisd.openbis.generic.shared.api.v1.Translator; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet.Connections; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetFetchOption; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PhysicalDataSet; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.AbstractExternalData; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExperimentFetchOptions; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.AbstractExternalData; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IDatasetLocation; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PhysicalDataSet; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.builders.DataSetBuilder; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifier; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifierFactory; @@ -251,8 +252,8 @@ public class TemplateBasedDataSetResourceResolverTest extends AbstractFileSystem @Test public void testInvalidConfig() { - FtpServerConfig config = - new FtpServerConfigBuilder().withTemplate(TEMPLATE_WITH_FILENAMES) + FtpPathResolverConfig config = + new ResolverConfigBuilder().withTemplate(TEMPLATE_WITH_FILENAMES) .showParentsAndChildren().getConfig(); try { @@ -268,8 +269,8 @@ public class TemplateBasedDataSetResourceResolverTest extends AbstractFileSystem @Test public void testWithParentsTopLevel() { - FtpServerConfig config = - new FtpServerConfigBuilder().withTemplate(BIG_TEMPLATE).showParentsAndChildren() + FtpPathResolverConfig config = + new ResolverConfigBuilder().withTemplate(BIG_TEMPLATE).showParentsAndChildren() .getConfig(); resolver = new TemplateBasedDataSetResourceResolver(config); resolver.setContentProvider(simpleFileContentProvider); @@ -300,8 +301,8 @@ public class TemplateBasedDataSetResourceResolverTest extends AbstractFileSystem @Test public void testChildOfParent() { - FtpServerConfig config = - new FtpServerConfigBuilder().withTemplate(BIG_TEMPLATE).showParentsAndChildren() + FtpPathResolverConfig config = + new ResolverConfigBuilder().withTemplate(BIG_TEMPLATE).showParentsAndChildren() .getConfig(); resolver = new TemplateBasedDataSetResourceResolver(config); resolver.setContentProvider(simpleFileContentProvider); @@ -339,8 +340,8 @@ public class TemplateBasedDataSetResourceResolverTest extends AbstractFileSystem @Test public void testAvoidInfiniteParentChildChains() { - FtpServerConfig config = - new FtpServerConfigBuilder().withTemplate(BIG_TEMPLATE).showParentsAndChildren() + FtpPathResolverConfig config = + new ResolverConfigBuilder().withTemplate(BIG_TEMPLATE).showParentsAndChildren() .getConfig(); resolver = new TemplateBasedDataSetResourceResolver(config); resolver.setContentProvider(simpleFileContentProvider); @@ -375,8 +376,8 @@ public class TemplateBasedDataSetResourceResolverTest extends AbstractFileSystem @Test public void testResolveNestedFilesWithSimpleTemplate() throws IOException { - FtpServerConfig config = - new FtpServerConfigBuilder().withTemplate(SIMPLE_TEMPLATE).showParentsAndChildren() + FtpPathResolverConfig config = + new ResolverConfigBuilder().withTemplate(SIMPLE_TEMPLATE).showParentsAndChildren() .getConfig(); resolver = new TemplateBasedDataSetResourceResolver(config); resolver.setContentProvider(simpleFileContentProvider); @@ -409,8 +410,8 @@ public class TemplateBasedDataSetResourceResolverTest extends AbstractFileSystem @Test public void testHierarchicalContentClosed() throws IOException { - FtpServerConfig config = - new FtpServerConfigBuilder().withTemplate(SIMPLE_TEMPLATE).getConfig(); + FtpPathResolverConfig config = + new ResolverConfigBuilder().withTemplate(SIMPLE_TEMPLATE).getConfig(); resolver = new TemplateBasedDataSetResourceResolver(config); resolver.setContentProvider(hierarchicalContentProvider); @@ -488,8 +489,8 @@ public class TemplateBasedDataSetResourceResolverTest extends AbstractFileSystem @Test public void testSubPathAndFileFilters() { - FtpServerConfig config = - new FtpServerConfigBuilder().withTemplate(TEMPLATE_WITH_FILENAMES) + FtpPathResolverConfig config = + new ResolverConfigBuilder().withTemplate(TEMPLATE_WITH_FILENAMES) .withFileListSubPath(DS_TYPE1, "orig[^/]*") .withFileListFilter(DS_TYPE1, "[^.]*\\.txt").getConfig(); resolver = new TemplateBasedDataSetResourceResolver(config);