| /* |
| * |
| * Copyright (c) 2011 - 2017 - Loetz GmbH & Co KG, 69115 Heidelberg, Germany |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Initial contribution: |
| * Loetz GmbH & Co. KG |
| * |
| */ |
| package org.eclipse.osbp.ui.api.customfields; |
| |
| import java.awt.image.BufferedImage; |
| import java.io.IOException; |
| import java.io.InputStream; |
| import java.util.List; |
| |
| import com.vaadin.server.StreamResource; |
| |
| public interface IBlobService { |
| |
| /** |
| * Adds the blob upload listener. |
| * |
| * @param listener the listener |
| */ |
| void addBlobUploadListener(IBlobUploadEventListener listener); |
| |
| /** |
| * Removes the blob upload listener. |
| * |
| * @param listener the listener |
| */ |
| void removeBlobUploadListener(IBlobUploadEventListener listener); |
| /** |
| * Creates for the specified image blob data by {@link InputStream} the |
| * base64 encoded image representation and a resized copy for each of the |
| * predefined resolutions and persist them in to database via JPA. |
| * |
| * If no blob uuid exists ({@code uploadedBlobUuid = null}, when a new image |
| * is uploaded, a new entry with a new uuid is created. |
| * |
| * Once the persistence of the blob data is successfully realized a positive |
| * {@link BlobEvent} (with the flag {@code uploadSuccessful = true}) |
| * is created and all the {@link IBlobUploadEventListener} are notified. |
| * |
| * But if the persistence of the blob data goes unsuccessful a negative |
| * {@link BlobEvent} (with the flag {@code uploadSuccessful = false} |
| * and a filled {@code errorMessage} is created and all the |
| * {@link IBlobUploadEventListener} are notified. |
| * |
| * @param stream the stream |
| * @param mimeType the mime type |
| * @return the list |
| * @throws IOException Signals that an I/O exception has occurred. |
| */ |
| List<Object> createBlobMappingBlobs(InputStream stream, int mimeType) throws IOException; |
| /** |
| * Creates for the specified image blob data by {@link InputStream} the |
| * base64 encoded image representation and a resized copy for each of the |
| * predefined resolutions and persist them in to database via JPA. |
| * |
| * If no blob uuid exists ({@code uploadedBlobUuid = null}, when a new image |
| * is uploaded, a new entry with a new uuid is created. |
| * |
| * Once the persistence of the blob data is successfully realized a positive |
| * {@link BlobEvent} (with the flag {@code uploadSuccessful = true}) |
| * is created and all the {@link IBlobUploadEventListener} are notified. |
| * |
| * But if the persistence of the blob data goes unsuccessful a negative |
| * {@link BlobEvent} (with the flag {@code uploadSuccessful = false} |
| * and a filled {@code errorMessage} is created and all the |
| * {@link IBlobUploadEventListener} are notified. |
| * |
| * @param stream the stream |
| * @param mimeType the mime type |
| * @return the list |
| * @throws IOException Signals that an I/O exception has occurred. |
| */ |
| List<Object> createBlobMappingBlobs(InputStream stream, String mimeType) throws IOException; |
| /** |
| * Creates for the specified image blob data by;@link InputStream} the |
| * base64 encoded image representation and a resized copy for each of the |
| * predefined resolutions and persist them in to database via JPA. |
| * |
| * Returns the UUID of the created blob mapping created. |
| * |
| * If the persistence of the blob data fail, returns null. |
| * |
| * @param stream |
| * @param fileName |
| * @param mimeType |
| * @param blobAPI |
| */ |
| String createBlobMapping(InputStream stream, String fileName, String mimeType); |
| /** |
| * Checks if the mime type by the specified mime type id;@code mimeTypeId} |
| * corresponds to an image. |
| * |
| * @param mimeTypeId |
| * @return boolean indicating if it is an image |
| */ |
| boolean isImage(int mimeTypeId); |
| /** |
| * Checks if the mime type by the specified mime type id;@code mimeTypeId} |
| * corresponds to a pdf file. |
| * |
| * @param mimeTypeId |
| * @return boolean indicating if it is a pdf file |
| */ |
| boolean isPdf(int mimeTypeId); |
| /** |
| * Checks if the mime type by the specified mime type id;@code mimeTypeId} |
| * corresponds to a word file. |
| * |
| * @param mimeTypeId |
| * @return boolean indicating if it is a word file |
| */ |
| boolean isWord(int mimeTypeId); |
| /** |
| * Checks if the mime type by the specified mime type id;@code mimeTypeId} |
| * corresponds to a excel file. |
| * |
| * @param mimeTypeId |
| * @return boolean indicating if it is a excel file |
| */ |
| boolean isExcel(int mimeTypeId); |
| /** |
| * Checks if the mime type corresponds to an image. |
| * |
| * @param mimeTypeId |
| * @return boolean indicating if it is an image |
| */ |
| boolean isImage(String mimeType); |
| |
| /** |
| * Creates a base64 {@link String} as the representation of a specific blob |
| * in a specific resolution. |
| * |
| * In case of an image mime type it is the base 64 encoded string of the |
| * image and otherwise a defined image for each mime type representing them. |
| * |
| * @param uuid the uuid |
| * @param resolutionId the resolution id |
| * @return the image |
| */ |
| String getImage(String uuid, int resolutionId); |
| /** |
| * Creates a {@link StreamResource} as the representation of a specific blob |
| * in a specific resolution. |
| * |
| * In case of an image mime type it is the base 64 encoded string of the |
| * image and otherwise a defined image for each mime type representing them. |
| * |
| * @param uuid the uuid |
| * @param resolutionId the resolution id |
| * @return the StreamResource |
| */ |
| StreamResource getResource(String uuid, int resolutionId); |
| |
| /** |
| * Gets the normalizer resolution id by name. |
| * |
| * @param displayResolution the display resolution |
| * @return the normalizer resolution id by name |
| */ |
| int getNormalizerResolutionIdByName(String displayResolution); |
| |
| /** |
| * Gets the buffered image from blob. |
| * |
| * @param uuid the uuid |
| * @param resolutionId the resolution id |
| * @return the buffered image |
| */ |
| BufferedImage getBufferedImage(String uuid, int resolutionId); |
| |
| /** |
| * Gets the image birt compatible. |
| * |
| * @param uuid the uuid |
| * @param resolutionId the resolution id |
| * @return the birt image |
| */ |
| String getBirtImage(String uuid, int resolutionId); |
| |
| /** |
| * Gets the byte array image. |
| * |
| * @param uuid the uuid |
| * @param resolutionId the resolution id |
| * @return the byte array image |
| */ |
| byte[] getByteArrayImage(String uuid, int resolutionId); |
| |
| /** |
| * Gets the base 64 image. |
| * |
| * @param uuid the uuid |
| * @param resolutionId the resolution id |
| * @return the base 64 image |
| */ |
| String getBase64Image(String uuid, int resolutionId); |
| |
| /** |
| * Gets the buffered image by name. |
| * |
| * @param name the name |
| * @param resolutionId the resolution id |
| * @param mimeType the mime type |
| * @return the buffered image by name |
| */ |
| BufferedImage getBufferedImageByName(String name, int resolutionId, String mimeType); |
| |
| /** |
| * Gets the base 64 image by name. |
| * |
| * @param name the name |
| * @param resolutionId the resolution id |
| * @param mimeType the mime type |
| * @return the base 64 image by name |
| */ |
| String getBase64ImageByName(String name, int resolutionId, String mimeType); |
| |
| } |