001/* 002 * (C) Copyright 2015 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 * Antoine Taillefer <ataillefer@nuxeo.com> 016 */ 017package org.nuxeo.ecm.automation.server.jaxrs.batch; 018 019import java.util.Collections; 020import java.util.List; 021 022import org.apache.commons.collections.CollectionUtils; 023import org.nuxeo.ecm.core.api.Blob; 024import org.nuxeo.ecm.core.transientstore.AbstractStorageEntry; 025import org.nuxeo.ecm.core.transientstore.api.TransientStore; 026 027/** 028 * Represents a chunk from a batch file backed by the {@link TransientStore}. 029 * 030 * @since 7.4 031 * @see BatchFileEntry 032 * @see Batch 033 */ 034public class BatchChunkEntry extends AbstractStorageEntry { 035 036 private static final long serialVersionUID = 1L; 037 038 public BatchChunkEntry(String id, Blob blob) { 039 super(id); 040 setBlobs(Collections.singletonList(blob)); 041 } 042 043 public Blob getBlob() { 044 List<Blob> blobs = getBlobs(); 045 if (CollectionUtils.isEmpty(blobs)) { 046 return null; 047 } 048 return blobs.get(0); 049 } 050 051 @Override 052 public void beforeRemove() { 053 // Nothing to do here 054 } 055}