1 package SL::File::Backend;
5 use parent qw(Rose::Object);
7 sub store { die 'store needs to be implemented' }
9 sub delete { die 'delete needs to be implemented' }
11 sub rename { die 'rename needs to be implemented' }
13 sub get_content { die 'get_content needs to be implemented' }
15 sub get_filepath { die 'get_filepath needs to be implemented' }
17 sub get_mtime { die 'get_mtime needs to be implemented' }
19 sub get_version_count { die 'get_version_count needs to be implemented' }
23 sub sync_from_backend { }
35 SL::File::Backend - Base class for file storage backend
39 See the synopsis of L<SL::File> and L<SL::File::Object>
43 The most methods must be overridden by the specific storage backend
45 See also the overview of L<SL::File> and L<SL::File::Object>.
54 The file data is stored in the backend.
62 The object SL::DB::File as param.
64 =item C<file_contents>
66 The data of the file to store
70 If the data is still in a file, the contents of this file is copied.
74 If both parameter C<file_contents> and C<file_path> exists,
75 the backend is responsible in which way the contents is fetched.
77 If the file exists the backend is responsible to decide to save a new version of the file or override the
80 =item C<delete PARAMS>
82 The file data is deleted in the backend.
90 The object SL::DB::File as param.
94 If this parameter is set only the latest version of the file are deleted.
96 =item C<all_but_notlast>
98 If this parameter is set all versions of the file are deleted except the latest version.
100 If none of the two parameters C<all_versions> or C<all__but_notlast> is set
101 all version of the file are deleted.
103 =item C<file_version>
105 If this parameter is set only this file version will be deleted. The object has
106 to be of type C<SL::DB::FileVersion>.
110 =item C<rename PARAMS>
112 The Filename of the file is changed. If the backend is not dependent from the filename
113 nothing must happens. The rename must work on all versions of the file.
121 The object SL::DB::File as param.
125 =item C<get_version_count PARAMS>
127 The count of the available versions of a file will returned.
128 The versions are numbered from 1 up to the returned value
138 =item C<get_mtime PARAMS>
146 The object SL::DB::File as param.
150 The version number of the file for which the modification timestamp is wanted.
151 If no version set or version is 0 , the mtime of the latest version is returned.
155 =item C<get_content PARAMS>
157 For downloading or printing the real data need to retrieve.
158 A reference of the data must be returned.
166 The object SL::DB::File as param.
170 =item C<get_file_path PARAMS>
172 If the backend has files as storage, the file path can returned.
173 If a file is not available in the backend a temporary file must be created with the contents.
181 The object SL::DB::File as param.
187 returns 1 if the backend is enabled and has all config to work.
188 In other cases it must return 0
190 =item C<sync_from_backend>
192 For Backends which may be changed outside of kivitendo a synchronization of the database is done.
193 Normally the backend is responsible to actualise the data if it needed.
194 This interface can be used if a long work must be done and runs in a extra task.
200 L<SL::File>, L<SL::File::Object>
204 Martin Helmling E<lt>martin.helmling@opendynamic.deE<gt>