%bcond_without  portlet
Name:                apache-commons-fileupload
Version:             1.4
Release:             2
Summary:             API to work with HTML file upload
License:             ASL 2.0
URL:                 http://commons.apache.org/fileupload/
BuildArch:           noarch
Source0:             http://archive.apache.org/dist/commons/fileupload/source/commons-fileupload-%{version}-src.tar.gz

Patch0:	   	     CVE-2023-24998.patch
BuildRequires:       maven-local mvn(commons-io:commons-io) mvn(javax.servlet:servlet-api)
BuildRequires:       mvn(junit:junit) mvn(org.apache.commons:commons-parent:pom:)
%if %{with portlet}
BuildRequires:       mvn(javax.portlet:portlet-api)
%endif
%description
The javax.servlet package lacks support for RFC-1867, HTML file
upload.  This package provides a simple to use API for working with
such data.  The scope of this package is to create a package of Java
utility classes to read multipart/form-data within a
javax.servlet.http.HttpServletRequest.

%package help
Summary:             API documentation for %{name}
Provides:            %{name}-javadoc = %{version}-%{release}
Obsoletes:           %{name}-javadoc < %{version}-%{release}

%description help
This package contains the API documentation for %{name}.

%prep
%setup -q -n commons-fileupload-%{version}-src
%patch0 -p1
sed -i 's/\r//' LICENSE.txt
sed -i 's/\r//' NOTICE.txt
%if %{with portlet}
sed -i "s|<groupId>portlet-api</groupId>|<groupId>javax.portlet</groupId>|" pom.xml
%else
%pom_remove_dep portlet-api:portlet-api
%pom_xpath_remove pom:properties/pom:commons.osgi.import
%pom_xpath_remove pom:properties/pom:commons.osgi.dynamicImport
rm -r src/main/java/org/apache/commons/fileupload/portlet
%endif
%mvn_file ":{*}" @1 %{name}
%mvn_alias : org.apache.commons:

%build
%mvn_build -f -- -Dcommons.osgi.symbolicName=org.apache.commons.fileupload

%install
%mvn_install

%files -f .mfiles
%license LICENSE.txt NOTICE.txt

%files help -f .mfiles-javadoc
%license LICENSE.txt NOTICE.txt

%changelog
* Mon Mar 06 2023 liyuxiang<liyuxiang@ncti-gba.cn> - 1.4-2
- fix CVE-2023-24998

* Tue Aug 4 2020 yanan li <liyanan032@huawei.com> - 1.4-1
- Package init
