001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.documentlibrary.store;
016    
017    import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
018    import com.liferay.portal.kernel.exception.PortalException;
019    import com.liferay.portal.kernel.exception.SystemException;
020    import com.liferay.portal.kernel.util.MethodCache;
021    import com.liferay.portal.kernel.util.ReferenceRegistry;
022    
023    import java.io.File;
024    import java.io.InputStream;
025    
026    /**
027     * Provides methods for storing files in the portal. The file storage
028     * implementation can be selected in <code>portal.properties</code> under the
029     * property <code>dl.store.impl</code>. Virus checking can also be enabled under
030     * the property <code>dl.store.antivirus.impl</code>.
031     *
032     * <p>
033     * The main client for this class is the Document Library portlet. It is also
034     * used by other portlets like Wiki and Message Boards to store file
035     * attachments. For the Document Library portlet, the <code>repositoryId</code>
036     * can be obtained by calling {@link
037     * com.liferay.portlet.documentlibrary.model.DLFolderConstants#getDataRepositoryId(long,long)}.
038     * For all other portlets, the <code>repositoryId</code> should be set to
039     * {@link CompanyConstants#SYSTEM}. These methods can be used in plugins and
040     * other portlets, as shown below.
041     * </p>
042     *
043     * <pre>
044     * <code>
045     * long repositoryId = CompanyConstants.SYSTEM;
046     * String dirName = "portlet_name/1234";
047     *
048     * try {
049     * DLStoreUtil.addDirectory(companyId, repositoryId, dirName);
050     * }
051     * catch (DuplicateDirectoryException dde) {
052     * }
053     *
054     * DLStoreUtil.addFile(
055     * companyId, repositoryId, dirName + "/" + fileName, file);
056     * </code>
057     * </pre>
058     *
059     * @author Brian Wing Shun Chan
060     * @author Alexander Chow
061     * @author Edward Han
062     * @see DLStoreImpl
063     */
064    public class DLStoreUtil {
065    
066            /**
067             * Adds a directory.
068             *
069             * @param  companyId the primary key of the company
070             * @param  repositoryId the primary key of the data repository (optionally
071             *         {@link CompanyConstants#SYSTEM})
072             * @param  dirName the directory's name
073             * @throws PortalException if the directory's information was invalid
074             * @throws SystemException if a system exception occurred
075             */
076            public static void addDirectory(
077                            long companyId, long repositoryId, String dirName)
078                    throws PortalException, SystemException {
079    
080                    getStore().addDirectory(companyId, repositoryId, dirName);
081            }
082    
083            /**
084             * Adds a file based on a byte array.
085             *
086             * @param  companyId the primary key of the company
087             * @param  repositoryId the primary key of the data repository (optionally
088             *         {@link CompanyConstants#SYSTEM})
089             * @param  fileName the file name
090             * @param  validateFileExtension whether to validate the file's extension
091             * @param  bytes the files's data
092             * @throws PortalException if the file's information was invalid or is found
093             *         to contain a virus
094             * @throws SystemException if a system exception occurred
095             */
096            public static void addFile(
097                            long companyId, long repositoryId, String fileName,
098                            boolean validateFileExtension, byte[] bytes)
099                    throws PortalException, SystemException {
100    
101                    getStore().addFile(
102                            companyId, repositoryId, fileName, validateFileExtension, bytes);
103            }
104    
105            /**
106             * Adds a file based on a {@link File} object.
107             *
108             * @param  companyId the primary key of the company
109             * @param  repositoryId the primary key of the data repository (optionally
110             *         {@link CompanyConstants#SYSTEM})
111             * @param  fileName the file name
112             * @param  validateFileExtension whether to validate the file's extension
113             * @param  file the files's data
114             * @throws PortalException if the file's information was invalid or is found
115             *         to contain a virus
116             * @throws SystemException if a system exception occurred
117             */
118            public static void addFile(
119                            long companyId, long repositoryId, String fileName,
120                            boolean validateFileExtension, File file)
121                    throws PortalException, SystemException {
122    
123                    getStore().addFile(
124                            companyId, repositoryId, fileName, validateFileExtension, file);
125            }
126    
127            /**
128             * Adds a file based on a {@link InputStream} object.
129             *
130             * @param  companyId the primary key of the company
131             * @param  repositoryId the primary key of the data repository (optionally
132             *         {@link CompanyConstants#SYSTEM})
133             * @param  fileName the file name
134             * @param  validateFileExtension whether to validate the file's extension
135             * @param  is the files's data
136             * @throws PortalException if the file's information was invalid or is found
137             *         to contain a virus
138             * @throws SystemException if a system exception occurred
139             */
140            public static void addFile(
141                            long companyId, long repositoryId, String fileName,
142                            boolean validateFileExtension, InputStream is)
143                    throws PortalException, SystemException {
144    
145                    getStore().addFile(
146                            companyId, repositoryId, fileName, validateFileExtension, is);
147            }
148    
149            /**
150             * Adds a file based on a byte array. Enforces validation of file's
151             * extension.
152             *
153             * @param  companyId the primary key of the company
154             * @param  repositoryId the primary key of the data repository (optionally
155             *         {@link CompanyConstants#SYSTEM})
156             * @param  fileName the file name
157             * @param  bytes the files's data
158             * @throws PortalException if the file's information was invalid or is found
159             *         to contain a virus
160             * @throws SystemException if a system exception occurred
161             */
162            public static void addFile(
163                            long companyId, long repositoryId, String fileName, byte[] bytes)
164                    throws PortalException, SystemException {
165    
166                    getStore().addFile(companyId, repositoryId, fileName, bytes);
167            }
168    
169            /**
170             * Adds a file based on a {@link File} object. Enforces validation of file's
171             * extension.
172             *
173             * @param  companyId the primary key of the company
174             * @param  repositoryId the primary key of the data repository (optionally
175             *         {@link CompanyConstants#SYSTEM})
176             * @param  fileName the file name
177             * @param  file the files's data
178             * @throws PortalException if the file's information was invalid or is found
179             *         to contain a virus
180             * @throws SystemException if a system exception occurred
181             */
182            public static void addFile(
183                            long companyId, long repositoryId, String fileName, File file)
184                    throws PortalException, SystemException {
185    
186                    getStore().addFile(companyId, repositoryId, fileName, file);
187            }
188    
189            /**
190             * Adds a file based on an {@link InputStream} object. Enforces validation
191             * of file's extension.
192             *
193             * @param  companyId the primary key of the company
194             * @param  repositoryId the primary key of the data repository (optionally
195             *         {@link CompanyConstants#SYSTEM})
196             * @param  fileName the file name
197             * @param  is the files's data
198             * @throws PortalException if the file's information was invalid or is found
199             *         to contain a virus
200             * @throws SystemException if a system exception occurred
201             */
202            public static void addFile(
203                            long companyId, long repositoryId, String fileName, InputStream is)
204                    throws PortalException, SystemException {
205    
206                    getStore().addFile(companyId, repositoryId, fileName, is);
207            }
208    
209            /**
210             * Ensures company's root directory exists. Only implemented by {@link
211             * JCRStore#checkRoot(long)}.
212             *
213             * @param  companyId the primary key of the company
214             * @throws SystemException if a system exception occurred
215             */
216            public static void checkRoot(long companyId) throws SystemException {
217                    getStore().checkRoot(companyId);
218            }
219    
220            /**
221             * Creates a new copy of the file version.
222             *
223             * @param  companyId the primary key of the company
224             * @param  repositoryId the primary key of the data repository (optionally
225             *         {@link CompanyConstants#SYSTEM})
226             * @param  fileName the original's file name
227             * @param  fromVersionLabel the original file's version label
228             * @param  toVersionLabel the new version label
229             * @throws PortalException if the file's information was invalid
230             * @throws SystemException if a system exception occurred
231             */
232            public static void copyFileVersion(
233                            long companyId, long repositoryId, String fileName,
234                            String fromVersionLabel, String toVersionLabel)
235                    throws PortalException, SystemException {
236    
237                    getStore().copyFileVersion(
238                            companyId, repositoryId, fileName, fromVersionLabel,
239                            toVersionLabel);
240            }
241    
242            /**
243             * Deletes a directory.
244             *
245             * @param  companyId the primary key of the company
246             * @param  repositoryId the primary key of the data repository (optionally
247             *         {@link CompanyConstants#SYSTEM})
248             * @param  dirName the directory's name
249             * @throws PortalException if the directory's information was invalid
250             * @throws SystemException if a system exception occurred
251             */
252            public static void deleteDirectory(
253                            long companyId, long repositoryId, String dirName)
254                    throws PortalException, SystemException {
255    
256                    getStore().deleteDirectory(companyId, repositoryId, dirName);
257            }
258    
259            /**
260             * Deletes a file. If a file has multiple versions, all versions will be
261             * deleted.
262             *
263             * @param  companyId the primary key of the company
264             * @param  repositoryId the primary key of the data repository (optionally
265             *         {@link CompanyConstants#SYSTEM})
266             * @param  fileName the file's name
267             * @throws PortalException if the file's information was invalid
268             * @throws SystemException if a system exception occurred
269             */
270            public static void deleteFile(
271                            long companyId, long repositoryId, String fileName)
272                    throws PortalException, SystemException {
273    
274                    getStore().deleteFile(companyId, repositoryId, fileName);
275            }
276    
277            /**
278             * Deletes a file at a particular version.
279             *
280             * @param  companyId the primary key of the company
281             * @param  repositoryId the primary key of the data repository (optionally
282             *         {@link CompanyConstants#SYSTEM})
283             * @param  fileName the file's name
284             * @param  versionLabel the file's version label
285             * @throws PortalException if the file's information was invalid
286             * @throws SystemException if a system exception occurred
287             */
288            public static void deleteFile(
289                            long companyId, long repositoryId, String fileName,
290                            String versionLabel)
291                    throws PortalException, SystemException {
292    
293                    getStore().deleteFile(companyId, repositoryId, fileName, versionLabel);
294            }
295    
296            /**
297             * Returns the file as a {@link File} object.
298             *
299             * <p>
300             * This method is useful when optimizing low-level file operations like
301             * copy. The client must not delete or change the returned {@link File}
302             * object in any way. This method is only supported in certain stores. If
303             * not supported, this method will throw an
304             * {@link UnsupportedOperationException}.
305             * </p>
306             *
307             * @param  companyId the primary key of the company
308             * @param  repositoryId the primary key of the data repository (optionally
309             *         {@link CompanyConstants#SYSTEM})
310             * @param  fileName the file's name
311             * @return Returns the {@link File} object with the file's name
312             * @throws PortalException if the file's information was invalid
313             * @throws SystemException if a system exception occurred
314             * @throws UnsupportedOperationException if the method is unsupported by the
315             *         storage implementation
316             */
317            public static File getFile(
318                            long companyId, long repositoryId, String fileName)
319                    throws PortalException, SystemException {
320    
321                    return getStore().getFile(companyId, repositoryId, fileName);
322            }
323    
324            /**
325             * Returns the file as a {@link File} object.
326             *
327             * <p>
328             * This method is useful when optimizing low-level file operations like
329             * copy. The client must not delete or change the returned {@link File}
330             * object in any way. This method is only supported in certain stores. If
331             * not supported, this method will throw an
332             * {@link UnsupportedOperationException}.
333             * </p>
334             *
335             * @param  companyId the primary key of the company
336             * @param  repositoryId the primary key of the data repository (optionally
337             *         {@link CompanyConstants#SYSTEM})
338             * @param  fileName the file's name
339             * @param  versionLabel the file's version label
340             * @return Returns the {@link File} object with the file's name
341             * @throws PortalException if the file's information was invalid
342             * @throws SystemException if a system exception occurred
343             * @throws UnsupportedOperationException if the method is unsupported by the
344             *         storage implementation
345             */
346            public static File getFile(
347                            long companyId, long repositoryId, String fileName,
348                            String versionLabel)
349                    throws PortalException, SystemException {
350    
351                    return getStore().getFile(
352                            companyId, repositoryId, fileName, versionLabel);
353            }
354    
355            /**
356             * Returns the file as a byte array.
357             *
358             * @param  companyId the primary key of the company
359             * @param  repositoryId the primary key of the data repository (optionally
360             *         {@link CompanyConstants#SYSTEM})
361             * @param  fileName the file's name
362             * @return Returns the byte array with the file's name
363             * @throws PortalException if the file's information was invalid
364             * @throws SystemException if a system exception occurred
365             */
366            public static byte[] getFileAsBytes(
367                            long companyId, long repositoryId, String fileName)
368                    throws PortalException, SystemException {
369    
370                    return getStore().getFileAsBytes(companyId, repositoryId, fileName);
371            }
372    
373            /**
374             * Returns the file as a byte array.
375             *
376             * @param  companyId the primary key of the company
377             * @param  repositoryId the primary key of the data repository (optionally
378             *         {@link CompanyConstants#SYSTEM})
379             * @param  fileName the file's name
380             * @param  versionLabel the file's version label
381             * @return Returns the byte array with the file's name
382             * @throws PortalException if the file's information was invalid
383             * @throws SystemException if a system exception occurred
384             */
385            public static byte[] getFileAsBytes(
386                            long companyId, long repositoryId, String fileName,
387                            String versionLabel)
388                    throws PortalException, SystemException {
389    
390                    return getStore().getFileAsBytes(
391                            companyId, repositoryId, fileName, versionLabel);
392            }
393    
394            /**
395             * Returns the file as an {@link InputStream} object.
396             *
397             * @param  companyId the primary key of the company
398             * @param  repositoryId the primary key of the data repository (optionally
399             *         {@link CompanyConstants#SYSTEM})
400             * @param  fileName the file's name
401             * @return Returns the {@link InputStream} object with the file's name
402             * @throws PortalException if the file's information was invalid
403             * @throws SystemException if a system exception occurred
404             */
405            public static InputStream getFileAsStream(
406                            long companyId, long repositoryId, String fileName)
407                    throws PortalException, SystemException {
408    
409                    return getStore().getFileAsStream(companyId, repositoryId, fileName);
410            }
411    
412            /**
413             * Returns the file as an {@link InputStream} object.
414             *
415             * @param  companyId the primary key of the company
416             * @param  repositoryId the primary key of the data repository (optionally
417             *         {@link CompanyConstants#SYSTEM})
418             * @param  fileName the file's name
419             * @param  versionLabel the file's version label
420             * @return Returns the {@link InputStream} object with the file's name
421             * @throws PortalException if the file's information was invalid
422             * @throws SystemException if a system exception occurred
423             */
424            public static InputStream getFileAsStream(
425                            long companyId, long repositoryId, String fileName,
426                            String versionLabel)
427                    throws PortalException, SystemException {
428    
429                    return getStore().getFileAsStream(
430                            companyId, repositoryId, fileName, versionLabel);
431            }
432    
433            /**
434             * Returns all files of the directory.
435             *
436             * @param  companyId the primary key of the company
437             * @param  repositoryId the primary key of the data repository (optionally
438             *         {@link CompanyConstants#SYSTEM})
439             * @param  dirName the directory's name
440             * @return Returns all files of the directory
441             * @throws PortalException if the directory's information was invalid
442             * @throws SystemException if a system exception occurred
443             */
444            public static String[] getFileNames(
445                            long companyId, long repositoryId, String dirName)
446                    throws PortalException, SystemException {
447    
448                    return getStore().getFileNames(companyId, repositoryId, dirName);
449            }
450    
451            /**
452             * Returns the size of the file.
453             *
454             * @param  companyId the primary key of the company
455             * @param  repositoryId the primary key of the data repository (optionally
456             *         {@link CompanyConstants#SYSTEM})
457             * @param  fileName the file's name
458             * @return Returns the size of the file
459             * @throws PortalException if the file's information was invalid
460             * @throws SystemException if a system exception occurred
461             */
462            public static long getFileSize(
463                            long companyId, long repositoryId, String fileName)
464                    throws PortalException, SystemException {
465    
466                    return getStore().getFileSize(companyId, repositoryId, fileName);
467            }
468    
469            /**
470             * Returns the {@link DLStore} object. Used primarily by Spring and should
471             * not be used by the client.
472             *
473             * @return Returns the {@link DLStore} object
474             */
475            public static DLStore getStore() {
476                    if (_store == null) {
477                            _store = (DLStore)PortalBeanLocatorUtil.locate(
478                                    DLStore.class.getName());
479    
480                            ReferenceRegistry.registerReference(DLStoreUtil.class, "_store");
481    
482                            MethodCache.remove(DLStore.class);
483                    }
484    
485                    return _store;
486            }
487    
488            /**
489             * Returns <code>true</code> if the directory exists.
490             *
491             * @param  companyId the primary key of the company
492             * @param  repositoryId the primary key of the data repository (optionally
493             *         {@link CompanyConstants#SYSTEM})
494             * @param  dirName the directory's name
495             * @return <code>true</code> if the directory exists; <code>false</code>
496             *         otherwise
497             * @throws PortalException if the directory's information was invalid
498             * @throws SystemException if a system exception occurred
499             */
500            public static boolean hasDirectory(
501                            long companyId, long repositoryId, String dirName)
502                    throws PortalException, SystemException {
503    
504                    return getStore().hasDirectory(companyId, repositoryId, dirName);
505            }
506    
507            /**
508             * Returns <code>true</code> if the file exists.
509             *
510             * @param  companyId the primary key of the company
511             * @param  repositoryId the primary key of the data repository (optionally
512             *         {@link CompanyConstants#SYSTEM})
513             * @param  fileName the file's name
514             * @return <code>true</code> if the file exists; <code>false</code>
515             *         otherwise
516             * @throws PortalException if the file's information was invalid
517             * @throws SystemException if a system exception occurred
518             */
519            public static boolean hasFile(
520                            long companyId, long repositoryId, String fileName)
521                    throws PortalException, SystemException {
522    
523                    return getStore().hasFile(companyId, repositoryId, fileName);
524            }
525    
526            /**
527             * Returns <code>true</code> if the file exists.
528             *
529             * @param  companyId the primary key of the company
530             * @param  repositoryId the primary key of the data repository (optionally
531             *         {@link CompanyConstants#SYSTEM})
532             * @param  fileName the file's name
533             * @param  versionLabel the file's version label
534             * @return <code>true</code> if the file exists; <code>false</code>
535             *         otherwise
536             * @throws PortalException if the file's information was invalid
537             * @throws SystemException if a system exception occurred
538             */
539            public static boolean hasFile(
540                            long companyId, long repositoryId, String fileName,
541                            String versionLabel)
542                    throws PortalException, SystemException {
543    
544                    return getStore().hasFile(
545                            companyId, repositoryId, fileName, versionLabel);
546            }
547    
548            /**
549             * Moves an existing directory. Only implemented by {@link
550             * JCRStore#move(String, String)}.
551             *
552             * @param  srcDir the original directory's name
553             * @param  destDir the new directory's name
554             * @throws SystemException if a system exception occurred
555             */
556            public static void move(String srcDir, String destDir)
557                    throws SystemException {
558    
559                    getStore().move(srcDir, destDir);
560            }
561    
562            /**
563             * Moves a file to a new data repository.
564             *
565             * @param  companyId the primary key of the company
566             * @param  repositoryId the primary key of the data repository
567             * @param  newRepositoryId the primary key of the new data repository
568             * @param  fileName the file's name
569             * @throws PortalException if the file's information was invalid
570             * @throws SystemException if a system exception occurred
571             */
572            public static void updateFile(
573                            long companyId, long repositoryId, long newRepositoryId,
574                            String fileName)
575                    throws PortalException, SystemException {
576    
577                    getStore().updateFile(
578                            companyId, repositoryId, newRepositoryId, fileName);
579            }
580    
581            /**
582             * Update's the file's name
583             *
584             * @param  companyId the primary key of the company
585             * @param  repositoryId the primary key of the data repository (optionally
586             *         {@link CompanyConstants#SYSTEM})
587             * @param  fileName the file's name
588             * @param  newFileName the file's new name
589             * @throws PortalException if the file's information was invalid
590             * @throws SystemException if a system exception occurred
591             */
592            public static void updateFile(
593                            long companyId, long repositoryId, String fileName,
594                            String newFileName)
595                    throws PortalException, SystemException {
596    
597                    getStore().updateFile(companyId, repositoryId, fileName, newFileName);
598            }
599    
600            /**
601             * Updates a file based on a {@link File} object.
602             *
603             * @param  companyId the primary key of the company
604             * @param  repositoryId the primary key of the data repository (optionally
605             *         {@link CompanyConstants#SYSTEM})
606             * @param  fileName the file name
607             * @param  fileExtension the file's extension
608             * @param  validateFileExtension whether to validate the file's extension
609             * @param  versionLabel the file's new version label
610             * @param  sourceFileName the new file's original name
611             * @param  file the file's new data
612             * @throws PortalException if the file's information was invalid or is found
613             *         to contain a virus
614             * @throws SystemException if a system exception occurred
615             */
616            public static void updateFile(
617                            long companyId, long repositoryId, String fileName,
618                            String fileExtension, boolean validateFileExtension,
619                            String versionLabel, String sourceFileName, File file)
620                    throws PortalException, SystemException {
621    
622                    getStore().updateFile(
623                            companyId, repositoryId, fileName, fileExtension,
624                            validateFileExtension, versionLabel, sourceFileName, file);
625            }
626    
627            /**
628             * Updates a file based on a {@link InputStream} object.
629             *
630             * @param  companyId the primary key of the company
631             * @param  repositoryId the primary key of the data repository (optionally
632             *         {@link CompanyConstants#SYSTEM})
633             * @param  fileName the file name
634             * @param  fileExtension the file's extension
635             * @param  validateFileExtension whether to validate the file's extension
636             * @param  versionLabel the file's new version label
637             * @param  sourceFileName the new file's original name
638             * @param  is the new file's data
639             * @throws PortalException if the file's information was invalid or is found
640             *         to contain a virus
641             * @throws SystemException if a system exception occurred
642             */
643            public static void updateFile(
644                            long companyId, long repositoryId, String fileName,
645                            String fileExtension, boolean validateFileExtension,
646                            String versionLabel, String sourceFileName, InputStream is)
647                    throws PortalException, SystemException {
648    
649                    getStore().updateFile(
650                            companyId, repositoryId, fileName, fileExtension,
651                            validateFileExtension, versionLabel, sourceFileName, is);
652            }
653    
654            /**
655             * Update's a file version label. Similar to {@link
656             * #copyFileVersion(long, long, String, String, String, String)} except that
657             * the old file version is deleted.
658             *
659             * @param  companyId the primary key of the company
660             * @param  repositoryId the primary key of the data repository (optionally
661             *         {@link CompanyConstants#SYSTEM})
662             * @param  fileName the file's name
663             * @param  fromVersionLabel the file's version label
664             * @param  toVersionLabel the file's new version label
665             * @throws PortalException if the file's information was invalid
666             * @throws SystemException if a system exception occurred
667             */
668            public static void updateFileVersion(
669                            long companyId, long repositoryId, String fileName,
670                            String fromVersionLabel, String toVersionLabel)
671                    throws PortalException, SystemException {
672    
673                    getStore().updateFileVersion(
674                            companyId, repositoryId, fileName, fromVersionLabel,
675                            toVersionLabel);
676            }
677    
678            /**
679             * Validates a file's name.
680             *
681             * @param  fileName the file's name
682             * @param  validateFileExtension whether to validate the file's extension
683             * @throws PortalException if the file's information was invalid
684             * @throws SystemException if a system exception occurred
685             */
686            public static void validate(String fileName, boolean validateFileExtension)
687                    throws PortalException, SystemException {
688    
689                    getStore().validate(fileName, validateFileExtension);
690            }
691    
692            /**
693             * Validates a file's name and data.
694             *
695             * @param  fileName the file's name
696             * @param  validateFileExtension whether to validate the file's extension
697             * @param  bytes the file's data (optionally <code>null</code>)
698             * @throws PortalException if the file's information was invalid
699             * @throws SystemException if a system exception occurred
700             */
701            public static void validate(
702                            String fileName, boolean validateFileExtension, byte[] bytes)
703                    throws PortalException, SystemException {
704    
705                    getStore().validate(fileName, validateFileExtension, bytes);
706            }
707    
708            /**
709             * Validates a file's name and data.
710             *
711             * @param  fileName the file's name
712             * @param  validateFileExtension whether to validate the file's extension
713             * @param  file the file's data (optionally <code>null</code>)
714             * @throws PortalException if the file's information was invalid
715             * @throws SystemException if a system exception occurred
716             */
717            public static void validate(
718                            String fileName, boolean validateFileExtension, File file)
719                    throws PortalException, SystemException {
720    
721                    getStore().validate(fileName, validateFileExtension, file);
722            }
723    
724            /**
725             * Validates a file's name and data.
726             *
727             * @param  fileName the file's name
728             * @param  validateFileExtension whether to validate the file's extension
729             * @param  is the file's data (optionally <code>null</code>)
730             * @throws PortalException if the file's information was invalid
731             * @throws SystemException if a system exception occurred
732             */
733            public static void validate(
734                            String fileName, boolean validateFileExtension, InputStream is)
735                    throws PortalException, SystemException {
736    
737                    getStore().validate(fileName, validateFileExtension, is);
738            }
739    
740            /**
741             * Validates a file's name and data.
742             *
743             * @param  fileName the file's name
744             * @param  fileExtension the file's extension
745             * @param  sourceFileName the file's original name
746             * @param  validateFileExtension whether to validate the file's extension
747             * @param  file the file's data (optionally <code>null</code>)
748             * @throws PortalException if the file's information was invalid
749             * @throws SystemException if a system exception occurred
750             */
751            public static void validate(
752                            String fileName, String fileExtension, String sourceFileName,
753                            boolean validateFileExtension, File file)
754                    throws PortalException, SystemException {
755    
756                    getStore().validate(
757                            fileName, fileExtension, sourceFileName, validateFileExtension,
758                            file);
759            }
760    
761            /**
762             * Validates a file's name and data.
763             *
764             * @param  fileName the file's name
765             * @param  fileExtension the file's extension
766             * @param  sourceFileName the file's original name
767             * @param  validateFileExtension whether to validate the file's extension
768             * @param  is the file's data (optionally <code>null</code>)
769             * @throws PortalException if the file's information was invalid
770             * @throws SystemException if a system exception occurred
771             */
772            public static void validate(
773                            String fileName, String fileExtension, String sourceFileName,
774                            boolean validateFileExtension, InputStream is)
775                    throws PortalException, SystemException {
776    
777                    getStore().validate(
778                            fileName, fileExtension, sourceFileName, validateFileExtension, is);
779            }
780    
781            /**
782             * Set's the {@link DLStore} object. Used primarily by Spring and should not
783             * be used by the client.
784             *
785             * @param store the {@link DLStore} object
786             */
787            public void setStore(DLStore store) {
788                    _store = store;
789    
790                    ReferenceRegistry.registerReference(DLStoreUtil.class, "_store");
791    
792                    MethodCache.remove(DLStore.class);
793            }
794    
795            private static DLStore _store;
796    
797    }