View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17  package org.apache.commons.fileupload2.core;
    18
    19  /**
    20   * Signals that a file size exceeds the configured maximum.
    21   */
    22  public class FileUploadByteCountLimitException extends FileUploadSizeException {
    23
    24      /**
    25       * The exceptions UID, for serializing an instance.
    26       */
    27      private static final long serialVersionUID = 2;
    28
    29      /**
    30       * File name of the item, which caused the exception.
    31       */
    32      private final String fileName;
    33
    34      /**
    35       * Field name of the item, which caused the exception.
    36       */
    37      private final String fieldName;
    38
    39      /**
    40       * Constructs an instance with the specified detail message, and actual and permitted sizes.
    41       *
    42       * @param message   The detail message (which is saved for later retrieval by the {@link #getMessage()} method)
    43       * @param actual    The actual request size.
    44       * @param permitted The maximum permitted request size.
    45       * @param fileName  File name of the item, which caused the exception.
    46       * @param fieldName Field name of the item, which caused the exception.
    47       */
    48      public FileUploadByteCountLimitException(final String message, final long actual, final long permitted, final String fileName, final String fieldName) {
    49          super(message, permitted, actual);
    50          this.fileName = fileName;
    51          this.fieldName = fieldName;
    52      }
    53
    54      /**
    55       * Gets the field name of the item, which caused the exception.
    56       *
    57       * @return Field name, if known, or null.
    58       */
    59      public String getFieldName() {
    60          return fieldName;
    61      }
    62
    63      /**
    64       * Gets the file name of the item, which caused the exception.
    65       *
    66       * @return File name, if known, or null.
    67       */
    68      public String getFileName() {
    69          return fileName;
    70      }
    71
    72  }