Example usage for com.liferay.portal.kernel.exception ImageTypeException ImageTypeException

List of usage examples for com.liferay.portal.kernel.exception ImageTypeException ImageTypeException

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.exception ImageTypeException ImageTypeException.

Prototype

public ImageTypeException(Throwable cause) 

Source Link

Usage

From source file:com.liferay.journal.web.internal.upload.ImageJournalUploadFileEntryHandler.java

License:Open Source License

private void _validateFile(String fileName, long size) throws PortalException {

    _dlValidator.validateFileSize(fileName, size);

    String extension = FileUtil.getExtension(fileName);

    for (String imageExtension : _journalFileUploadsConfiguration.imageExtensions()) {

        if (StringPool.STAR.equals(imageExtension) || imageExtension.equals(StringPool.PERIOD + extension)) {

            return;
        }/*from  w w  w . java2 s . c  o m*/
    }

    throw new ImageTypeException("Invalid image type for file name " + fileName);
}

From source file:com.liferay.journal.web.internal.upload.ImageJournalUploadHandler.java

License:Open Source License

@Override
public void validateFile(String fileName, String contentType, long size) throws PortalException {

    _dlValidator.validateFileSize(fileName, size);

    String extension = FileUtil.getExtension(fileName);

    for (String imageExtension : _journalFileUploadsConfiguration.imageExtensions()) {

        if (StringPool.STAR.equals(imageExtension) || imageExtension.equals(StringPool.PERIOD + extension)) {

            return;
        }//from   w  ww  . j  a  va  2 s.c om
    }

    throw new ImageTypeException("Invalid image type for file name " + fileName);
}