001/* 002 * (C) Copyright 2007 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 * Nuxeo - initial API and implementation 018 * 019 * $Id: DocumentBlob.java 13220 2007-03-03 18:45:30Z bstefanescu $ 020 */ 021 022package org.nuxeo.ecm.platform.api.ws; 023 024import java.io.IOException; 025import java.io.Serializable; 026 027import org.nuxeo.ecm.core.api.Blob; 028 029/** 030 * Web service document blob. 031 * 032 * @author <a href="mailto:ja@nuxeo.com">Julien Anguenot</a> 033 * @author <a href="mailto:td@nuxeo.com">Thierry Delprat</a> 034 */ 035public class DocumentBlob implements Serializable { 036 037 private static final long serialVersionUID = 1L; 038 039 private String encoding; 040 041 private String mimeType; 042 043 private String[] extensions; 044 045 private String name; 046 047 private byte[] blob; 048 049 private String url; 050 051 /** 052 * Empty ctor needed by tools like jaxb. 053 */ 054 public DocumentBlob() { 055 } 056 057 public DocumentBlob(String name, Blob blob) throws IOException { 058 this.blob = blob.getByteArray(); 059 encoding = blob.getEncoding(); 060 mimeType = blob.getMimeType(); 061 this.name = name; 062 } 063 064 public DocumentBlob(String name, String encoding, String mimeType, String downloadUrl) { 065 this.name = name; 066 this.encoding = encoding; 067 this.mimeType = mimeType; 068 url = downloadUrl; 069 } 070 071 /** 072 * Returns the name of the document field name. 073 * <p> 074 * We probably need to embed the name along with the schema prefix. 075 * 076 * @return the name of the document field name 077 */ 078 public String getName() { 079 return name; 080 } 081 082 /** 083 * Returns the main RFC-2046 mimetype name. 084 * 085 * @return the main RFC-2046 name 086 */ 087 public String getMimetype() { 088 return mimeType; 089 } 090 091 /** 092 * Returns the encoding of the blob. 093 * 094 * @return the encoding of the blob 095 */ 096 public String getEncoding() { 097 return encoding; 098 } 099 100 /** 101 * Returns the actual blob as a serializable input stream. 102 * 103 * @return the actual blob as a serializable input stream 104 */ 105 public byte[] getBlob() { 106 return blob; 107 } 108 109 public void setExtensions(String[] extensions) { 110 this.extensions = extensions; 111 } 112 113 public String[] getExtensions() { 114 return extensions; 115 } 116 117 public void setBlob(byte[] blob) { 118 this.blob = blob; 119 } 120 121 public void setMimetype(String mimeType) { 122 this.mimeType = mimeType; 123 } 124 125 public void setEncoding(String encoding) { 126 this.encoding = encoding; 127 } 128 129 public void setName(String name) { 130 this.name = name; 131 } 132 133 public String getDownloadUrl() { 134 return url; 135 } 136 137 public String getMimeType() { 138 return mimeType; 139 } 140 141 public void setMimeType(String mimeType) { 142 this.mimeType = mimeType; 143 } 144 145 public String getUrl() { 146 return url; 147 } 148 149 public void setUrl(String url) { 150 this.url = url; 151 } 152 153}