Package org.openrefine.importing
Class ImportingUtilities
- java.lang.Object
-
- org.openrefine.importing.ImportingUtilities
-
public class ImportingUtilities extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceImportingUtilities.Progress
-
Field Summary
Fields Modifier and Type Field Description static List<String>allowedProtocolsprotected static org.slf4j.Loggerlogger
-
Constructor Summary
Constructors Constructor Description ImportingUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FileallocateFile(File dir, String name)static longcreateProject(ImportingJob job, String format, com.fasterxml.jackson.databind.node.ObjectNode optionObj, Runner runner, List<Exception> exceptions, boolean synchronous)static ProjectMetadatacreateProjectMetadata(com.fasterxml.jackson.databind.node.ObjectNode optionObj)protected static StringextractFilenameFromSparkURI(String uri)Attempts to extract a filename from a Spark URI.static StringgetArchiveFileName(com.fasterxml.jackson.databind.node.ObjectNode fileRecord)static ReadergetFileReader(File file, ImportingFileRecord fileRecord, String commonEncoding)static ReadergetFileReader(ImportingJob job, ImportingFileRecord fileRecord, String commonEncoding)static StringgetRelativePath(File file, File dir)static booleanhasArchiveFileField(List<com.fasterxml.jackson.databind.node.ObjectNode> fileRecords)static voidloadDataAndPrepareJob(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Properties parameters, ImportingJob job)static StringnormalizePath(String path)Replace the illegal character with '-' in the path in Windowsstatic booleanpostProcessRetrievedFile(File rawDataDir, File file, ImportingFileRecord fileRecord, List<ImportingFileRecord> fileRecords, ImportingUtilities.Progress progress)static voidpostProcessSingleRetrievedFile(File file, ImportingFileRecord fileRecord)static voidpreviewParse(ImportingJob job, String format, com.fasterxml.jackson.databind.node.ObjectNode optionObj, Runner runner, List<Exception> exceptions)static voidretrieveContentFromPostRequest(javax.servlet.http.HttpServletRequest request, Properties parameters, File rawDataDir, ImportingJob.RetrievalRecord retrievalRecord, ImportingUtilities.Progress progress)static InputStreamtryOpenAsArchive(File file, String mimeType)static InputStreamtryOpenAsArchive(File file, String mimeType, String contentType)static InputStreamtryOpenAsCompressedFile(File file, String mimeType)static InputStreamtryOpenAsCompressedFile(File file, String mimeType, String contentEncoding)static FileuncompressFile(File rawDataDir, InputStream uncompressedIS, ImportingFileRecord fileRecord, ImportingUtilities.Progress progress)
-
-
-
Method Detail
-
loadDataAndPrepareJob
public static void loadDataAndPrepareJob(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Properties parameters, ImportingJob job) throws IOException, javax.servlet.ServletException- Throws:
IOExceptionjavax.servlet.ServletException
-
retrieveContentFromPostRequest
public static void retrieveContentFromPostRequest(javax.servlet.http.HttpServletRequest request, Properties parameters, File rawDataDir, ImportingJob.RetrievalRecord retrievalRecord, ImportingUtilities.Progress progress) throws IOException, org.apache.commons.fileupload.FileUploadException- Throws:
IOExceptionorg.apache.commons.fileupload.FileUploadException
-
extractFilenameFromSparkURI
protected static String extractFilenameFromSparkURI(String uri)
Attempts to extract a filename from a Spark URI.- Parameters:
uri- the spark URI- Returns:
- null if it does not succeed, or if there is no final name in the path
-
normalizePath
public static String normalizePath(String path)
Replace the illegal character with '-' in the path in Windows- Parameters:
path- : file path- Returns:
- the replaced path or original path if the OS is not Windows
-
getFileReader
public static Reader getFileReader(ImportingJob job, ImportingFileRecord fileRecord, String commonEncoding) throws FileNotFoundException
- Throws:
FileNotFoundException
-
getFileReader
public static Reader getFileReader(File file, ImportingFileRecord fileRecord, String commonEncoding) throws FileNotFoundException
- Throws:
FileNotFoundException
-
getArchiveFileName
public static String getArchiveFileName(com.fasterxml.jackson.databind.node.ObjectNode fileRecord)
-
hasArchiveFileField
public static boolean hasArchiveFileField(List<com.fasterxml.jackson.databind.node.ObjectNode> fileRecords)
-
postProcessRetrievedFile
public static boolean postProcessRetrievedFile(File rawDataDir, File file, ImportingFileRecord fileRecord, List<ImportingFileRecord> fileRecords, ImportingUtilities.Progress progress) throws IOException
- Throws:
IOException
-
postProcessSingleRetrievedFile
public static void postProcessSingleRetrievedFile(File file, ImportingFileRecord fileRecord)
-
tryOpenAsArchive
public static InputStream tryOpenAsArchive(File file, String mimeType)
-
tryOpenAsArchive
public static InputStream tryOpenAsArchive(File file, String mimeType, String contentType)
-
tryOpenAsCompressedFile
public static InputStream tryOpenAsCompressedFile(File file, String mimeType)
-
tryOpenAsCompressedFile
public static InputStream tryOpenAsCompressedFile(File file, String mimeType, String contentEncoding)
-
uncompressFile
public static File uncompressFile(File rawDataDir, InputStream uncompressedIS, ImportingFileRecord fileRecord, ImportingUtilities.Progress progress) throws IOException
- Throws:
IOException
-
previewParse
public static void previewParse(ImportingJob job, String format, com.fasterxml.jackson.databind.node.ObjectNode optionObj, Runner runner, List<Exception> exceptions)
-
createProject
public static long createProject(ImportingJob job, String format, com.fasterxml.jackson.databind.node.ObjectNode optionObj, Runner runner, List<Exception> exceptions, boolean synchronous)
-
createProjectMetadata
public static ProjectMetadata createProjectMetadata(com.fasterxml.jackson.databind.node.ObjectNode optionObj)
-
-