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