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 void writeExternal(ObjectOutput out) throws IOException { 050 out.writeLong(length); 051 out.writeObject(digest); 052 out.writeObject(mimeType); 053 out.writeObject(encoding); 054 out.writeObject(filename); 055 out.writeObject(key); 056 } 057 058 @Override 059 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { 060 length = in.readLong(); 061 digest = (String) in.readObject(); 062 mimeType = (String) in.readObject(); 063 encoding = (String) in.readObject(); 064 filename = (String) in.readObject(); 065 key = (String) in.readObject(); 066 } 067}