001/*
002 * (C) Copyright 2013 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     vpasquier <vpasquier@nuxeo.com>
018 */
019package org.nuxeo.ecm.restapi.server.jaxrs.blob;
020
021import javax.ws.rs.Path;
022import javax.ws.rs.PathParam;
023
024import org.nuxeo.ecm.core.api.DocumentModel;
025import org.nuxeo.ecm.webengine.model.Resource;
026import org.nuxeo.ecm.webengine.model.WebAdapter;
027import org.nuxeo.ecm.webengine.model.impl.DefaultAdapter;
028
029/**
030 * REST API Blob Manager
031 *
032 * @since 5.7.3
033 */
034@WebAdapter(name = BlobAdapter.NAME, type = "blobAdapter")
035public class BlobAdapter extends DefaultAdapter {
036
037    public static final String NAME = "blob";
038
039    protected DocumentModel doc;
040
041    @Path("{fieldPath:((?:(?!/@).)*)}")
042    public Resource doGet(@PathParam("fieldPath") String fieldPath) {
043        doc = getTarget().getAdapter(DocumentModel.class);
044        return newObject("blob", fieldPath, doc);
045    }
046
047}