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 all2011-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 allimports...
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;
}
}
}