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

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

Introduction

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

Prototype

public NoSuchImageException() 

Source Link

Usage

From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

protected void validateReferences(long groupId, String ddmStructureKey, String ddmTemplateKey,
        String layoutUuid, boolean smallImage, String smallImageURL, byte[] smallImageBytes, long smallImageId,
        String content) throws PortalException {

    long classNameId = classNameLocalService.getClassNameId(JournalArticle.class.getName());

    if (Validator.isNotNull(ddmStructureKey)) {
        DDMStructure ddmStructure = ddmStructureLocalService.fetchStructure(groupId, classNameId,
                ddmStructureKey, true);/*  w  w  w.  j ava  2  s  .c  om*/

        if (ddmStructure == null) {
            throw new NoSuchStructureException();
        }
    }

    classNameId = classNameLocalService.getClassNameId(DDMStructure.class.getName());

    if (Validator.isNotNull(ddmTemplateKey)) {
        DDMTemplate ddmTemplate = ddmTemplateLocalService.fetchTemplate(groupId, classNameId, ddmTemplateKey,
                true);

        if (ddmTemplate == null) {
            throw new NoSuchTemplateException();
        }
    }

    if (Validator.isNotNull(layoutUuid)) {
        Layout layout = JournalUtil.getArticleLayout(layoutUuid, groupId);

        if (layout == null) {
            throw new NoSuchLayoutException(JournalArticleConstants.DISPLAY_PAGE);
        }
    }

    if (smallImage && Validator.isNull(smallImageURL) && ArrayUtil.isEmpty(smallImageBytes)) {

        Image image = imageLocalService.fetchImage(smallImageId);

        if (image == null) {
            throw new NoSuchImageException();
        }
    }

    ExportImportContentProcessor exportImportContentProcessor = ExportImportContentProcessorRegistryUtil
            .getExportImportContentProcessor(JournalArticle.class.getName());

    exportImportContentProcessor.validateContentReferences(groupId, content);
}

From source file:com.liferay.sync.internal.servlet.SyncDownloadServlet.java

License:Open Source License

protected void sendImage(HttpServletRequest request, HttpServletResponse response, long imageId)
        throws Exception {

    User user = _userLocalService.fetchUser(imageId);

    if (user != null) {
        imageId = user.getPortraitId();//from ww  w  . j av  a2 s. c om
    }

    Image image = _imageLocalService.fetchImage(imageId);

    if (image == null) {
        _portal.sendError(HttpServletResponse.SC_NOT_FOUND, new NoSuchImageException(), request, response);

        return;
    }

    String type = image.getType();

    if (!type.equals(ImageConstants.TYPE_NOT_AVAILABLE)) {
        String contentType = MimeTypesUtil.getExtensionContentType(type);

        response.setContentType(contentType);
    }

    ServletResponseUtil.write(response, image.getTextObj());
}