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.util;
016    
017    import com.liferay.portlet.documentlibrary.exception.FileExtensionException;
018    import com.liferay.portlet.documentlibrary.exception.FileNameException;
019    import com.liferay.portlet.documentlibrary.exception.FileSizeException;
020    import com.liferay.portlet.documentlibrary.exception.FolderNameException;
021    import com.liferay.portlet.documentlibrary.exception.InvalidFileVersionException;
022    import com.liferay.portlet.documentlibrary.exception.SourceFileNameException;
023    
024    import java.io.File;
025    import java.io.InputStream;
026    
027    /**
028     * @author Adolfo P??rez
029     */
030    public interface DLValidator {
031    
032            public String fixName(String name);
033    
034            public boolean isValidName(String name);
035    
036            public void validateDirectoryName(String directoryName)
037                    throws FolderNameException;
038    
039            public void validateFileExtension(String fileName)
040                    throws FileExtensionException;
041    
042            public void validateFileName(String fileName) throws FileNameException;
043    
044            public void validateFileSize(String fileName, byte[] bytes)
045                    throws FileSizeException;
046    
047            public void validateFileSize(String fileName, File file)
048                    throws FileSizeException;
049    
050            public void validateFileSize(String fileName, InputStream is)
051                    throws FileSizeException;
052    
053            public void validateFileSize(String fileName, long size)
054                    throws FileSizeException;
055    
056            public void validateSourceFileExtension(
057                            String fileExtension, String sourceFileName)
058                    throws SourceFileNameException;
059    
060            public void validateVersionLabel(String versionLabel)
061                    throws InvalidFileVersionException;
062    
063    }