From 6b1b9e46a5d8e2f3be53e3d4bde4f1f4477ee1a4 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 29 Dec 2020 09:30:16 -0600 Subject: [PATCH] Adding openkm data --- openkm/data/OpenKM.cfg | 7 ++++ openkm/data/OpenKM.xml | 61 ++++++++++++++++++++++++++++ openkm/data/server.xml | 72 +++++++++++++++++++++++++++++++++ openkm/data/simple_importer.bsh | 46 +++++++++++++++++++++ openkm/docker-compose.yml | 34 ++++++++++++++++ 5 files changed, 220 insertions(+) create mode 100644 openkm/data/OpenKM.cfg create mode 100644 openkm/data/OpenKM.xml create mode 100644 openkm/data/server.xml create mode 100644 openkm/data/simple_importer.bsh create mode 100644 openkm/docker-compose.yml diff --git a/openkm/data/OpenKM.cfg b/openkm/data/OpenKM.cfg new file mode 100644 index 0000000..f13df93 --- /dev/null +++ b/openkm/data/OpenKM.cfg @@ -0,0 +1,7 @@ +#OpenKM Hibernate configuration values +hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect +hibernate.hbm2ddl=create + +# Logback configuration file +# logback.config=logback.xml + diff --git a/openkm/data/OpenKM.xml b/openkm/data/OpenKM.xml new file mode 100644 index 0000000..ff97493 --- /dev/null +++ b/openkm/data/OpenKM.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + java.naming.referral + + follow + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/openkm/data/server.xml b/openkm/data/server.xml new file mode 100644 index 0000000..20c7855 --- /dev/null +++ b/openkm/data/server.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/openkm/data/simple_importer.bsh b/openkm/data/simple_importer.bsh new file mode 100644 index 0000000..ea14315 --- /dev/null +++ b/openkm/data/simple_importer.bsh @@ -0,0 +1,46 @@ +import com.openkm.core.*; +import com.openkm.api.*; +import java.io.*; +import com.openkm.module.db.stuff.DbSessionManager; + +String token = DbSessionManager.getInstance().getSystemToken(); +OKMDocument document = OKMDocument.getInstance(); +OKMFolder folder = OKMFolder.getInstance(); + +public void autoImport(String okmPath, File fldpath){ + try { + print("Scanning " + fldpath.getName() + "
"); + for (File file : fldpath.listFiles()) { + print("Importing " + file.getName() + "
"); + try { + if (file.isDirectory()) { + try { + folder.createSimple(token, okmPath + file.getName()); + } catch (ItemExistsException ie) { + print("folder already exists
"); + // Folder already exists - just ignore exception + } + autoImport( okmPath + file.getName() + "/", file); + } else { + // Check if file is still being written to + long length = file.length(); + Thread.sleep(1000); + if (file.length() > length) continue; // Skip file this time + FileInputStream fis = new FileInputStream(file); + document.createSimple(token, okmPath + file.getName(), fis); + fis.close(); + } + print("Created " + okmPath + file.getName() + "
"); + } catch (Exception e) { + print ("Exception:" + e + "
"); + // Something bad happened to prevent import. Skip to next file. + continue; + } + file.delete(); + } + } catch (Exception e) { + print("Exception: " + e + "
"); + } +} + +autoImport("/okm:root/Imported Items/Scans/", new File("/import/DocumentImport/Live")); diff --git a/openkm/docker-compose.yml b/openkm/docker-compose.yml new file mode 100644 index 0000000..0473bea --- /dev/null +++ b/openkm/docker-compose.yml @@ -0,0 +1,34 @@ +version: '3.2' + +services: + openkm: + container_name: openkm + hostname: openkm + image: openkm/openkm-ce:6.3.9 + ports: + - 8095:8080 + volumes: + - ./data/server.xml:/opt/tomcat/conf/server.xml + - ./data/OpenKM.cfg:/opt/tomcat/OpenKM.cfg + - ./data/OpenKM.xml:/opt/tomcat/OpenKM.xml + - ./data/repository:/opt/tomcat/repository + - ./data/import:/import + environment: + CATALINA_OPTS: "-Duser.timezone=America/Chicago" + links: + - mysql:mysql + + mysql: + container_name: openkmdb + hostname: openkmdb + image: mysql:8.0.13 + command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8 --collation-server=utf8_bin + environment: + MYSQL_DATABASE: ${MYSQL_DATABASE} + MYSQL_USER: ${MYSQL_USER} + MYSQL_PASSWORD: ${MYSQL_PASSWORD} + MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} + security_opt: + - seccomp:unconfined + volumes: + - ./data/mysql:/var/lib/mysql