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