Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.flexstor.flexdbserver.services.external
Class ExecuteExternalService  view ExecuteExternalService download ExecuteExternalService.java

java.lang.Object
  extended bycom.flexstor.flexdbserver.services.external.ExecuteExternalService
All Implemented Interfaces:
com.flexstor.flexdbserver.services.io.IIntervalTimer, com.flexstor.flexdbserver.services.Service

public class ExecuteExternalService
extends java.lang.Object
implements com.flexstor.flexdbserver.services.Service, com.flexstor.flexdbserver.services.io.IIntervalTimer

ExecuteExternalService

The Execute External Service will execute a external program as part of a workflow either during imports or during a customized process.
The service can be set so it accepts the full path of the program to be called and its arguments. Arguments can be meta data information stored in the data object passed to the service or literal arguments (defined for the service and passed straight to the program. All arguments should be specified in one of the following files:

- services.config
- roletype_services.config
- custom_process.xml
- xml file defined for FLEXsi

The following rules apply when defining arguments:

- Properties defined in roletype_services.config override properties already defined in services.config.
- Properties defined in either custom_process.xml or FLEXsi xml overrides properties already defined in services.config.
- The program should be defined to include it full path and name as follows:

exceutable = /full/path/to/program/including/name

- Meta data arguments should be defined as:

argN.bucket = ,
argN+1.bucket = ,

- Literal arguments should be defined as:

argN+2.literal =

where N is the position of this argument as expected in the program.


When calling this service from a customized process it is a good idea to call the MetaData Service first, as it will load all bucket, element, asset and asset role information available from the database. Calling the MetaData Service as part of an import process (before the DBUpdate Service) will have no effects since information for the assets and any new bucket will not be available yet.
Due to some limitations on this service at the moment; the ExecuteExternal Service can only be run against primary assets during an import process. If run as part of a customized process, this limiation does not apply.

Input Data Object

com.flexstor.common.data.ActionData or com.flexstor.common.importprocessor.ImportData

Output Data Object

com.flexstor.common.data.ActionResult containing a com.flexstor.common.importprocessor.ActionData object, if called during an import process, or com.flexstor.common.data.ActionData, if called during a customized process

Configurable Properties (in services.config or roletype_services.config) and
Programmable Properties (passed inside data object )

Global Properties (apply to all assets)

inrole: The role of the assets for which to execute this program. Defaults to ALL if not defined.
Data type: String
Legal values: One of the following: HIGHRES, LOWRES, THUMBNAIL, LAYOUT, AUDIO, VIDEO or ALL

intype: The type of the assets for which to execute this program. Defaults to ALL if not defined.
Data type: String
Legal values: A type as defined in typerdat.txt

inflag: The flag of the assets for which to execute this program. Defaults to PARENT if not defined.
Data type: String
Legal values: One of the following: PARENT, TEMP_PARENT, CHILDREN, TEMP_CHILDREN, ALL, TEMP_ALL

executable: full path of program to be run by the service.
Data type: String
Legal values: /full/path/to/program/including/name

argN.bucket: Bucket and field label for which to use its meta data as argument N of the program.
Data type: String
Legal values: A String of the following form ,

argN.literal: Literal value to be passed directly to the program as argument N.
Data type: String
Legal values: A String with an argument for the program

intervaltimer_timeout: A user-specified property in services.config or roletype_services.config that defines the timeout period for the watch-dog timer that interrupts the external process if it hangs. Data type: int
Legal values: time (seconds)


Field Summary
private  com.flexstor.flexdbserver.disguise.BucketHelper bucketHelper
           
protected  com.flexstor.flexdbserver.services.ServiceContext context
           
private  com.flexstor.common.data.ActionData data
           
protected  java.lang.String fileSeparator
           
static java.lang.String IDENTIFIER
           
private  java.util.List lExecArgs
          Holds all arguments passed to this service, which will be passed to the program.
private  java.util.List lExecProps
          Holds the property names; in other words, while the instance variable lExecArgs will hold only the values, this List will hold the name of the properties.
private  java.lang.Process pr
           
private  java.lang.String sCommand
           
private  java.lang.String sInFlag
           
private  java.lang.String sInRole
           
private  java.lang.String sInType
           
private  java.lang.String sThisService
           
 
Constructor Summary
ExecuteExternalService()
           
 
Method Summary
private  com.flexstor.common.importprocessor.ImportData createImportData(com.flexstor.common.data.ActionData data)
           
private  boolean executeProgram(java.util.List lThisAssetArgs)
           
private  java.util.List getMetaDataArguments(com.flexstor.common.data.ejb.disguiserecord.DisguiseAssetRecordData asset)
           
 com.flexstor.common.data.ActionResult go()
          This methods carries the load of the business logic for the service.
 void initData(com.flexstor.common.data.ActionData actionData)
          A data initialization method called at the beginning of the service.
private  boolean isAssetRoleBucket(java.lang.String sBucketLabel)
           
private  void retrieveArgs(java.util.Iterator props)
           
private  void retrieveDataObjectArgs(com.flexstor.common.importprocessor.ImportData data)
          Retrieves arguments set in the data object
private  void retrieveServiceArgs()
          Retrieves arguments set in the service instance itself.
 void setServiceContext(com.flexstor.flexdbserver.services.ServiceContext context)
          Calls before the service is initialized (before initData is called) to pass information about the environment in which the service is running.
 void timedOut()
          Called from IntervalTimer if it times out
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IDENTIFIER

public static final java.lang.String IDENTIFIER
See Also:
Constant Field Values

data

private com.flexstor.common.data.ActionData data

sThisService

private java.lang.String sThisService

pr

private java.lang.Process pr

sCommand

private java.lang.String sCommand

fileSeparator

protected java.lang.String fileSeparator

context

protected com.flexstor.flexdbserver.services.ServiceContext context

lExecArgs

private java.util.List lExecArgs
Holds all arguments passed to this service, which will be passed to the program. The first item on the list is the program name itself.


lExecProps

private java.util.List lExecProps
Holds the property names; in other words, while the instance variable lExecArgs will hold only the values, this List will hold the name of the properties.


sInRole

private java.lang.String sInRole

sInType

private java.lang.String sInType

sInFlag

private java.lang.String sInFlag

bucketHelper

private com.flexstor.flexdbserver.disguise.BucketHelper bucketHelper
Constructor Detail

ExecuteExternalService

public ExecuteExternalService()
Method Detail

setServiceContext

public void setServiceContext(com.flexstor.flexdbserver.services.ServiceContext context)
Calls before the service is initialized (before initData is called) to pass information about the environment in which the service is running. This environment consists of information about the properties set for the service in one of these files (services.config, roletype_services.config, or *.ctl), plus methods to access other information such as an instance of the service broker to invoke other services, the transaction id for the service, file separator character and local path for the installation directory and configuration directory.

Specified by:
setServiceContext in interface com.flexstor.flexdbserver.services.Service

initData

public void initData(com.flexstor.common.data.ActionData actionData)
Description copied from interface: com.flexstor.flexdbserver.services.Service
A data initialization method called at the beginning of the service. Not business logic, relevant to the functionality of the service, should be added here, other than initializing some variables, etc.

Specified by:
initData in interface com.flexstor.flexdbserver.services.Service

go

public com.flexstor.common.data.ActionResult go()
Description copied from interface: com.flexstor.flexdbserver.services.Service
This methods carries the load of the business logic for the service.

Specified by:
go in interface com.flexstor.flexdbserver.services.Service

createImportData

private com.flexstor.common.importprocessor.ImportData createImportData(com.flexstor.common.data.ActionData data)

retrieveServiceArgs

private void retrieveServiceArgs()
Retrieves arguments set in the service instance itself.


retrieveDataObjectArgs

private void retrieveDataObjectArgs(com.flexstor.common.importprocessor.ImportData data)
Retrieves arguments set in the data object


retrieveArgs

private void retrieveArgs(java.util.Iterator props)

getMetaDataArguments

private java.util.List getMetaDataArguments(com.flexstor.common.data.ejb.disguiserecord.DisguiseAssetRecordData asset)
                                     throws java.lang.IllegalArgumentException

isAssetRoleBucket

private boolean isAssetRoleBucket(java.lang.String sBucketLabel)

executeProgram

private boolean executeProgram(java.util.List lThisAssetArgs)
                        throws java.io.IOException,
                               java.lang.InterruptedException

timedOut

public void timedOut()
Called from IntervalTimer if it times out

Specified by:
timedOut in interface com.flexstor.flexdbserver.services.io.IIntervalTimer