FileNet P8 Content Engine, Versão 4.0.+              

Manipulador de Documentos de Arquivo

Esse manipulador arquiva um documento em uma pasta especificada determinada pelo evento disparado no documento.

Manipulador de Documentos de Arquivo
Versão do Content Engine 3.5.x JScript
function
OnEvent (Event, Subscription) 
{ 
var doc = Event.SourceObject; 
if (Event.IsOfClass("CreationEvent")) 
{ 
FileDocInFolder("/Docs", doc); 
} 
else if (Event.IsOfClass("ChangeClassEvent")) 
{ 
FileDocInFolder("/Archives", doc); 
} 
} 
function FileDocInFolder(otherFolderName, doc) 
{ 
var os = doc.ObjectStore; 
var rootFld = os.RootFolder; 
var fldSet = new Enumerator(rootFld.SubFolders); 
var subFld; 
for (; !fldSet.atEnd(); fldSet.moveNext()) 
{ 
subFld = fldSet.item(); if (subFld.Name == otherFolderName) 
{ subFld.File(doc, 0, doc.DocumentTitle);
 }
 }
 } 
Versão Content Engine 4.x Java
import
com.filenet.api.constants.*; 
import com.filenet.api.constants.DefineSecurityParentage; 
import com.filenet.api.core.*; 
import com.filenet.api.engine.EventActionHandler; 
import com.filenet.api.events.ObjectChangeEvent; 
import com.filenet.api.exception.EngineRuntimeException; 
import com.filenet.api.exception.ExceptionCode; 
import com.filenet.api.util.Id; public class FileDocumentAction
implements 
EventActionHandler { 

public void onEvent(ObjectChangeEvent event, Id subscriptionId)
throws 
EngineRuntimeException 
{ 
Document doc = (Document)event.get_SourceObject(); 
try 
{ 
if (event.getClassName().equalsIgnoreCase("CreationEvent")) 
FileDocInFolder("/docs", doc); 
else if (event.getClassName().equalsIgnoreCase("ChangeClassEvent")) 
FileDocInFolder("/Archives", doc); 
} 
catch (Exception e) 
{ 
throw new EngineRuntimeException(ExceptionCode.E_FAILED); 
} 
}  
public void fileDocInFolder(String folderName, Document doc) 
{ 
try 
{ 
Folder folder = (Folder)doc.getObjectStore().getObject("Folder",
folderName); 
ReferentialContainmentRelationship rel = folder.file (doc, 
AutoUniqueName.AUTO_UNIQUE, doc.get_Name(), 
DefineSecurityParentage.DO_NOT_DEFINE_SECURITY_PARENTAGE); 
rel.save(RefreshMode.NO_REFRESH); 
} 
catch (Exception e) 
{ 
e.printStackTrace(); 
} 
} 
} 


Feedback

Última atualização: novembro de 2010


© Copyright IBM Corporation 2010.
Este centro de informações foi desenvolvido com a tecnologia Eclipse. (http://www.eclipse.org)