001/* 002 * (C) Copyright 2016 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 * bdelbosc 018 */ 019package org.nuxeo.importer.stream.message; 020 021import java.io.IOException; 022import java.io.ObjectInput; 023import java.io.ObjectOutput; 024 025import org.nuxeo.ecm.core.blob.BlobInfo; 026import org.nuxeo.lib.stream.pattern.Message; 027 028/** 029 * A message holding BlobInfo. 030 * 031 * @since 9.3 032 */ 033public class BlobInfoMessage extends BlobInfo implements Message { 034 static final long serialVersionUID = 20170803L; 035 036 public BlobInfoMessage() { 037 } 038 039 public BlobInfoMessage(BlobInfo info) { 040 super(info); 041 } 042 043 @Override 044 public String getId() { 045 return digest; 046 } 047 048 @Override 049 public String toString() { 050 return "BlobInfoMessage{" + 051 "key='" + key + '\'' + 052 ", mimeType='" + mimeType + '\'' + 053 ", encoding='" + encoding + '\'' + 054 ", filename='" + filename + '\'' + 055 ", length=" + length + 056 ", digest='" + digest + '\'' + 057 '}'; 058 } 059 060 @Override 061 public void writeExternal(ObjectOutput out) throws IOException { 062 out.writeLong(length); 063 out.writeObject(digest); 064 out.writeObject(mimeType); 065 out.writeObject(encoding); 066 out.writeObject(filename); 067 out.writeObject(key); 068 } 069 070 @Override 071 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { 072 length = in.readLong(); 073 digest = (String) in.readObject(); 074 mimeType = (String) in.readObject(); 075 encoding = (String) in.readObject(); 076 filename = (String) in.readObject(); 077 key = (String) in.readObject(); 078 } 079}