1 /*
2 * Licensed to The Apereo Foundation under one or more contributor license
3 * agreements. See the NOTICE file distributed with this work for additional
4 * information regarding copyright ownership.
5 *
6 *
7 * The Apereo Foundation licenses this file to you under the Educational
8 * Community License, Version 2.0 (the "License"); you may not use this file
9 * except in compliance with the License. You may obtain a copy of the License
10 * at:
11 *
12 * http://opensource.org/licenses/ecl2.txt
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17 * License for the specific language governing permissions and limitations under
18 * the License.
19 *
20 */
21 package org.opencastproject.assetmanager.api.storage;
22
23 import org.opencastproject.storage.StorageUsage;
24
25 import java.io.InputStream;
26 import java.util.Optional;
27
28 /**
29 * Versioned storage for binary resources.
30 * <p>
31 * The ElementStore is designed to be as simple as possible, so that it must not have any additional logic or persistent
32 * storage of metadata.
33 */
34 public interface AssetStore extends StorageUsage {
35
36 String STORE_TYPE_PROPERTY = "store.type";
37
38 /** Add the content of <code>soure</code> under the given path. */
39 void put(StoragePath path, Source source) throws AssetStoreException;
40
41 /**
42 * Copy a resource to a new location.
43 *
44 * @return true, if the selected resource could be found and copied
45 */
46 boolean copy(StoragePath from, StoragePath to) throws AssetStoreException;
47
48 /** Get an input stream to a resource. */
49 Optional<InputStream> get(StoragePath path) throws AssetStoreException;
50
51 /** Check if a resource exists. */
52 boolean contains(StoragePath path) throws AssetStoreException;
53
54 /**
55 * Delete all selected resources.
56 *
57 * @return true, if the selected resources could be found and deleted
58 */
59 boolean delete(DeletionSelector sel) throws AssetStoreException;
60
61 /**
62 * Returns the store.type property
63 *
64 * @return store type
65 */
66 String getStoreType();
67 }