Пример #1
0
  /** @see Form#onFileUploadException(FileUploadException, Map) */
  @Override
  protected void onFileUploadException(FileUploadException e, Map<String, Object> model) {
    if (e instanceof SizeLimitExceededException) {
      final String msg =
          "Only files up to  " + bytesToString(getMaxSize(), Locale.US) + " can be uploaded.";
      error(msg);
    } else {
      final String msg = "Error uploading the file: " + e.getLocalizedMessage();
      error(msg);

      log.warn(msg, e);
    }
  }
Пример #2
0
  /**
   * Create an I/O advisor for the given content type.
   *
   * @param contentType the content type, may be <code>null</code>
   * @return the resource advisor for that content type or a default resource advisor
   */
  public ResourceAdvisor getAdvisor(IContentType contentType) {
    if (contentType == null) {
      return DEFAULT;
    }

    boolean error = false;
    for (ResourceAdvisorDescriptor factory : getFactories()) {
      if (factory.getAssociatedTypes().contains(contentType)) {
        try {
          return factory.createExtensionObject();
        } catch (Exception e) {
          log.error("Could not create resource advisor " + factory.getIdentifier(), e);
          error = true;
        }
      }
    }

    if (error) {
      log.warn(
          "Using default resource advisor as fall-back for content type " + contentType.getName());
    }

    return DEFAULT;
  }