001/*
002 * (C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Florent Guillaume
018 */
019package org.nuxeo.ecm.platform.ui.web.component.file;
020
021import java.io.IOException;
022
023import javax.faces.component.UIInput;
024import javax.faces.context.FacesContext;
025
026/**
027 * Interface for a Blob Uploader, a JSF helper that knows how to encode and validate a component to provide blob input
028 * in the JSF UI.
029 *
030 * @since 7.2
031 */
032public interface JSFBlobUploader {
033
034    /**
035     * Gets the choice key associated to this uploader. This MUST start with "upload" for the display logic to work
036     * correctly.
037     */
038    String getChoice();
039
040    /**
041     * Constructs the needed subcomponent.
042     */
043    void hookSubComponent(UIInput parent);
044
045    /**
046     * Generates the HTML for an upload choice.
047     */
048    void encodeBeginUpload(UIInput parent, FacesContext context, String onClick) throws IOException;
049
050    /**
051     * Transforms input into a blob.
052     *
053     * @param submitted the value into which the input is stored
054     */
055    void validateUpload(UIInput parent, FacesContext context, InputFileInfo submitted);
056
057    /**
058     * Checks if the uploader is enabled. Only enabled uploaders are added to the UI.
059     *
060     * @since 7.4
061     */
062    boolean isEnabled();
063
064}