001/* 002 * (C) Copyright 2019 Nuxeo (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 * Florent Guillaume 018 */ 019package org.nuxeo.ecm.core.blob; 020 021import java.time.Duration; 022import java.util.Calendar; 023 024/** 025 * Context available when a blob is updated in a blob provider. 026 * 027 * @since 11.1 028 */ 029public class BlobUpdateContext { 030 031 /** The blob key, without blob provider prefix. */ 032 public final String key; 033 034 public UpdateRetainUntil updateRetainUntil; 035 036 public UpdateLegalHold updateLegalHold; 037 038 public RestoreForDuration restoreForDuration; 039 040 public BlobUpdateContext(String key) { 041 this.key = key; 042 } 043 044 public BlobUpdateContext with(BlobUpdateContext other) { 045 if (other.updateRetainUntil != null) { 046 updateRetainUntil = other.updateRetainUntil; 047 } 048 if (other.updateLegalHold != null) { 049 updateLegalHold = other.updateLegalHold; 050 } 051 if (other.restoreForDuration != null) { 052 restoreForDuration = other.restoreForDuration; 053 } 054 return this; 055 } 056 057 public BlobUpdateContext withUpdateRetainUntil(Calendar retainUntil) { 058 updateRetainUntil = new UpdateRetainUntil(retainUntil); 059 return this; 060 } 061 062 public BlobUpdateContext withUpdateLegalHold(boolean hold) { 063 updateLegalHold = new UpdateLegalHold(hold); 064 return this; 065 } 066 067 public BlobUpdateContext withRestoreForDuration(Duration duration) { 068 restoreForDuration = new RestoreForDuration(duration); 069 return this; 070 } 071 072 public static class UpdateRetainUntil { 073 074 public final Calendar retainUntil; 075 076 public UpdateRetainUntil(Calendar retainUntil) { 077 this.retainUntil = retainUntil; 078 } 079 080 } 081 082 public static class UpdateLegalHold { 083 084 public final boolean hold; 085 086 public UpdateLegalHold(boolean hold) { 087 this.hold = hold; 088 } 089 090 } 091 092 public static class RestoreForDuration { 093 094 public final Duration duration; 095 096 public RestoreForDuration(Duration duration) { 097 this.duration = duration; 098 } 099 100 } 101 102}