Skip to content
Snippets Groups Projects
Commit fb404e19 authored by vkovtun's avatar vkovtun
Browse files

BIS-772: Work in progress.

parent 8d03aaa6
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
...@@ -129,13 +129,11 @@ import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.fetchoptions.SampleTypeFe ...@@ -129,13 +129,11 @@ import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.fetchoptions.SampleTypeFe
import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.search.SampleTypeSearchCriteria; import ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.search.SampleTypeSearchCriteria;
import ch.ethz.sis.openbis.generic.asapi.v3.dto.space.Space; import ch.ethz.sis.openbis.generic.asapi.v3.dto.space.Space;
import ch.ethz.sis.openbis.generic.asapi.v3.exceptions.NotFetchedException; import ch.ethz.sis.openbis.generic.asapi.v3.exceptions.NotFetchedException;
import ch.ethz.sis.openbis.generic.dssapi.v3.IDataStoreServerApi;
import ch.ethz.sis.openbis.generic.dssapi.v3.dto.datasetfile.DataSetFile; import ch.ethz.sis.openbis.generic.dssapi.v3.dto.datasetfile.DataSetFile;
import ch.ethz.sis.openbis.generic.dssapi.v3.dto.datasetfile.fetchoptions.DataSetFileFetchOptions; import ch.ethz.sis.openbis.generic.dssapi.v3.dto.datasetfile.fetchoptions.DataSetFileFetchOptions;
import ch.ethz.sis.openbis.generic.dssapi.v3.dto.datasetfile.search.DataSetFileSearchCriteria; import ch.ethz.sis.openbis.generic.dssapi.v3.dto.datasetfile.search.DataSetFileSearchCriteria;
import ch.ethz.sis.openbis.generic.server.asapi.v3.IApplicationServerInternalApi; import ch.ethz.sis.openbis.generic.server.asapi.v3.IApplicationServerInternalApi;
import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.IOperationContext; import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.IOperationContext;
import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.common.search.AbstractSearchObjectsOperationExecutor;
import ch.ethz.sis.openbis.generic.server.xls.export.ExportableKind; import ch.ethz.sis.openbis.generic.server.xls.export.ExportableKind;
import ch.ethz.sis.openbis.generic.server.xls.export.ExportablePermId; import ch.ethz.sis.openbis.generic.server.xls.export.ExportablePermId;
import ch.ethz.sis.openbis.generic.server.xls.export.XLSExport; import ch.ethz.sis.openbis.generic.server.xls.export.XLSExport;
...@@ -222,11 +220,13 @@ public class ExportExecutor implements IExportExecutor ...@@ -222,11 +220,13 @@ public class ExportExecutor implements IExportExecutor
private static final Logger OPERATION_LOG = LogFactory.getLogger(LogCategory.OPERATION, ExportExecutor.class); private static final Logger OPERATION_LOG = LogFactory.getLogger(LogCategory.OPERATION, ExportExecutor.class);
/** All characters except the ones we consider safe as a folder name. */
private static final String UNSAFE_CHARACTERS_REGEXP = "[^\\w $!#%'()+,\\-.;=@\\[\\]^{}_~]";
@Autowired @Autowired
private ISessionWorkspaceProvider sessionWorkspaceProvider; private ISessionWorkspaceProvider sessionWorkspaceProvider;
@Autowired // private IDataStoreServerApi v3Dss = (IDataStoreServerApi) ServiceProvider.getDssServiceV3().getService();
private IDataStoreServerApi v3Dss;
@Resource(name = ExposablePropertyPlaceholderConfigurer.PROPERTY_CONFIGURER_BEAN_NAME) @Resource(name = ExposablePropertyPlaceholderConfigurer.PROPERTY_CONFIGURER_BEAN_NAME)
private ExposablePropertyPlaceholderConfigurer configurer; private ExposablePropertyPlaceholderConfigurer configurer;
...@@ -974,13 +974,18 @@ public class ExportExecutor implements IExportExecutor ...@@ -974,13 +974,18 @@ public class ExportExecutor implements IExportExecutor
{ {
try try
{ {
return entity.getVarcharProperty(NAME_PROPERTY_NAME); return escapeUnsafeCharacters(entity.getVarcharProperty(NAME_PROPERTY_NAME));
} catch (final NotFetchedException e) } catch (final NotFetchedException e)
{ {
return null; return null;
} }
} }
static String escapeUnsafeCharacters(final String name)
{
return name.replaceAll(UNSAFE_CHARACTERS_REGEXP, "_");
}
private static void exportXls(final ZipOutputStream zos, final BufferedOutputStream bos, final XLSExport.PrepareWorkbookResult xlsExportResult, private static void exportXls(final ZipOutputStream zos, final BufferedOutputStream bos, final XLSExport.PrepareWorkbookResult xlsExportResult,
final Workbook wb, final Collection<String> warnings) throws IOException final Workbook wb, final Collection<String> warnings) throws IOException
{ {
......
...@@ -347,4 +347,12 @@ public class ExportExecutorTest ...@@ -347,4 +347,12 @@ public class ExportExecutorTest
ExportExecutor.getFolderName(prefix, spaceCode, projectCode, containerCode, entityCode, entityName); ExportExecutor.getFolderName(prefix, spaceCode, projectCode, containerCode, entityCode, entityName);
} }
@Test()
public void testEscapeUnsafeCharacters()
{
final String input = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 $!#%'()+,-.;=@[]^_{}~\\/:*?\"<>|`";
final String expectedOutput = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 $!#%'()+,-.;=@[]^_{}~__________";
assertEquals(ExportExecutor.escapeUnsafeCharacters(input), expectedOutput);
}
} }
\ No newline at end of file
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