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