use of org.opendatakit.briefcase.ui.StorageLocation in project briefcase by opendatakit.
the class BaseFormParserForJavaRosa method redirectOutput.
private static void redirectOutput() {
File jrLogFile = new File(new StorageLocation().getBriefcaseFolder(), ".briefcase-javarosa.log");
log.info("Redirecting javarosa output to {}", jrLogFile);
try {
PrintStream jrOut = new PrintStream(jrLogFile);
Std.setOut(jrOut);
Std.setErr(jrOut);
} catch (FileNotFoundException e) {
log.warn("Failed to redirect javarosa output");
}
}
use of org.opendatakit.briefcase.ui.StorageLocation in project briefcase by opendatakit.
the class XmlManipulationUtils method parseXml.
public static Document parseXml(File submission) throws ParsingException, FileSystemException {
// parse the xml document...
Document doc = null;
try {
InputStream is = null;
InputStreamReader isr = null;
try {
is = new FileInputStream(submission);
isr = new InputStreamReader(is, UTF_8);
Document tempDoc = new Document();
KXmlParser parser = new KXmlParser();
parser.setInput(isr);
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
tempDoc.parse(parser);
isr.close();
doc = tempDoc;
} finally {
if (isr != null) {
try {
isr.close();
} catch (Exception e) {
// no-op
}
}
if (is != null) {
try {
is.close();
} catch (Exception e) {
// no-op
}
}
}
} catch (XmlPullParserException e) {
try {
return BadXMLFixer.fixBadXML(submission);
} catch (CannotFixXMLException e1) {
File debugFileLocation = new File(new StorageLocation().getBriefcaseFolder(), "debug");
try {
if (!debugFileLocation.exists()) {
FileUtils.forceMkdir(debugFileLocation);
}
long checksum = FileUtils.checksumCRC32(submission);
File debugFile = new File(debugFileLocation, "submission-" + checksum + ".xml");
FileUtils.copyFile(submission, debugFile);
} catch (IOException e2) {
throw new RuntimeException(e2);
}
throw new ParsingException("Failed during parsing of submission Xml: " + e.toString());
}
} catch (IOException e) {
throw new FileSystemException("Failed while reading submission xml: " + e.toString());
}
return doc;
}
use of org.opendatakit.briefcase.ui.StorageLocation in project briefcase by opendatakit.
the class FileSystemUtils method getTempFormDefinitionFile.
public static File getTempFormDefinitionFile() throws FileSystemException {
File briefcase = new StorageLocation().getBriefcaseFolder();
File tempDefnFile;
try {
tempDefnFile = File.createTempFile("tempDefn", ".xml", briefcase);
} catch (IOException e) {
log.error("failed to create temp file for form def", e);
return null;
}
return tempDefnFile;
}
use of org.opendatakit.briefcase.ui.StorageLocation in project briefcase by opendatakit.
the class Common method bootCache.
static void bootCache(String storageDir) {
BriefcasePreferences.setBriefcaseDirectoryProperty(storageDir);
File f = new StorageLocation().getBriefcaseFolder();
LOGGER.info("Trying to use {} as storage directory", f);
if (!f.exists()) {
if (!f.mkdirs()) {
LOGGER.error("Unable to create directory");
System.exit(1);
}
} else if (f.exists() && !f.isDirectory()) {
LOGGER.error("Not a directory");
System.exit(1);
}
if (BriefcasePreferences.appScoped().getBriefcaseDirectoryOrNull() != null) {
FileSystemUtils.createFormCacheInBriefcaseFolder();
}
}
Aggregations