@Override public void delete() throws IOException { wrappedUploadedFile.delete(); }
@Override public String getContentType() { return wrappedUploadedFile.getContentType(); }
@Override public String getName() { return wrappedUploadedFile.getName(); }
@Override protected void validateValue(FacesContext facesContext, Object value) { super.validateValue(facesContext, value); if (isValid()) { Long maxFileSize = getMaxFileSize(); String contentTypeSet = getContentTypes(); if ((maxFileSize != null) || (contentTypeSet != null)) { Locale locale = facesContext.getViewRoot().getLocale(); ExternalContext externalContext = facesContext.getExternalContext(); I18n i18n = I18nFactory.getI18nInstance(externalContext); String clientId = getClientId(facesContext); @SuppressWarnings("unchecked") List<UploadedFile> uploadedFiles = (List<UploadedFile>) value; for (UploadedFile uploadedFile : uploadedFiles) { if ((maxFileSize != null) && (maxFileSize >= 0) && (uploadedFile.getSize() > maxFileSize)) { String errorMessage = i18n.getMessage(facesContext, locale, "file-x-is-y-bytes-but-may-not-exceed-z-bytes", uploadedFile.getName(), uploadedFile.getSize(), maxFileSize); handleInvalidFile(facesContext, clientId, uploadedFile, errorMessage); } String contentType = uploadedFile.getContentType(); if ((contentType == null) || ((contentTypeSet != null) && !contentTypeSet.contains(contentType))) { String errorMessage = i18n.getMessage(facesContext, locale, "file-x-has-an-invalid-content-type-y", uploadedFile.getName(), contentType); handleInvalidFile(facesContext, clientId, uploadedFile, errorMessage); } } } } }
File file = new File(uploadedFile.getAbsolutePath()); file.delete(); return uploadedFile.getContentType(); return new FileInputStream(uploadedFile.getAbsolutePath()); return uploadedFile.getName(); return uploadedFile.getSize();
@Override public long getSize() { return wrappedUploadedFile.getSize(); }
@Override public String getAbsolutePath() { return wrappedUploadedFile.getAbsolutePath(); }
@Override public Collection<String> getHeaderNames() { return wrappedUploadedFile.getHeaderNames(); }
@Override public String getHeader(String name) { return wrappedUploadedFile.getHeader(name); }
@Override public String getCharSet() { return wrappedUploadedFile.getCharSet(); }
@Override public Map<String, Object> getAttributes() { return wrappedUploadedFile.getAttributes(); }
@Override public byte[] getBytes() throws IOException { return wrappedUploadedFile.getBytes(); }
@Override protected void validateValue(FacesContext facesContext, Object value) { setValid(true); Long maxFileSize = getMaxFileSize(); String contentTypeSet = getContentTypes(); if ((maxFileSize != null) || (contentTypeSet != null)) { Locale locale = facesContext.getViewRoot().getLocale(); MessageContextFactory messageContextFactory = (MessageContextFactory) FactoryExtensionFinder.getFactory( MessageContextFactory.class); MessageContext messageContext = messageContextFactory.getMessageContext(); String clientId = getClientId(facesContext); @SuppressWarnings("unchecked") List<UploadedFile> uploadedFiles = (List<UploadedFile>) value; for (UploadedFile uploadedFile : uploadedFiles) { if ((maxFileSize != null) && (maxFileSize >= 0) && (uploadedFile.getSize() > maxFileSize)) { String errorMessage = messageContext.getMessage(locale, "file-x-is-y-bytes-but-may-not-exceed-z-bytes", uploadedFile.getName(), uploadedFile.getSize(), maxFileSize); handleInvalidFile(facesContext, clientId, uploadedFile, errorMessage); } String contentType = uploadedFile.getContentType(); if ((contentType == null) || ((contentTypeSet != null) && !contentTypeSet.contains(contentType))) { String errorMessage = messageContext.getMessage(locale, "file-x-has-an-invalid-content-type-y", uploadedFile.getName(), contentType); handleInvalidFile(facesContext, clientId, uploadedFile, errorMessage); } } } }
File file = new File(uploadedFile.getAbsolutePath()); file.delete(); return uploadedFile.getContentType(); return new FileInputStream(uploadedFile.getAbsolutePath()); return uploadedFile.getName(); return uploadedFile.getSize();
@Override public long getSize() { return wrappedUploadedFile.getSize(); }
@Override public String getAbsolutePath() { return wrappedUploadedFile.getAbsolutePath(); }
@Override public Collection<String> getHeaderNames() { return wrappedUploadedFile.getHeaderNames(); }
@Override public String getHeader(String name) { return wrappedUploadedFile.getHeader(name); }
@Override public String getCharSet() { return wrappedUploadedFile.getCharSet(); }
@Override public Map<String, Object> getAttributes() { return wrappedUploadedFile.getAttributes(); }