001    /**
002     * Copyright (c) 2000-2012 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(
038     * long,long)}. For all other portlets, the <code>repositoryId</code> should be
039     * set to {@link com.liferay.portal.model.CompanyConstants#SYSTEM}. These
040     * methods can be used in plugins and 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 com.liferay.portal.model.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 com.liferay.portal.model.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 com.liferay.portal.model.CompanyConstants#SYSTEM})
111             * @param  fileName the file name
112             * @param  validateFileExtension whether to validate the file's extension
113             * @param  file Name the file name
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 com.liferay.portal.model.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 com.liferay.portal.model.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 com.liferay.portal.model.CompanyConstants#SYSTEM})
176             * @param  fileName the file name
177             * @param  file Name the file name
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 com.liferay.portal.model.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 com.liferay.portal.model.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 com.liferay.portal.model.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 com.liferay.portal.model.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 com.liferay.portal.model.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 {@link
304             * 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 com.liferay.portal.model.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             */
315            public static File getFile(
316                            long companyId, long repositoryId, String fileName)
317                    throws PortalException, SystemException {
318    
319                    return getStore().getFile(companyId, repositoryId, fileName);
320            }
321    
322            /**
323             * Returns the file as a {@link File} object.
324             *
325             * <p>
326             * This method is useful when optimizing low-level file operations like
327             * copy. The client must not delete or change the returned {@link File}
328             * object in any way. This method is only supported in certain stores. If
329             * not supported, this method will throw an {@link
330             * UnsupportedOperationException}.
331             * </p>
332             *
333             * @param  companyId the primary key of the company
334             * @param  repositoryId the primary key of the data repository (optionally
335             *         {@link com.liferay.portal.model.CompanyConstants#SYSTEM})
336             * @param  fileName the file's name
337             * @param  versionLabel the file's version label
338             * @return Returns the {@link File} object with the file's name
339             * @throws PortalException if the file's information was invalid
340             * @throws SystemException if a system exception occurred
341             */
342            public static File getFile(
343                            long companyId, long repositoryId, String fileName,
344                            String versionLabel)
345                    throws PortalException, SystemException {
346    
347                    return getStore().getFile(
348                            companyId, repositoryId, fileName, versionLabel);
349            }
350    
351            /**
352             * Returns the file as a byte array.
353             *
354             * @param  companyId the primary key of the company
355             * @param  repositoryId the primary key of the data repository (optionally
356             *         {@link com.liferay.portal.model.CompanyConstants#SYSTEM})
357             * @param  fileName the file's name
358             * @return Returns the byte array with the file's name
359             * @throws PortalException if the file's information was invalid
360             * @throws SystemException if a system exception occurred
361             */
362            public static byte[] getFileAsBytes(
363                            long companyId, long repositoryId, String fileName)
364                    throws PortalException, SystemException {
365    
366                    return getStore().getFileAsBytes(companyId, repositoryId, fileName);
367            }
368    
369            /**
370             * Returns the file as a byte array.
371             *
372             * @param  companyId the primary key of the company
373             * @param  repositoryId the primary key of the data repository (optionally
374             *         {@link com.liferay.portal.model.CompanyConstants#SYSTEM})
375             * @param  fileName the file's name
376             * @param  versionLabel the file's version label
377             * @return Returns the byte array with the file's name
378             * @throws PortalException if the file's information was invalid
379             * @throws SystemException if a system exception occurred
380             */
381            public static byte[] getFileAsBytes(
382                            long companyId, long repositoryId, String fileName,
383                            String versionLabel)
384                    throws PortalException, SystemException {
385    
386                    return getStore().getFileAsBytes(
387                            companyId, repositoryId, fileName, versionLabel);
388            }
389    
390            /**
391             * Returns the file as an {@link java.io.InputStream} object.
392             *
393             * @param  companyId the primary key of the company
394             * @param  repositoryId the primary key of the data repository (optionally
395             *         {@link com.liferay.portal.model.CompanyConstants#SYSTEM})
396             * @param  fileName the file's name
397             * @return Returns the {@link java.io.InputStream} object with the file's
398             *         name
399             * @throws PortalException if the file's information was invalid
400             * @throws SystemException if a system exception occurred
401             */
402            public static InputStream getFileAsStream(
403                            long companyId, long repositoryId, String fileName)
404                    throws PortalException, SystemException {
405    
406                    return getStore().getFileAsStream(companyId, repositoryId, fileName);
407            }
408    
409            /**
410             * Returns the file as an {@link java.io.InputStream} object.
411             *
412             * @param  companyId the primary key of the company
413             * @param  repositoryId the primary key of the data repository (optionally
414             *         {@link com.liferay.portal.model.CompanyConstants#SYSTEM})
415             * @param  fileName the file's name
416             * @param  versionLabel the file's version label
417             * @return Returns the {@link java.io.InputStream} object with the file's
418             *         name
419             * @throws PortalException if the file's information was invalid
420             * @throws SystemException if a system exception occurred
421             */
422            public static InputStream getFileAsStream(
423                            long companyId, long repositoryId, String fileName,
424                            String versionLabel)
425                    throws PortalException, SystemException {
426    
427                    return getStore().getFileAsStream(
428                            companyId, repositoryId, fileName, versionLabel);
429            }
430    
431            /**
432             * Returns all files of the directory.
433             *
434             * @param  companyId the primary key of the company
435             * @param  repositoryId the primary key of the data repository (optionally
436             *         {@link com.liferay.portal.model.CompanyConstants#SYSTEM})
437             * @param  dirName the directory's name
438             * @return Returns all files of the directory
439             * @throws PortalException if the directory's information was invalid
440             * @throws SystemException if a system exception occurred
441             */
442            public static String[] getFileNames(
443                            long companyId, long repositoryId, String dirName)
444                    throws PortalException, SystemException {
445    
446                    return getStore().getFileNames(companyId, repositoryId, dirName);
447            }
448    
449            /**
450             * Returns the size of the file.
451             *
452             * @param  companyId the primary key of the company
453             * @param  repositoryId the primary key of the data repository (optionally
454             *         {@link com.liferay.portal.model.CompanyConstants#SYSTEM})
455             * @param  fileName the file's name
456             * @return Returns the size of the file
457             * @throws PortalException if the file's information was invalid
458             * @throws SystemException if a system exception occurred
459             */
460            public static long getFileSize(
461                            long companyId, long repositoryId, String fileName)
462                    throws PortalException, SystemException {
463    
464                    return getStore().getFileSize(companyId, repositoryId, fileName);
465            }
466    
467            /**
468             * Returns the {@link DLStore} object. Used primarily by Spring and should
469             * not be used by the client.
470             *
471             * @return Returns the {@link DLStore} object
472             */
473            public static DLStore getStore() {
474                    if (_store == null) {
475                            _store = (DLStore)PortalBeanLocatorUtil.locate(
476                                    DLStore.class.getName());
477    
478                            ReferenceRegistry.registerReference(DLStoreUtil.class, "_store");
479    
480                            MethodCache.remove(DLStore.class);
481                    }
482    
483                    return _store;
484            }
485    
486            /**
487             * Returns <code>true</code> if the directory exists.
488             *
489             * @param  companyId the primary key of the company
490             * @param  repositoryId the primary key of the data repository (optionally
491             *         {@link com.liferay.portal.model.CompanyConstants#SYSTEM})
492             * @param  dirName the directory's name
493             * @return <code>true</code> if the directory exists; <code>false</code>
494             *         otherwise
495             * @throws PortalException if the directory's information was invalid
496             * @throws SystemException if a system exception occurred
497             */
498            public static boolean hasDirectory(
499                            long companyId, long repositoryId, String dirName)
500                    throws PortalException, SystemException {
501    
502                    return getStore().hasDirectory(companyId, repositoryId, dirName);
503            }
504    
505            /**
506             * Returns <code>true</code> if the file exists.
507             *
508             * @param  companyId the primary key of the company
509             * @param  repositoryId the primary key of the data repository (optionally
510             *         {@link com.liferay.portal.model.CompanyConstants#SYSTEM})
511             * @param  fileName the file's name
512             * @return <code>true</code> if the file exists; <code>false</code>
513             *         otherwise
514             * @throws PortalException if the file's information was invalid
515             * @throws SystemException if a system exception occurred
516             */
517            public static boolean hasFile(
518                            long companyId, long repositoryId, String fileName)
519                    throws PortalException, SystemException {
520    
521                    return getStore().hasFile(companyId, repositoryId, fileName);
522            }
523    
524            /**
525             * Returns <code>true</code> if the file exists.
526             *
527             * @param  companyId the primary key of the company
528             * @param  repositoryId the primary key of the data repository (optionally
529             *         {@link com.liferay.portal.model.CompanyConstants#SYSTEM})
530             * @param  fileName the file's name
531             * @param  versionLabel the file's version label
532             * @return <code>true</code> if the file exists; <code>false</code>
533             *         otherwise
534             * @throws PortalException if the file's information was invalid
535             * @throws SystemException if a system exception occurred
536             */
537            public static boolean hasFile(
538                            long companyId, long repositoryId, String fileName,
539                            String versionLabel)
540                    throws PortalException, SystemException {
541    
542                    return getStore().hasFile(
543                            companyId, repositoryId, fileName, versionLabel);
544            }
545    
546            /**
547             * Moves an existing directory. Only implemented by {@link
548             * JCRStore#move(String, String)}.
549             *
550             * @param  srcDir the original directory's name
551             * @param  destDir the new directory's name
552             * @throws SystemException if a system exception occurred
553             */
554            public static void move(String srcDir, String destDir)
555                    throws SystemException {
556    
557                    getStore().move(srcDir, destDir);
558            }
559    
560            /**
561             * Moves a file to a new data repository.
562             *
563             * @param  companyId the primary key of the company
564             * @param  repositoryId the primary key of the data repository
565             * @param  newRepositoryId the primary key of the new data repository
566             * @param  fileName the file's name
567             * @throws PortalException if the file's information was invalid
568             * @throws SystemException if a system exception occurred
569             */
570            public static void updateFile(
571                            long companyId, long repositoryId, long newRepositoryId,
572                            String fileName)
573                    throws PortalException, SystemException {
574    
575                    getStore().updateFile(
576                            companyId, repositoryId, newRepositoryId, fileName);
577            }
578    
579            /**
580             * Update's the file's name
581             *
582             * @param  companyId the primary key of the company
583             * @param  repositoryId the primary key of the data repository (optionally
584             *         {@link com.liferay.portal.model.CompanyConstants#SYSTEM})
585             * @param  fileName the file's name
586             * @param  newFileName the file's new name
587             * @throws PortalException if the file's information was invalid
588             * @throws SystemException if a system exception occurred
589             */
590            public static void updateFile(
591                            long companyId, long repositoryId, String fileName,
592                            String newFileName)
593                    throws PortalException, SystemException {
594    
595                    getStore().updateFile(companyId, repositoryId, fileName, newFileName);
596            }
597    
598            /**
599             * Updates a file based on a {@link File} object.
600             *
601             * @param  companyId the primary key of the company
602             * @param  repositoryId the primary key of the data repository (optionally
603             *         {@link com.liferay.portal.model.CompanyConstants#SYSTEM})
604             * @param  fileName the file name
605             * @param  fileExtension the file's extension
606             * @param  validateFileExtension whether to validate the file's extension
607             * @param  versionLabel the file's new version label
608             * @param  sourceFileName the new file's original name
609             * @param  file Name the file name
610             * @throws PortalException if the file's information was invalid or is found
611             *         to contain a virus
612             * @throws SystemException if a system exception occurred
613             */
614            public static void updateFile(
615                            long companyId, long repositoryId, String fileName,
616                            String fileExtension, boolean validateFileExtension,
617                            String versionLabel, String sourceFileName, File file)
618                    throws PortalException, SystemException {
619    
620                    getStore().updateFile(
621                            companyId, repositoryId, fileName, fileExtension,
622                            validateFileExtension, versionLabel, sourceFileName, file);
623            }
624    
625            /**
626             * Updates a file based on a {@link InputStream} object.
627             *
628             * @param  companyId the primary key of the company
629             * @param  repositoryId the primary key of the data repository (optionally
630             *         {@link com.liferay.portal.model.CompanyConstants#SYSTEM})
631             * @param  fileName the file name
632             * @param  fileExtension the file's extension
633             * @param  validateFileExtension whether to validate the file's extension
634             * @param  versionLabel the file's new version label
635             * @param  sourceFileName the new file's original name
636             * @param  is the new file's data
637             * @throws PortalException if the file's information was invalid or is found
638             *         to contain a virus
639             * @throws SystemException if a system exception occurred
640             */
641            public static void updateFile(
642                            long companyId, long repositoryId, String fileName,
643                            String fileExtension, boolean validateFileExtension,
644                            String versionLabel, String sourceFileName, InputStream is)
645                    throws PortalException, SystemException {
646    
647                    getStore().updateFile(
648                            companyId, repositoryId, fileName, fileExtension,
649                            validateFileExtension, versionLabel, sourceFileName, is);
650            }
651    
652            /**
653             * Update's a file version label. Similar to {@link #copyFileVersion(long,
654             * long, String, String, String)} except that the old file version is
655             * deleted.
656             *
657             * @param  companyId the primary key of the company
658             * @param  repositoryId the primary key of the data repository (optionally
659             *         {@link com.liferay.portal.model.CompanyConstants#SYSTEM})
660             * @param  fileName the file's name
661             * @param  fromVersionLabel the file's version label
662             * @param  toVersionLabel the file's new version label
663             * @throws PortalException if the file's information was invalid
664             * @throws SystemException if a system exception occurred
665             */
666            public static void updateFileVersion(
667                            long companyId, long repositoryId, String fileName,
668                            String fromVersionLabel, String toVersionLabel)
669                    throws PortalException, SystemException {
670    
671                    getStore().updateFileVersion(
672                            companyId, repositoryId, fileName, fromVersionLabel,
673                            toVersionLabel);
674            }
675    
676            /**
677             * Validates a file's name.
678             *
679             * @param  fileName the file's name
680             * @param  validateFileExtension whether to validate the file's extension
681             * @throws PortalException if the file's information was invalid
682             * @throws SystemException if a system exception occurred
683             */
684            public static void validate(String fileName, boolean validateFileExtension)
685                    throws PortalException, SystemException {
686    
687                    getStore().validate(fileName, validateFileExtension);
688            }
689    
690            /**
691             * Validates a file's name and data.
692             *
693             * @param  fileName the file's name
694             * @param  validateFileExtension whether to validate the file's extension
695             * @param  bytes the file's data (optionally <code>null</code>)
696             * @throws PortalException if the file's information was invalid
697             * @throws SystemException if a system exception occurred
698             */
699            public static void validate(
700                            String fileName, boolean validateFileExtension, byte[] bytes)
701                    throws PortalException, SystemException {
702    
703                    getStore().validate(fileName, validateFileExtension, bytes);
704            }
705    
706            /**
707             * Validates a file's name and data.
708             *
709             * @param  fileName the file's name
710             * @param  validateFileExtension whether to validate the file's extension
711             * @param  file Name the file's name
712             * @throws PortalException if the file's information was invalid
713             * @throws SystemException if a system exception occurred
714             */
715            public static void validate(
716                            String fileName, boolean validateFileExtension, File file)
717                    throws PortalException, SystemException {
718    
719                    getStore().validate(fileName, validateFileExtension, file);
720            }
721    
722            /**
723             * Validates a file's name and data.
724             *
725             * @param  fileName the file's name
726             * @param  validateFileExtension whether to validate the file's extension
727             * @param  is the file's data (optionally <code>null</code>)
728             * @throws PortalException if the file's information was invalid
729             * @throws SystemException if a system exception occurred
730             */
731            public static void validate(
732                            String fileName, boolean validateFileExtension, InputStream is)
733                    throws PortalException, SystemException {
734    
735                    getStore().validate(fileName, validateFileExtension, is);
736            }
737    
738            /**
739             * Validates a file's name and data.
740             *
741             * @param  fileName the file's name
742             * @param  fileExtension the file's extension
743             * @param  sourceFileName the file's original name
744             * @param  validateFileExtension whether to validate the file's extension
745             * @param  file Name the file's name
746             * @throws PortalException if the file's information was invalid
747             * @throws SystemException if a system exception occurred
748             */
749            public static void validate(
750                            String fileName, String fileExtension, String sourceFileName,
751                            boolean validateFileExtension, File file)
752                    throws PortalException, SystemException {
753    
754                    getStore().validate(
755                            fileName, fileExtension, sourceFileName, validateFileExtension,
756                            file);
757            }
758    
759            /**
760             * Validates a file's name and data.
761             *
762             * @param  fileName the file's name
763             * @param  fileExtension the file's extension
764             * @param  sourceFileName the file's original name
765             * @param  validateFileExtension whether to validate the file's extension
766             * @param  is the file's data (optionally <code>null</code>)
767             * @throws PortalException if the file's information was invalid
768             * @throws SystemException if a system exception occurred
769             */
770            public static void validate(
771                            String fileName, String fileExtension, String sourceFileName,
772                            boolean validateFileExtension, InputStream is)
773                    throws PortalException, SystemException {
774    
775                    getStore().validate(
776                            fileName, fileExtension, sourceFileName, validateFileExtension, is);
777            }
778    
779            /**
780             * Set's the {@link DLStore} object. Used primarily by Spring and should not
781             * be used by the client.
782             *
783             * @param store the {@link DLStore} object
784             */
785            public void setStore(DLStore store) {
786                    _store = store;
787    
788                    ReferenceRegistry.registerReference(DLStoreUtil.class, "_store");
789    
790                    MethodCache.remove(DLStore.class);
791            }
792    
793            private static DLStore _store;
794    
795    }