Difference between revisions of "Utilities"

From OpenKM Documentation
Jump to: navigation, search
(PHP Utilities)
 
(62 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{TOCright}} __TOC__
 +
 
These are OpenKM utilities created by the community.
 
These are OpenKM utilities created by the community.
 +
== General Utilities ==
 +
* [[Direct link]] ( Link documents outside OpenKM )
 +
* [[Fast extension sample]] ( Show how to fastly extend openkm UI features ).
 +
* [[Bash document import]] ( Bash script to import documents )
 +
* [[Extra tab with OpenKM url link]] ( Show how to access GWT javascript functions from iframe )
  
== Crontab Utilites ==
+
== Script Utilities ==
 
+
* [[Folders deep]] ( Find folder with some depth )
== PHP Utilities ==
+
* [[Cognitive PDF/A]] ( Cognitive PDF/A integration example )
* [[PHP AutoImport]] (Import pdf files from some local path to specific OpenKM server path
+
* [[Low level security change]] ( For great size repositories change security in low level mode )
 +
* [[CSV importer]] ( Import metadata from CSV files )
 +
* [[Export folder to server as zip]]
 +
* [[Convert Exchange Legacy DN]]
  
 +
== Automation ==
 +
* [[Incremental autonumeric]] ( creates incremental autonumeric for each new document )
 +
* [[OMR scripting]] ( automatically process images by OMR engine )
 +
* [[Unique name]] ( automatically creates unique document name based in metadata values )
 +
* [[Simple autotagging]] ( automatically autotaggin documents based in database metadata values )
 +
* [[Folder Style assigned by metadata]] ( automatically assign folder style based on metadata document values into )
  
== File upload ==
+
== Reports ==
<source lang="php">
+
* [[File:SQLReportPattern.jrxml]] ( sql basic report pattern )
  <?php
+
* [[File:JavaReportPattern.jrxml]] ( java basic report pattern )
  $okmurl="http://localhost:8080/OpenKM/";
 
  $okmid="username";
 
  $okmpw="password";
 
  $impfile = $argv[1];
 
  
  $OKMAuth = new SoapClient($okmurl."OKMAuth?wsdl");
+
== Crontab Utilites ==
  $OKMDocument = new SoapClient($okmurl."OKMDocument?wsdl");
+
* [[Crontab importer with metadata]] ( import files with metadata values in the filename from server filesystem).
 +
* [[Crontab simple importer]] ( import files from server filesystem )
 +
* [[Crontab xml importer]] ( import files from server filesystem with metadata values)
  
  // open file and encode if necessary
+
== PHP Utilities ==
  $handle = fopen($impfile,'rb');
+
* [[PHP AutoImport]] ( Import pdf files from some local path to specific OpenKM server path )
  $file_content = fread($handle,filesize($impfile));
+
* [[PHP fileUpoad]] ( Shell script that uses php support to import files )
  fclose($handle);
+
* [[PHP Download file]] ( download file using webservices )
  $encoded = base64_encode($file_content);
+
* [http://code.google.com/p/openkm-php-class/ PHP Class made for OpenKM Document Manager]
 
 
  // Login
 
  $token = $OKMAuth->login($okmid, $okmpw);
 
  $OKMDocument->createSimple($token,"/okm:root/file.to.upload",$file_content);
 
 
 
  // Logout
 
  $OKMAuth->logout($token);
 
?>
 
</source>
 
 
 
<source lang="bash">
 
#!/bin/bash
 
# JOAKO Import 1.0.0 - Copyright 2011 Andrew Joakimsen
 
# Distributed under the terms of the GNU General Public
 
# License Version 2 and no future versions.
 
#
 
# Script to import files into OpenKM and report error/success.
 
# Requires the PHP import script written by snowman, with a
 
# few small tweaks.
 
 
 
###################################
 
###                            ###
 
###  C O N F I G U R A T I O N  ###
 
###                            ###
 
###################################
 
 
 
# OpenKM directory where files are imported to
 
OKM_IMPORT_DIR=NEW
 
  
# Filesystem directory (no trailing slash) where we put imported files (it will be created)
+
== Others ==
STORE_DIR=~/we-test
+
* [[Version number sample]]
  
# Filesystem directory (no trailing slash) where we put files that encountered import errors
+
== Remote Importer ==
ERROR_STORE_DIR=~/error-test
+
This utility is designed to import documents to a remote OpenKM instance. It uses OpenKM WebServices API so is firewall friendly.
  
####################################
+
You need Java 7 installed in your computer since v1.0.
# First let's see if the runtime condition is sane
 
if [ -z "$1" ]; then
 
    echo "JOAKO Import: Missing file name"
 
    echo "Usage: import.sh [filename] [target-directory]"
 
    exit 1
 
fi
 
  
# If ARG1 is a real file
 
if [ -d "$1" ]; then
 
    echo "ERROR: \"$1\" is a directory!"
 
    exit 1
 
fi
 
if [ ! -f "$1" ]; then
 
    echo "ERROR: \"$1\" Invalid file name "
 
    exit 1
 
else
 
    INFILE=$1
 
fi
 
  
# Check if OKM_IMPORT_DIR was passed as argument
+
{| align="center"
if [ -z "$2" ]; then
+
|[[File:Remote Importer 01.png|300px|center]]
    OKM_DIR=$OKM_IMPORT_DIR
+
|[[File:Remote Importer 02.png|300px|center]]
else
+
|}
    OKM_DIR=$2
 
fi
 
  
# Check if the imported files directory exsists
 
if [ ! -d $STORE_DIR/$OKM_DIR ]; then
 
    if [ ! -d ~/$STORE_DIR ]; then
 
        mkdir $STORE_DIR
 
    fi
 
    mkdir $STORE_DIR/$OKM_DIR
 
fi
 
  
# Run the import Process
+
{{Note|The '''preserve creation date''' feature in only compatible since OpenKM Professional 6.2.10 and OpenKM Community 6.2.3.}}
RESULT=$(php /opt/openkm/import.php $INFILE ${INFILE##*/} $OKM_DIR 2>&1)
 
RESULTCODE=$?
 
  
# Deal with the consequences
 
function importer-error {
 
    # Check if the import error directory exsists
 
    if [ ! -d $ERROR_STORE_DIR/$OKM_DIR ]; then
 
        if [ ! -d $ERROR_STORE_DIR ]; then
 
            mkdir $ERROR_STORE_DIR
 
        fi
 
        mkdir $ERROR_STORE_DIR/$OKM_DIR
 
    fi
 
    echo "`date` JOAKO Import Encountered an error type $RESULTCODE."
 
    echo "$RESULT"
 
    mv $INFILE $ERROR_STORE_DIR/$OKM_DIR &> /dev/null
 
    exit $?
 
}
 
  
if [ $RESULTCODE -ne 0 ]; then # There was an error
+
[http://www.openkm.com/utils/wsImporter.jnlp Download & Execute]
    importer-error
 
else # We check further
 
    if [ -n "$RESULT" ]; then # There was an error
 
        importer-error
 
    else # No error detected
 
        echo "`date` JOAKO Import: Imported file [${INFILE##*/}] to [$OKM_DIR] directory"
 
        mv $INFILE $STORE_DIR/$OKM_DIR &> /dev/null
 
        exit 0
 
    fi
 
fi
 
</source>
 
  
 
[[Category: Utilities]]
 
[[Category: Utilities]]

Latest revision as of 18:33, 13 May 2015

These are OpenKM utilities created by the community.

General Utilities

Script Utilities

Automation

Reports

Crontab Utilites

PHP Utilities

Others

Remote Importer

This utility is designed to import documents to a remote OpenKM instance. It uses OpenKM WebServices API so is firewall friendly.

You need Java 7 installed in your computer since v1.0.


Remote Importer 01.png
Remote Importer 02.png



Nota clasica.png The preserve creation date feature in only compatible since OpenKM Professional 6.2.10 and OpenKM Community 6.2.3.


Download & Execute