View Javadoc

1   /*
2    * Copyright (c) 2002-2014, Mairie de Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.plugins.blobstore.business.filesystem;
35  
36  import fr.paris.lutece.plugins.blobstore.business.BytesBlobStore;
37  import fr.paris.lutece.plugins.blobstore.business.InputStreamBlobStore;
38  
39  import java.io.IOException;
40  import java.io.InputStream;
41  
42  import javax.inject.Inject;
43  
44  
45  /**
46   * FileSystemBlobStoreHome.
47   */
48  public final class FileSystemBlobStoreHome implements IFileSystemBlobStoreHome
49  {
50      /** The Constant BEAN_SERVICE. */
51      public static final String BEAN_SERVICE = "blobstore.fileSystemBlobStoreHome";
52  
53      /** The _dao. */
54      @Inject
55      private IFileSystemBlobStoreDAO _dao;
56  
57      /*
58       * (non-Javadoc)
59       *
60       * @see fr.paris.lutece.plugins.blobstore.business.filesystem.
61       * IFileSystemBlobStoreHome
62       * #create(fr.paris.lutece.plugins.blobstore.business.BytesBlobStore,
63       * java.lang.String, java.lang.Integer)
64       */
65      @Override
66      public void create( final BytesBlobStore blobStore, final String strBasePath, final Integer depth )
67          throws IOException, FileAlreadyExistsException
68      {
69          _dao.insert( blobStore, strBasePath, depth );
70      }
71  
72      /*
73       * (non-Javadoc)
74       *
75       * @see fr.paris.lutece.plugins.blobstore.business.filesystem.
76       * IFileSystemBlobStoreHome
77       * #update(fr.paris.lutece.plugins.blobstore.business.BytesBlobStore,
78       * java.lang.String, java.lang.Integer)
79       */
80      @Override
81      public void update( final BytesBlobStore blobStore, final String strBasePath, final Integer depth )
82          throws IOException
83      {
84          _dao.store( blobStore, strBasePath, depth );
85      }
86  
87      /*
88       * (non-Javadoc)
89       *
90       * @see fr.paris.lutece.plugins.blobstore.business.filesystem.
91       * IFileSystemBlobStoreHome
92       * #updateInputStream(fr.paris.lutece.plugins.blobstore
93       * .business.InputStreamBlobStore, java.lang.String, java.lang.Integer)
94       */
95      @Override
96      public void updateInputStream( final InputStreamBlobStore blobStore, final String strBasePath, final Integer depth )
97          throws IOException
98      {
99          _dao.storeInputStream( blobStore, strBasePath, depth );
100     }
101 
102     /*
103      * (non-Javadoc)
104      *
105      * @see fr.paris.lutece.plugins.blobstore.business.filesystem.
106      * IFileSystemBlobStoreHome#remove(java.lang.String, java.lang.String,
107      * java.lang.Integer)
108      */
109     @Override
110     public boolean remove( final String strKey, final String strBasePath, final Integer depth )
111         throws IOException
112     {
113         return _dao.delete( strKey, strBasePath, depth );
114     }
115 
116     /*
117      * (non-Javadoc)
118      *
119      * @see fr.paris.lutece.plugins.blobstore.business.filesystem.
120      * IFileSystemBlobStoreHome#findByPrimaryKey(java.lang.String,
121      * java.lang.String, java.lang.Integer)
122      */
123     @Override
124     public BytesBlobStore findByPrimaryKey( final String strKey, final String strBasePath, final Integer depth )
125         throws IOException
126     {
127         return _dao.load( strKey, strBasePath, depth );
128     }
129 
130     /*
131      * (non-Javadoc)
132      *
133      * @see fr.paris.lutece.plugins.blobstore.business.filesystem.
134      * IFileSystemBlobStoreHome#findByPrimaryKeyInputStream(java.lang.String,
135      * java.lang.String, java.lang.Integer)
136      */
137     @Override
138     public InputStream findByPrimaryKeyInputStream( final String strKey, final String strBasePath, final Integer depth )
139         throws IOException
140     {
141         return _dao.loadInputStream( strKey, strBasePath, depth );
142     }
143 
144     /*
145      * (non-Javadoc)
146      *
147      * @see fr.paris.lutece.plugins.blobstore.business.filesystem.
148      * IFileSystemBlobStoreHome
149      * #createInputStream(fr.paris.lutece.plugins.blobstore
150      * .business.InputStreamBlobStore, java.lang.String, java.lang.Integer)
151      */
152     @Override
153     public void createInputStream( final InputStreamBlobStore blobStore, final String strBasePath, final Integer depth )
154         throws FileAlreadyExistsException, IOException
155     {
156         _dao.insert( blobStore, strBasePath, depth );
157     }
158 }