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.core.transientstore; 018 019import java.io.Serializable; 020import java.util.List; 021import java.util.Map; 022import java.util.concurrent.ConcurrentHashMap; 023import java.util.concurrent.ConcurrentMap; 024 025import org.apache.commons.logging.Log; 026import org.apache.commons.logging.LogFactory; 027import org.nuxeo.ecm.core.transientstore.api.TransientStore; 028 029/** 030 * Class representing an entry stored in the {@link TransientStore}. 031 * 032 * @since 7.10 033 */ 034public class StorageEntry implements Serializable { 035 036 protected Log log = LogFactory.getLog(StorageEntry.class); 037 038 private static final long serialVersionUID = 1L; 039 040 protected ConcurrentMap<String, Serializable> params; 041 042 protected List<Map<String, String>> blobInfos; 043 044 protected long size; 045 046 protected boolean completed; 047 048 public StorageEntry() { 049 this(0, false); 050 } 051 052 public StorageEntry(long size, boolean completed) { 053 params = null; 054 blobInfos = null; 055 this.size = size; 056 this.completed = completed; 057 } 058 059 public Map<String, Serializable> getParams() { 060 if (params == null) { 061 params = new ConcurrentHashMap<>(); 062 } 063 return params; 064 } 065 066 public void putParams(Map<String, Serializable> params) { 067 if (this.params == null) { 068 this.params = new ConcurrentHashMap<>(); 069 } 070 this.params.putAll(params); 071 } 072 073 public Serializable getParam(String param) { 074 if (params == null) { 075 return null; 076 } 077 return params.get(param); 078 } 079 080 public void putParam(String param, Serializable value) { 081 if (params == null) { 082 params = new ConcurrentHashMap<>(); 083 } 084 params.put(param, value); 085 } 086 087 public List<Map<String, String>> getBlobInfos() { 088 return blobInfos; 089 } 090 091 public void setBlobInfos(List<Map<String, String>> blobInfos) { 092 this.blobInfos = blobInfos; 093 } 094 095 public long getSize() { 096 return size; 097 } 098 099 public void setSize(long size) { 100 this.size = size; 101 } 102 103 public boolean isCompleted() { 104 return completed; 105 } 106 107 public void setCompleted(boolean completed) { 108 this.completed = completed; 109 } 110 111}