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