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 interface
ImportingUtilities.Progress
-
Field Summary
Fields Modifier and Type Field Description static List<String>
allowedProtocols
protected static org.slf4j.Logger
logger
-
Constructor Summary
Constructors Constructor Description ImportingUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static File
allocateFile(File dir, String name)
static long
createProject(ImportingJob job, String format, com.fasterxml.jackson.databind.node.ObjectNode optionObj, Runner runner, List<Exception> exceptions, boolean synchronous)
static ProjectMetadata
createProjectMetadata(com.fasterxml.jackson.databind.node.ObjectNode optionObj)
protected static String
extractFilenameFromSparkURI(String uri)
Attempts to extract a filename from a Spark URI.static String
getArchiveFileName(com.fasterxml.jackson.databind.node.ObjectNode fileRecord)
static Reader
getFileReader(File file, ImportingFileRecord fileRecord, String commonEncoding)
static Reader
getFileReader(ImportingJob job, ImportingFileRecord fileRecord, String commonEncoding)
static String
getRelativePath(File file, File dir)
static boolean
hasArchiveFileField(List<com.fasterxml.jackson.databind.node.ObjectNode> fileRecords)
static void
loadDataAndPrepareJob(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Properties parameters, ImportingJob job)
static String
normalizePath(String path)
Replace the illegal character with '-' in the path in Windowsstatic boolean
postProcessRetrievedFile(File rawDataDir, File file, ImportingFileRecord fileRecord, List<ImportingFileRecord> fileRecords, ImportingUtilities.Progress progress)
static void
postProcessSingleRetrievedFile(File file, ImportingFileRecord fileRecord)
static void
previewParse(ImportingJob job, String format, com.fasterxml.jackson.databind.node.ObjectNode optionObj, Runner runner, List<Exception> exceptions)
static void
retrieveContentFromPostRequest(javax.servlet.http.HttpServletRequest request, Properties parameters, File rawDataDir, ImportingJob.RetrievalRecord retrievalRecord, ImportingUtilities.Progress progress)
static InputStream
tryOpenAsArchive(File file, String mimeType)
static InputStream
tryOpenAsArchive(File file, String mimeType, String contentType)
static InputStream
tryOpenAsCompressedFile(File file, String mimeType)
static InputStream
tryOpenAsCompressedFile(File file, String mimeType, String contentEncoding)
static File
uncompressFile(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:
IOException
javax.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:
IOException
org.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)
-
-