2f1da83d371a54b4791508c5247359d8234d981b
[kivitendo-erp.git] / SL / File / Backend.pm
1 package SL::File::Backend;
2
3 use strict;
4
5 use parent qw(Rose::Object);
6
7 sub store { die 'store needs to be implemented' }
8
9 sub delete { die 'delete needs to be implemented' }
10
11 sub rename { die 'rename needs to be implemented' }
12
13 sub get_content { die 'get_content needs to be implemented' }
14
15 sub get_filepath { die 'get_filepath needs to be implemented' }
16
17 sub get_mtime { die 'get_mtime needs to be implemented' }
18
19 sub get_version_count { die 'get_version_count needs to be implemented' }
20
21 sub enabled { 0; }
22
23 sub sync_from_backend { }
24
25 1;
26
27 __END__
28
29 =pod
30
31 =encoding utf8
32
33 =head1 NAME
34
35 SL::File::Backend  - Base class for file storage backend
36
37 =head1 SYNOPSIS
38
39 See the synopsis of L<SL::File> and L<SL::File::Object>
40
41 =head1 OVERVIEW
42
43 The most methods must be overridden by the specific storage backend
44
45 See also the overview of L<SL::File> and L<SL::File::Object>.
46
47
48 =head1 METHODS
49
50 =over 4
51
52 =item C<store PARAMS>
53
54 The file data is stored in the backend.
55
56 Available C<PARAMS>:
57
58 =over 4
59
60 =item C<dbfile>
61
62 The object SL::DB::File as param.
63
64 =item C<file_contents>
65
66 The data of the file to store
67
68 =item C<file_path>
69
70 If the data is still in a file, the contents of this file is copied.
71
72 =back
73
74 If both parameter C<file_contents> and C<file_path> exists,
75 the backend is responsible in which way the contents is fetched.
76
77 If the file exists the backend is responsible to decide to save a new version of the file or override the
78 latest existing file.
79
80 =item C<delete PARAMS>
81
82 The file data is deleted in the backend.
83
84 Available C<PARAMS>:
85
86 =over 4
87
88 =item C<dbfile>
89
90 The object SL::DB::File as param.
91
92 =item C<last>
93
94 If this parameter is set only the latest version of the file are deleted.
95
96 =item C<all_but_notlast>
97
98 If this parameter is set all versions of the file are deleted except the latest version.
99
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.
102
103 =back
104
105 =item C<rename PARAMS>
106
107 The Filename of the file is changed. If the backend is not dependent from the filename
108 nothing must happens. The rename must work on all versions of the file.
109
110 Available C<PARAMS>:
111
112 =over 4
113
114 =item C<dbfile>
115
116 The object SL::DB::File as param.
117
118 =back
119
120 =item C<get_version_count PARAMS>
121
122 The count of the available versions of a file will returned.
123 The versions are numbered from 1 up to the returned value
124
125 Available C<PARAMS>:
126
127 =over 4
128
129 =item C<dbfile>
130
131 =back
132
133 =item C<get_mtime PARAMS>
134
135 Available C<PARAMS>:
136
137 =over 4
138
139 =item C<dbfile>
140
141 The object SL::DB::File as param.
142
143 =item C<version>
144
145 The version number of the file for which the modification timestamp is wanted.
146 If no version set or version is 0 , the mtime of the latest version is returned.
147
148 =back
149
150 =item C<get_content PARAMS>
151
152 For downloading or printing the real data need to retrieve.
153 A reference of the data must be returned.
154
155 Available C<PARAMS>:
156
157 =over 4
158
159 =item C<dbfile>
160
161 The object SL::DB::File as param.
162
163 =back
164
165 =item C<get_file_path PARAMS>
166
167 If the backend has files as storage, the file path can returned.
168 If a file is not available in the backend a temporary file must be created with the contents.
169
170 Available C<PARAMS>:
171
172 =over 4
173
174 =item C<dbfile>
175
176 The object SL::DB::File as param.
177
178 =back
179
180 =item C<enabled>
181
182 returns 1 if the backend is enabled and has all config to work.
183 In other cases it must return 0
184
185 =item C<sync_from_backend>
186
187 For Backends which may be changed outside of kivitendo a synchronization of the database is done.
188 Normally the backend is responsible to actualise the data if it needed.
189 This interface can be used if a long work must be done and runs in a extra task.
190
191 =back
192
193 =head1 SEE ALSO
194
195 L<SL::File>, L<SL::File::Object>
196
197 =head1 AUTHOR
198
199 Martin Helmling E<lt>martin.helmling@opendynamic.deE<gt>
200
201 =cut