View Javadoc

1   /**
2    *
3    * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4    *
5    * ====================================================================
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   * ====================================================================
18   */
19  package org.jclouds.blobstore.domain;
20  
21  import java.io.File;
22  import java.io.IOException;
23  import java.io.InputStream;
24  import java.util.Map;
25  
26  import org.jclouds.blobstore.domain.internal.BlobBuilderImpl;
27  import org.jclouds.io.Payload;
28  import org.jclouds.io.Payloads;
29  
30  import com.google.inject.ImplementedBy;
31  
32  /**
33   * 
34   * In case the name was confusing, this indeed builds a Blob.
35   * 
36   * @author Adrian Cole
37   */
38  @ImplementedBy(BlobBuilderImpl.class)
39  public interface BlobBuilder {
40     /**
41      * @param name
42      *           The name of the {@link Blob}. Typically refers to an http path.
43      */
44     BlobBuilder name(String name);
45  
46     /**
47      * @param type
48      *           overrides default type of {@link StorageType#BLOB}
49      */
50     BlobBuilder type(StorageType type);
51  
52     /**
53      * @param userMetadata
54      *           User defined metadata associated with this {@link Blob}.
55      * 
56      */
57     BlobBuilder userMetadata(Map<String, String> userMetadata);
58  
59     /**
60      * 
61      * @param payload
62      *           payload you wish to construct the {@link Blob} with.
63      */
64     PayloadBlobBuilder payload(Payload payload);
65  
66     /**
67      * 
68      * @param payload
69      *           payload you wish to construct the {@link Blob} with.
70      */
71     PayloadBlobBuilder payload(InputStream payload);
72  
73     /**
74      * If you are creating a blob only for signing, use this. {@see BlobRequestSigner}
75      */
76     PayloadBlobBuilder forSigning();
77  
78     /**
79      * 
80      * @param payload
81      *           payload you wish to construct the {@link Blob} with.
82      */
83     PayloadBlobBuilder payload(byte[] payload);
84  
85     /**
86      * 
87      * @param payload
88      *           payload you wish to construct the {@link Blob} with.
89      */
90     PayloadBlobBuilder payload(String payload);
91  
92     /**
93      * 
94      * @param payload
95      *           payload you wish to construct the {@link Blob} with.
96      */
97     PayloadBlobBuilder payload(File payload);
98  
99     /**
100     * This makes a blob from the currently configured parameters.
101     * 
102     * @return a new blob from the current parameters
103     */
104    Blob build();
105 
106    public interface PayloadBlobBuilder extends BlobBuilder {
107 
108       PayloadBlobBuilder contentLength(long contentLength);
109 
110       PayloadBlobBuilder contentMD5(byte[] md5);
111 
112       PayloadBlobBuilder contentType(String contentType);
113 
114       PayloadBlobBuilder contentDisposition(String contentDisposition);
115 
116       PayloadBlobBuilder contentLanguage(String contentLanguage);
117 
118       PayloadBlobBuilder contentEncoding(String contentEncoding);
119 
120       /**
121        * 
122        * @see Payloads#calculateMD5
123        */
124       PayloadBlobBuilder calculateMD5() throws IOException;
125 
126    }
127 }