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            public static boolean isValidName(String name) {
570                    return getStore().isValidName(name);
571            }
572    
573            /**
574             * Moves an existing directory. Only implemented by {@link
575             * JCRStore#move(String, String)}.
576             *
577             * @param  srcDir the original directory's name
578             * @param  destDir the new directory's name
579             * @throws SystemException if a system exception occurred
580             */
581            public static void move(String srcDir, String destDir)
582                    throws SystemException {
583    
584                    getStore().move(srcDir, destDir);
585            }
586    
587            /**
588             * Moves a file to a new data repository.
589             *
590             * @param  companyId the primary key of the company
591             * @param  repositoryId the primary key of the data repository
592             * @param  newRepositoryId the primary key of the new data repository
593             * @param  fileName the file's name
594             * @throws PortalException if the file's information was invalid
595             * @throws SystemException if a system exception occurred
596             */
597            public static void updateFile(
598                            long companyId, long repositoryId, long newRepositoryId,
599                            String fileName)
600                    throws PortalException, SystemException {
601    
602                    getStore().updateFile(
603                            companyId, repositoryId, newRepositoryId, fileName);
604            }
605    
606            /**
607             * Update's the file's name
608             *
609             * @param  companyId the primary key of the company
610             * @param  repositoryId the primary key of the data repository (optionally
611             *         {@link com.liferay.portal.model.CompanyConstants#SYSTEM})
612             * @param  fileName the file's name
613             * @param  newFileName the file's new name
614             * @throws PortalException if the file's information was invalid
615             * @throws SystemException if a system exception occurred
616             */
617            public static void updateFile(
618                            long companyId, long repositoryId, String fileName,
619                            String newFileName)
620                    throws PortalException, SystemException {
621    
622                    getStore().updateFile(companyId, repositoryId, fileName, newFileName);
623            }
624    
625            /**
626             * Updates a file based on a {@link File} object.
627             *
628             * @param  companyId the primary key of the company
629             * @param  repositoryId the primary key of the data repository (optionally
630             *         {@link com.liferay.portal.model.CompanyConstants#SYSTEM})
631             * @param  fileName the file name
632             * @param  fileExtension the file's extension
633             * @param  validateFileExtension whether to validate the file's extension
634             * @param  versionLabel the file's new version label
635             * @param  sourceFileName the new file's original name
636             * @param  file Name the file name
637             * @throws PortalException if the file's information was invalid or is found
638             *         to contain a virus
639             * @throws SystemException if a system exception occurred
640             */
641            public static void updateFile(
642                            long companyId, long repositoryId, String fileName,
643                            String fileExtension, boolean validateFileExtension,
644                            String versionLabel, String sourceFileName, File file)
645                    throws PortalException, SystemException {
646    
647                    getStore().updateFile(
648                            companyId, repositoryId, fileName, fileExtension,
649                            validateFileExtension, versionLabel, sourceFileName, file);
650            }
651    
652            /**
653             * Updates a file based on a {@link InputStream} object.
654             *
655             * @param  companyId the primary key of the company
656             * @param  repositoryId the primary key of the data repository (optionally
657             *         {@link com.liferay.portal.model.CompanyConstants#SYSTEM})
658             * @param  fileName the file name
659             * @param  fileExtension the file's extension
660             * @param  validateFileExtension whether to validate the file's extension
661             * @param  versionLabel the file's new version label
662             * @param  sourceFileName the new file's original name
663             * @param  is the new file's data
664             * @throws PortalException if the file's information was invalid or is found
665             *         to contain a virus
666             * @throws SystemException if a system exception occurred
667             */
668            public static void updateFile(
669                            long companyId, long repositoryId, String fileName,
670                            String fileExtension, boolean validateFileExtension,
671                            String versionLabel, String sourceFileName, InputStream is)
672                    throws PortalException, SystemException {
673    
674                    getStore().updateFile(
675                            companyId, repositoryId, fileName, fileExtension,
676                            validateFileExtension, versionLabel, sourceFileName, is);
677            }
678    
679            /**
680             * Update's a file version label. Similar to {@link #copyFileVersion(long,
681             * long, String, String, String)} except that the old file version is
682             * deleted.
683             *
684             * @param  companyId the primary key of the company
685             * @param  repositoryId the primary key of the data repository (optionally
686             *         {@link com.liferay.portal.model.CompanyConstants#SYSTEM})
687             * @param  fileName the file's name
688             * @param  fromVersionLabel the file's version label
689             * @param  toVersionLabel the file's new version label
690             * @throws PortalException if the file's information was invalid
691             * @throws SystemException if a system exception occurred
692             */
693            public static void updateFileVersion(
694                            long companyId, long repositoryId, String fileName,
695                            String fromVersionLabel, String toVersionLabel)
696                    throws PortalException, SystemException {
697    
698                    getStore().updateFileVersion(
699                            companyId, repositoryId, fileName, fromVersionLabel,
700                            toVersionLabel);
701            }
702    
703            /**
704             * Validates a file's name.
705             *
706             * @param  fileName the file's name
707             * @param  validateFileExtension whether to validate the file's extension
708             * @throws PortalException if the file's information was invalid
709             * @throws SystemException if a system exception occurred
710             */
711            public static void validate(String fileName, boolean validateFileExtension)
712                    throws PortalException, SystemException {
713    
714                    getStore().validate(fileName, validateFileExtension);
715            }
716    
717            /**
718             * Validates a file's name and data.
719             *
720             * @param  fileName the file's name
721             * @param  validateFileExtension whether to validate the file's extension
722             * @param  bytes the file's data (optionally <code>null</code>)
723             * @throws PortalException if the file's information was invalid
724             * @throws SystemException if a system exception occurred
725             */
726            public static void validate(
727                            String fileName, boolean validateFileExtension, byte[] bytes)
728                    throws PortalException, SystemException {
729    
730                    getStore().validate(fileName, validateFileExtension, bytes);
731            }
732    
733            /**
734             * Validates a file's name and data.
735             *
736             * @param  fileName the file's name
737             * @param  validateFileExtension whether to validate the file's extension
738             * @param  file Name the file's name
739             * @throws PortalException if the file's information was invalid
740             * @throws SystemException if a system exception occurred
741             */
742            public static void validate(
743                            String fileName, boolean validateFileExtension, File file)
744                    throws PortalException, SystemException {
745    
746                    getStore().validate(fileName, validateFileExtension, file);
747            }
748    
749            /**
750             * Validates a file's name and data.
751             *
752             * @param  fileName the file's name
753             * @param  validateFileExtension whether to validate the file's extension
754             * @param  is the file's data (optionally <code>null</code>)
755             * @throws PortalException if the file's information was invalid
756             * @throws SystemException if a system exception occurred
757             */
758            public static void validate(
759                            String fileName, boolean validateFileExtension, InputStream is)
760                    throws PortalException, SystemException {
761    
762                    getStore().validate(fileName, validateFileExtension, is);
763            }
764    
765            /**
766             * Validates a file's name and data.
767             *
768             * @param  fileName the file's name
769             * @param  fileExtension the file's extension
770             * @param  sourceFileName the file's original name
771             * @param  validateFileExtension whether to validate the file's extension
772             * @param  file Name the file's name
773             * @throws PortalException if the file's information was invalid
774             * @throws SystemException if a system exception occurred
775             */
776            public static void validate(
777                            String fileName, String fileExtension, String sourceFileName,
778                            boolean validateFileExtension, File file)
779                    throws PortalException, SystemException {
780    
781                    getStore().validate(
782                            fileName, fileExtension, sourceFileName, validateFileExtension,
783                            file);
784            }
785    
786            /**
787             * Validates a file's name and data.
788             *
789             * @param  fileName the file's name
790             * @param  fileExtension the file's extension
791             * @param  sourceFileName the file's original name
792             * @param  validateFileExtension whether to validate the file's extension
793             * @param  is the file's data (optionally <code>null</code>)
794             * @throws PortalException if the file's information was invalid
795             * @throws SystemException if a system exception occurred
796             */
797            public static void validate(
798                            String fileName, String fileExtension, String sourceFileName,
799                            boolean validateFileExtension, InputStream is)
800                    throws PortalException, SystemException {
801    
802                    getStore().validate(
803                            fileName, fileExtension, sourceFileName, validateFileExtension, is);
804            }
805    
806            public static void validateDirectoryName(String directoryName)
807                    throws PortalException {
808    
809                    getStore().validateDirectoryName(directoryName);
810            }
811    
812            /**
813             * Set's the {@link DLStore} object. Used primarily by Spring and should not
814             * be used by the client.
815             *
816             * @param store the {@link DLStore} object
817             */
818            public void setStore(DLStore store) {
819                    _store = store;
820    
821                    ReferenceRegistry.registerReference(DLStoreUtil.class, "_store");
822            }
823    
824            private static DLStore _store;
825    
826    }