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 *     matic
011 */
012package org.nuxeo.ecm.automation.jaxrs.io.operations;
013
014import org.nuxeo.ecm.core.api.DocumentRef;
015import org.nuxeo.ecm.core.api.IdRef;
016import org.nuxeo.ecm.core.api.PathRef;
017
018/**
019 * @author matic
020 */
021public class DocumentInputResolver implements InputResolver<DocumentRef> {
022
023    @Override
024    public String getType() {
025        return "doc";
026    }
027
028    @Override
029    public DocumentRef getInput(String content) {
030        return docRefFromString(content);
031    }
032
033    public static DocumentRef docRefFromString(String input) {
034        if (input.startsWith("/")) {
035            return new PathRef(input);
036        } else {
037            return new IdRef(input);
038        }
039    }
040
041}