private static final String DROP_USER_SQL_CMD = "DROP USER";
private static final String DROP_USER_IF_EXISTS_SQL_CMD = DROP_USER_SQL_CMD + " IF EXISTS %s;";
private static final String DROP_OBJECTS_SQL_COMMENT = "-- drop all the objects before dropping roles";
+ private static final String CSPACE_JEESERVER_HOME = "CSPACE_JEESERVER_HOME";
private ServiceMain() {
// Intentionally blank
}
}
+
+ public static String getJeeContainPath() throws Exception {
+ String result = System.getenv(CSPACE_JEESERVER_HOME);
+
+ if (result == null) {
+ throw new Exception();
+ }
+
+ return result;
+ }
}
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.collectionspace.services.nuxeo.client.java.CommonList;
import org.collectionspace.services.common.Download;
+import org.collectionspace.services.common.ServiceMain;
import org.collectionspace.services.common.document.DocumentException;
import org.collectionspace.services.common.imaging.nuxeo.NuxeoBlobUtils;
throw new DocumentException(msg);
}
} else if (blobUrl.getProtocol().equalsIgnoreCase("file")) {
- theBlobFile = FileUtils.toFile(blobUrl);
+ if (blobUrl.getPath().startsWith("/")) {
+ // full path
+ theBlobFile = FileUtils.toFile(blobUrl);
+ } else {
+ // relative to JEE container (e.g. Apache Tomcat) path
+ Path theBlobFilePath = Paths.get(ServiceMain.getJeeContainPath(), blobUrl.getPath());
+ theBlobFile = new File(theBlobFilePath.toAbsolutePath().toString());
+ }
if (theBlobFile.exists() == false || theBlobFile.canRead() == false) {
String msg = FILE_ACCESS_ERROR + theBlobFile.getAbsolutePath();
logger.error(msg);