• workflow with folder

  • We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #8733  by liampadre
 
escogiendo la manera supuestamente mas simple de hacerlo, que es por scripting, veo que en la wiki de scripting mencionan como variables usadas solo 4:
* java.lang.String eventType - says the event that has fired the script. See below for event types.
* javax.jcr.Session session - users session that executes the script.
* javax.jcr.Node eventNode - node that causes the event.
* javax.jcr.Node scriptNode - node where is stored the script.
pero si kiero vincular un documento a un workflow y arrancar ese workflow... ke clases deberia usar, el javadoc de las clases que puedo usar en el entorno scripting no lo veo...

alguien puede darme una pista sobre esto...
 #8827  by pavila
 
Esta característica de asociar un workflow a una carpeta en lugar de a un documento estaba planeada para la versión de desarrollo. Veré en qué estado está pq pensaba que ya estaba implementado.
 #8931  by liampadre
 
Hola, he seguido investigando el tema de workflows y he logrado varias cosas, pero ahora estoy intentando con el usuario okmAdmin que cuando finaliza un workflow el fichero se cree (o se copie) en una carpeta X (en caso no exista) o hacerle un checkout y checkin en caso si exista en dicha carpeta X, pero al ejecutar el workflow por 1era vez ejecuta el codigo de crear el documento y al parecer no me lo hace porque no lo veo y tampoco me devuelve una excepcion, pero cuando lo ejecuto por 2da vez ejecuta el codigo de actualizar (e.d. checkout y checkin) y me devuelve una excepcion que es esta:
Code: Select all
2011-02-18 14:30:00,418 ERROR [org.apache.jackrabbit.core.XASessionImpl] Resource already associated with a transaction.
2011-02-18 14:30:00,418 ERROR [STDERR] javax.transaction.xa.XAException
al parecer porque si lo encuentra, porque si lo creo pero no lo veo, no se si se deba al tema del usuario, dado que al devolver las sesion actual solo me devuelve la del usuario "system" y con la sesion de este usuario se ejecuta el codigo, pero no se como obtener la sesion de otro usuario desde el objeto JcrSessionManager, les adjunto mi codigo haber si me pueden ayudar...
Code: Select all
imports...

public class VersionActionHandler implements ActionHandler{
	
	private static final long serialVersionUID = 1L;
	private static Log log = LogFactory.getLog(VersionActionHandler.class);
    
	public void execute(ExecutionContext context) throws Exception {
		String sTarea = context.getTask().getName();
		
		String actorId = context.getTaskInstance().getActorId();
		System.out.println("MAFE TASKINSTANCE actorId: " + actorId);

		JcrSessionManager sessionManager = JcrSessionManager.getInstance();
		DirectDocumentModule docModule = DirectDocumentModule.class.newInstance();
		DirectPropertyGroupModule pgModule = DirectPropertyGroupModule.class.newInstance();
		
		String uuid = (String)context.getContextInstance().getVariable("uuid");
		
		Map sessions = sessionManager.getSessions(); //AQUI DEVUELVO TODAS LAS SESIONES DISPONIBLES
		JcrSessionInfo info = null;
		Session session = null;
		String token = "";
		
		Iterator it = sessions.entrySet().iterator();
		while (it.hasNext()) {
			Map.Entry e = (Map.Entry)it.next();
			info = (JcrSessionInfo)e.getValue();
			token = String.valueOf(e.getKey());
			session = info.getSession(); //SOLO ME DEVUELVE LA SESION RELACIONADA AL USUARIO "system"
		}
		
		String path = docModule.getPath(token, uuid);
		Document doc = docModule.getProperties(session, path);
		InputStream is = docModule.getContent(token, path, false);
		
		String sComment = "Versionado por " + actorId + " en la tarea " + sTarea;
		String destino = "/okm:root/SISTEMAS/SAP/";
		String sfile = FileUtils.getName(doc.getPath());
		
		Document dfinal = null;
		try {
			dfinal = docModule.getProperties(session, destino + sfile);
		}catch(PathNotFoundException pnfe){}
		
		try {
			if (dfinal != null) {
				destino += sfile;
				docModule.checkout(token, destino);
				docModule.setContent(token, destino, is);
				docModule.checkin(token, destino, sComment);
			}else{
				dfinal = new Document();
				destino += sfile;
				dfinal.setPath(destino);
				dfinal.setMimeType(doc.getMimeType());
				dfinal.setAuthor(doc.getAuthor());
				dfinal.setCategories(doc.getCategories());
				dfinal.setKeywords(doc.getKeywords());
				dfinal.setNotes(doc.getNotes());
				dfinal.setSubscriptors(doc.getSubscriptors());
				dfinal.setPermissions(doc.getPermissions());
				docModule.create(token, dfinal, is);
			}
			context.getContextInstance().setVariable("okpub", "1");
			
		}catch(RepositoryException re){
			context.getContextInstance().setVariable("okpub", "0");
			re.printStackTrace();
		}catch(LockException le) {
			context.getContextInstance().setVariable("okpub", "0");
			le.printStackTrace();
		}catch(Exception e) {
			context.getContextInstance().setVariable("okpub", "0");
			throw e;
		}
	}
}

 #9126  by pavila
 
Las clases del tipo DirectPropertyGroupModule no están pensadas para ser usadas directamente. En mejor acceder a las respectivas del API, que en este caso sería la clase OKMPropertyGroup. Por otra parte, el primer parámetro de estos métodos es un token de autentificación. Dicho token se puede puede obtener mediante el método OKMAuth.login(String, String) y recuerda hace luego un OKMAuth.logout(String) al terminar. De esta forma puedes ejecutar métodos del API de OpenKM con cualquier usuario.

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.