001/* 002 * (C) Copyright 2007-2015 Nuxeo SAS (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl-2.1.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Anahide Tchertchian 016 * Florent Guillaume 017 */ 018package org.nuxeo.ecm.platform.ui.web.component.file; 019 020/** 021 * Available choice when uploading a file. 022 */ 023public class InputFileChoice { 024 025 /** 026 * No file exists currently and no new one is added. 027 */ 028 public static final String NONE = "none"; 029 030 /** 031 * A file exists and is kept. 032 */ 033 public static final String KEEP = "keep"; 034 035 /** 036 * A file has been uploaded but there was a validation error in another field. 037 */ 038 public static final String KEEP_TEMP = "tempKeep"; 039 040 /** 041 * A file has been uploaded. 042 * <p> 043 * Also used as a prefix for all custom upload modes. 044 */ 045 public static final String UPLOAD = "upload"; 046 047 /** 048 * A file exists and should be deleted. 049 */ 050 public static final String DELETE = "delete"; 051 052 private InputFileChoice() { 053 // utility class 054 } 055 056 public static boolean isKeepOrKeepTemp(String choice) { 057 return KEEP_TEMP.equals(choice) || KEEP.equals(choice); 058 } 059 060 public static boolean isUploadOrKeepTemp(String choice) { 061 return KEEP_TEMP.equals(choice) || isUpload(choice); 062 } 063 064 public static boolean isUpload(String choice) { 065 return UPLOAD.equals(choice) || choice.startsWith(UPLOAD); 066 } 067 068}