001/* 002 * (C) Copyright 2007-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 * Anahide Tchertchian 018 * Florent Guillaume 019 */ 020package org.nuxeo.ecm.platform.ui.web.component.file; 021 022/** 023 * Available choice when uploading a file. 024 */ 025public class InputFileChoice { 026 027 /** 028 * No file exists currently and no new one is added. 029 */ 030 public static final String NONE = "none"; 031 032 /** 033 * A file exists and is kept. 034 */ 035 public static final String KEEP = "keep"; 036 037 /** 038 * A file has been uploaded but there was a validation error in another field. 039 */ 040 public static final String KEEP_TEMP = "tempKeep"; 041 042 /** 043 * A file has been uploaded. 044 * <p> 045 * Also used as a prefix for all custom upload modes. 046 */ 047 public static final String UPLOAD = "upload"; 048 049 /** 050 * A file exists and should be deleted. 051 */ 052 public static final String DELETE = "delete"; 053 054 private InputFileChoice() { 055 // utility class 056 } 057 058 public static boolean isKeepOrKeepTemp(String choice) { 059 return KEEP_TEMP.equals(choice) || KEEP.equals(choice); 060 } 061 062 public static boolean isUploadOrKeepTemp(String choice) { 063 return KEEP_TEMP.equals(choice) || isUpload(choice); 064 } 065 066 public static boolean isUpload(String choice) { 067 return UPLOAD.equals(choice) || choice.startsWith(UPLOAD); 068 } 069 070}