001/* 002 * (C) Copyright 2015 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 * Thierry Delprat <tdelprat@nuxeo.com> 018 * Antoine Taillefer <ataillefer@nuxeo.com> 019 */ 020 021package org.nuxeo.ecm.core.transientstore.api; 022 023import java.io.Serializable; 024import java.util.List; 025import java.util.Map; 026import org.nuxeo.ecm.core.api.Blob; 027 028/** 029 * Service Interface for managing a transient store. 030 * <p> 031 * Allows to store entries in 2 sub parts: a list of blobs stored on a file system along with a map of parameters. 032 * 033 * @since 7.2 034 */ 035public interface TransientStore { 036 037 /** 038 * Returns {@code true} if an entry exists with the given {@code key}. 039 * 040 * @since 7.10 041 */ 042 boolean exists(String key); 043 044 /** 045 * Sets {@code parameter} to {@code value} in the entry with the given {@code key}. 046 * <p> 047 * If entry does not exist a new entry is created. If {@code parameter} already exists in the entry it is 048 * overwritten. 049 * 050 * @since 7.10 051 */ 052 void putParameter(String key, String parameter, Serializable value); 053 054 /** 055 * Gets the value of {@code parameter} in the entry with the given {@code key}. 056 * <p> 057 * Returns {@code null} if entry or parameter does not exist. 058 * 059 * @since 7.10 060 */ 061 Serializable getParameter(String key, String parameter); 062 063 /** 064 * Puts {@code parameters} in the entry with the given {@code key}. Overwrites any existing parameter in the entry. 065 * <p> 066 * If entry does not exist a new entry is created. 067 * 068 * @since 7.10 069 */ 070 void putParameters(String key, Map<String, Serializable> parameters); 071 072 /** 073 * Gets values of the parameters in the entry with the given {@code key}. 074 * <p> 075 * Returns {@code null} if entry does not exist. 076 * 077 * @since 7.10 078 */ 079 Map<String, Serializable> getParameters(String key); 080 081 /** 082 * Associates the given {@code blobs} with the entry with the given {@code key}. 083 * <p> 084 * If entry does not exist a new entry is created. 085 * 086 * @since 7.10 087 */ 088 void putBlobs(String key, List<Blob> blobs); 089 090 /** 091 * Gets the blobs associated with the entry with the given {@code key}. 092 * <p> 093 * Returns {@code null} if entry does not exist. 094 * 095 * @since 7.10 096 */ 097 List<Blob> getBlobs(String key); 098 099 /** 100 * Returns the size of the blobs associated with the entry with the given {@code key} or {@code -1} if entry does 101 * not exist. 102 * 103 * @since 7.10 104 */ 105 long getSize(String key); 106 107 /** 108 * Returns {@code true} if the entry with the given {@code key} is ready. 109 * 110 * @since 7.10 111 */ 112 boolean isCompleted(String key); 113 114 /** 115 * Marks the entry with the given {@code key} as ready. 116 * <p> 117 * If entry does not exist a new entry is created. 118 * 119 * @since 7.10 120 */ 121 void setCompleted(String key, boolean completed); 122 123 /** 124 * Removes entry with the given {@code key}. 125 * <p> 126 * Has no effect if entry does not exist. 127 */ 128 void remove(String key); 129 130 /** 131 * Informs the store that the entry with the given {@code key} can be released if TTL or GC parameters require to do 132 * some cleanup. 133 * <p> 134 * Has no effect if entry does not exist. 135 */ 136 void release(String key); 137 138}