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