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 *      Vladimir Pasquier <vpasquier@nuxeo.com>
016 */
017package org.nuxeo.binary.metadata.internals.operations;
018
019import java.util.Map;
020
021import org.nuxeo.binary.metadata.api.BinaryMetadataService;
022import org.nuxeo.ecm.automation.core.Constants;
023import org.nuxeo.ecm.automation.core.annotations.Context;
024import org.nuxeo.ecm.automation.core.annotations.Operation;
025import org.nuxeo.ecm.automation.core.annotations.OperationMethod;
026import org.nuxeo.ecm.automation.core.annotations.Param;
027import org.nuxeo.ecm.core.api.Blob;
028
029/**
030 * @since 7.1
031 */
032@Operation(id = ReadMetadataFromBinary.ID, category = Constants.CAT_BLOB, label = "Read Metadata From Binary", description = "Read Metadata "
033        + "From Binary with the default Nuxeo processor.", since = "7.1", addToStudio = false, aliases = { "Binary.ReadMetadata" })
034public class ReadMetadataFromBinary {
035
036    public static final String ID = "Blob.ReadMetadata";
037
038    @Context
039    protected BinaryMetadataService binaryMetadataService;
040
041    @Param(name = "ignorePrefix", required = false, description = "Ignore metadata prefixes or not")
042    boolean ignorePrefix = true;
043
044    @OperationMethod
045    public Map<String, Object> run(Blob blob) {
046        return binaryMetadataService.readMetadata(blob, ignorePrefix);
047    }
048}