001/* 002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl-2.1.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * <a href="mailto:grenard@nuxeo.com">Guillaume Renard</a> 016 * 017 */ 018 019package org.nuxeo.ecm.restapi.server.jaxrs.routing.io; 020 021import org.nuxeo.ecm.core.api.CoreSession; 022import org.nuxeo.ecm.core.api.DocumentModel; 023import org.nuxeo.ecm.core.api.IdRef; 024import org.nuxeo.ecm.core.api.UnrestrictedSessionRunner; 025import org.nuxeo.ecm.platform.routing.core.impl.GraphNode; 026import org.nuxeo.ecm.platform.routing.core.impl.GraphRoute; 027 028/** 029 * @since 7.2 030 */ 031public class NodeAccessRunner extends UnrestrictedSessionRunner { 032 033 GraphNode node; 034 035 GraphRoute workflowInstance; 036 037 String workflowInstanceId; 038 039 String nodeId; 040 041 public NodeAccessRunner(CoreSession session, String workflowInstanceId, String nodeId) { 042 super(session); 043 this.workflowInstanceId = workflowInstanceId; 044 this.nodeId = nodeId; 045 } 046 047 @Override 048 public void run() { 049 DocumentModel workflowInstanceDoc = session.getDocument(new IdRef(workflowInstanceId)); 050 workflowInstance = workflowInstanceDoc.getAdapter(GraphRoute.class); 051 node = workflowInstance.getNode(nodeId); 052 workflowInstanceDoc.detach(true); 053 node.getDocument().detach(true); 054 } 055 056}