public static String DEFAULT_ENCODING = "";\r
public static String UTF8_ENCODING = "UTF-8";\r
public static boolean FORCE_CREATE_PARENT_DIRS = true;\r
+ private static String JAVA_TEMP_DIR_PROPERTY = "java.io.tmpdir";\r
\r
/**\r
* getObjectFromStream get object of given class from given inputstream\r
return result;\r
}\r
\r
+ // FIXME: Java 7 now offers an integral method for this purpose,\r
+ // java.nio.file.Files.createTempDirectory()\r
public static File createTmpDir(String filePrefix){\r
- String tmpDir = System.getProperty("java.io.tmpdir");\r
+ String tmpDir = System.getProperty(JAVA_TEMP_DIR_PROPERTY);\r
File result = new File(tmpDir, filePrefix + UUID.randomUUID().toString());\r
return result;\r
}\r
+ \r
+ /**\r
+ * Returns information about the Java temporary directory,\r
+ * including its path and selected access rights of the\r
+ * current code to that directory.\r
+ * \r
+ * This can potentially be helpful when troubleshooting issues\r
+ * related to code that uses that temporary directory, as per CSPACE-5766.\r
+ * \r
+ * @return information about the Java temporary directory.\r
+ */\r
+ public static String getJavaTmpDirInfo() {\r
+ StringBuffer strBuf = new StringBuffer("");\r
+ String tmpDirProperty = System.getProperty(JAVA_TEMP_DIR_PROPERTY);\r
+ strBuf.append("\n");\r
+ if (Tools.notBlank(tmpDirProperty)) {\r
+ strBuf.append("Java temporary directory property=");\r
+ strBuf.append(tmpDirProperty);\r
+ strBuf.append("\n");\r
+ } else {\r
+ strBuf.append("Could not get Java temporary directory property");\r
+ strBuf.append("\n");\r
+ return strBuf.toString();\r
+ }\r
+ File tmpDir = new File(tmpDirProperty); // Throws only NPE, if tmpDirProperty is null\r
+ boolean tmpDirExists = false;\r
+ boolean tmpDirIsDirectory = false;\r
+ try {\r
+ tmpDirExists = tmpDir.exists();\r
+ strBuf.append("Temporary directory exists=");\r
+ strBuf.append(tmpDirExists);\r
+ strBuf.append("\n");\r
+ tmpDirIsDirectory = tmpDir.isDirectory();\r
+ strBuf.append("Temporary directory is actually a directory=");\r
+ strBuf.append(tmpDirIsDirectory);\r
+ strBuf.append("\n"); \r
+ } catch (SecurityException se) {\r
+ strBuf.append("Security manager settings prohibit reading temporary directory: ");\r
+ strBuf.append(se.getMessage());\r
+ strBuf.append("\n");\r
+ return strBuf.toString();\r
+ }\r
+ if (tmpDirExists && tmpDirIsDirectory) {\r
+ try {\r
+ boolean tmpDirIsWriteable = tmpDir.canWrite();\r
+ strBuf.append("Temporary directory is writeable by application=");\r
+ strBuf.append(tmpDirIsWriteable);\r
+ } catch (SecurityException se) {\r
+ strBuf.append("Security manager settings prohibit writing to temporary directory: ");\r
+ strBuf.append(se.getMessage());\r
+ } \r
+ }\r
+ return strBuf.toString();\r
+ }\r
}\r
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.client.ReportClient;
import org.collectionspace.services.common.ServiceMain;
+import org.collectionspace.services.common.api.FileTools;
import org.collectionspace.services.common.api.Tools;
import org.collectionspace.services.common.config.ConfigReader;
import org.collectionspace.services.common.context.ServiceContext;
outputFilename = outputFilename+"-default-to.pdf";
}
outReportFileName.append(outputFilename); // Set the out going param to the report's final file name
- // fill the report
+ // FIXME: Logging temporarily set to INFO level for CSPACE-5766;
+ // can change to TRACE or DEBUG level as warranted thereafter
+ if (logger.isInfoEnabled()) {
+ logger.info(FileTools.getJavaTmpDirInfo());
+ }
+ // fill the report
JasperPrint jasperPrint = JasperFillManager.fillReport(fileStream, params,conn);
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);