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 org.nuxeo.ecm.core.api.Blob; 022import org.nuxeo.ecm.core.model.Document; 023 024/** 025 * Context of blob (what document it's part of, its xpath, etc.). 026 * 027 * @since 11.1 028 */ 029public class BlobContext { 030 031 public final Blob blob; 032 033 public final String repositoryName; 034 035 public final String docId; 036 037 public final String xpath; 038 039 public BlobContext(Blob blob, Document doc, String xpath) { 040 this.blob = blob; 041 this.repositoryName = doc == null ? null : doc.getRepositoryName(); 042 this.docId = doc == null ? null : doc.getUUID(); 043 this.xpath = xpath; 044 } 045 046 public BlobContext(Blob blob) { 047 this(blob, (Document) null, null); 048 } 049 050 public BlobContext(Document doc, String xpath) { 051 this(null, doc, xpath); 052 } 053 054 // used for tests 055 public BlobContext(Blob blob, String docId, String xpath) { 056 this.blob = blob; 057 this.repositoryName = null; 058 this.docId = docId; 059 this.xpath = xpath; 060 } 061 062}