001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     bstefanescu
011 */
012package org.nuxeo.ecm.automation.server.jaxrs;
013
014import javax.ws.rs.GET;
015
016import org.nuxeo.ecm.automation.AutomationService;
017import org.nuxeo.ecm.automation.OperationContext;
018import org.nuxeo.ecm.automation.OperationException;
019import org.nuxeo.ecm.automation.jaxrs.io.operations.ExecutionRequest;
020
021/**
022 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
023 */
024// Seems useless
025public class ChainResource extends ExecutableResource {
026
027    protected final String chainId;
028
029    public ChainResource(AutomationService service, String chainId) {
030        super(service);
031        this.chainId = chainId;
032    }
033
034    @GET
035    public Object doGet() { // TODO
036        return null;
037    }
038
039    @Override
040    public Object execute(ExecutionRequest xreq) throws OperationException {
041        OperationContext ctx = xreq.createContext(request, getCoreSession());
042        // Copy params in the Chain context
043        ctx.putAll(xreq.getParams());
044        return service.run(ctx, chainId);
045    }
046
047    @Override
048    public String getId() {
049        return chainId;
050    }
051
052    @Override
053    public boolean isChain() {
054        return true;
055    }
056}