Difference between revisions of "Utilities"

From OpenKM Documentation
Jump to: navigation, search
(PHP Utilities)
 
(67 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 )
 +
* [[Cognitive PDF/A]] ( Cognitive PDF/A integration example )
 +
* [[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]]
  
== PHP Utilities ==
+
== 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 )
  
 +
== Reports ==
 +
* [[File:SQLReportPattern.jrxml]] ( sql basic report pattern )
 +
* [[File:JavaReportPattern.jrxml]] ( java basic report pattern )
  
== Autoimport ==
+
== Crontab Utilites ==
<source lang="php">
+
* [[Crontab importer with metadata]] ( import files with metadata values in the filename from server filesystem).
<?php
+
* [[Crontab simple importer]] ( import files from server filesystem )
  $okmurl="http://localhost:8080/OpenKM/";
+
* [[Crontab xml importer]] ( import files from server filesystem with metadata values)
  $okmid="autoImport";
 
  $okmpw="upload";
 
 
  $OKMAuth = new SoapClient($okmurl."OKMAuth?wsdl");
 
  $OKMDocument = new SoapClient($okmurl."OKMDocument?wsdl");
 
  
  // Login
+
== PHP Utilities ==
  $token = $OKMAuth->login($okmid, $okmpw);
+
* [[PHP AutoImport]] ( Import pdf files from some local path to specific OpenKM server path )
 
+
* [[PHP fileUpoad]] ( Shell script that uses php support to import files )
  foreach (glob("/converted/*.pdf") as $filename) {
+
* [[PHP Download file]] ( download file using webservices )
    echo "$filename size " . filesize($filename) . '<br />';
+
* [http://code.google.com/p/openkm-php-class/ PHP Class made for OpenKM Document Manager]
   
 
    // open file and encode if necessary
 
    $handle = fopen($filename,'rb');
 
    $file_content = fread($handle,filesize($filename));
 
    fclose($handle);
 
    $encoded = base64_encode($file_content);
 
    $filename1 = substr($filename,12);
 
    echo "$filename1" . '<br />';
 
    $OKMDocument->createSimple($token,"/okm:root/imported/".$filename1,$file_content);
 
   
 
    //delete the file uoloaded
 
    unlink("c:/converted/".$filename1);   
 
  }
 
 
 
  // Logout
 
  $OKMAuth->logout($token);
 
?>
 
</source>
 
 
 
== File upload ==
 
<source lang="php">
 
  <?php
 
  $okmurl="http://localhost:8080/OpenKM/";
 
  $okmid="username";
 
  $okmpw="password";
 
  $impfile = $argv[1];
 
 
 
  $OKMAuth = new SoapClient($okmurl."OKMAuth?wsdl");
 
  $OKMDocument = new SoapClient($okmurl."OKMDocument?wsdl");
 
 
 
  // open file and encode if necessary
 
  $handle = fopen($impfile,'rb');
 
  $file_content = fread($handle,filesize($impfile));
 
  fclose($handle);
 
  $encoded = base64_encode($file_content);
 
 
 
  // 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
+
== Others ==
OKM_IMPORT_DIR=NEW
+
* [[Version number sample]]
  
# Filesystem directory (no trailing slash) where we put imported files (it will be created)
+
== Remote Importer ==
STORE_DIR=~/we-test
+
This utility is designed to import documents to a remote OpenKM instance. It uses OpenKM WebServices API so is firewall friendly.
  
# Filesystem directory (no trailing slash) where we put files that encountered import errors
+
You need Java 7 installed in your computer since v1.0.
ERROR_STORE_DIR=~/error-test
 
  
####################################
 
# 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
+
{| align="center"
if [ -d "$1" ]; then
+
|[[File:Remote Importer 01.png|300px|center]]
    echo "ERROR: \"$1\" is a directory!"
+
|[[File:Remote Importer 02.png|300px|center]]
    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
 
if [ -z "$2" ]; then
 
    OKM_DIR=$OKM_IMPORT_DIR
 
else
 
    OKM_DIR=$2
 
fi
 
  
# Check if the imported files directory exsists
+
{{Note|The '''preserve creation date''' feature in only compatible since OpenKM Professional 6.2.10 and OpenKM Community 6.2.3.}}
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
 
RESULT=$(php /opt/openkm/import.php $INFILE ${INFILE##*/} $OKM_DIR 2>&1)
 
RESULTCODE=$?
 
  
# Deal with the consequences
+
[http://www.openkm.com/utils/wsImporter.jnlp Download & Execute]
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
+
[[Category: Utilities]]
    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>
 

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