Example usage for com.liferay.portal.kernel.model ImageConstants TYPE_NOT_AVAILABLE

List of usage examples for com.liferay.portal.kernel.model ImageConstants TYPE_NOT_AVAILABLE

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.model ImageConstants TYPE_NOT_AVAILABLE.

Prototype

String TYPE_NOT_AVAILABLE

To view the source code for com.liferay.portal.kernel.model ImageConstants TYPE_NOT_AVAILABLE.

Click Source Link

Usage

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  w w w  . j  av a2s  .c  o  m
    }

    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());
}