Name:                jets3t
Version:             0.9.3
Release:             1
Summary:             Java interface to Amazon S3 and CloudFront services
License:             ASL 2.0 and BSD and LGPLv2+
Url:                 http://jets3t.s3.amazonaws.com/index.html
Source0:             https://github.com/iterate-ch/jets3t/archive/Release-0.9.3.tar.gz
Source5:             http://www.zhangsheng.org/magic/3.0/sources/SOURCES.j/jets3t/jets3t-cockpit.pod
Source6:             http://www.zhangsheng.org/magic/3.0/sources/SOURCES.j/jets3t/jets3t-cockpitlite.pod
Source7:             http://www.zhangsheng.org/magic/3.0/sources/SOURCES.j/jets3t/jets3t-synchronize.pod
Source8:             http://www.zhangsheng.org/magic/3.0/sources/SOURCES.j/jets3t/jets3t-uploader.pod
Patch0:              jets3t-0.9.3-scripts.patch
Patch1:              jets3t-0.9.0-nuvola-fsf-address.patch
Patch2:              jets3t-0.9.3-dist-build.patch
BuildRequires:       ant apache-commons-codec apache-commons-logging BareBonesBrowserLaunch
BuildRequires:       bouncycastle dos2unix httpcomponents-client httpcomponents-core jackson
BuildRequires:       java-base64 java-xmlbuilder javamail junit log4j12 maven-local mx4j
BuildRequires:       %{_bindir}/pod2man sonatype-oss-parent glassfish-servlet-api
BuildArch:           noarch
%description
The JetS3t toolkit provides Java programmers with an API for interacting and
managing data stored in Amazon Simple Storage Service and Amazon CloudFront
content delivery network.

%package app
Summary:             Graphical and command-line tools for Amazon S3 and CloudFront
Requires:            jets3t = %{version}-%{release} apache-commons-codec apache-commons-logging
Requires:            avalon-framework avalon-logkit BareBonesBrowserLaunch base64 bouncycastle
Requires:            geronimo-jms glassfish-servlet-api httpcomponents-client httpcomponents-core
Requires:            java java-xmlbuilder jpackage-utils log4j12
%description app
The JetS3t toolkit provides Java programmers with an API for interacting and
managing data stored in Amazon Simple Storage Service and Amazon CloudFront
content delivery network.
Features:
- jets3t-cockpitlite: A graphical application that Service Providers with S3
  accounts may provide to clients or customers without S3 accounts.
  jets3t-cockpitlite allows users to manage the content of an S3 account to
  upload files, download files, delete S3 objects and make objects publicly
  accessible. All these operations are mediated by a Gatekeeper service.
- jets3t-cockpit: graphical application for transferring files, viewing and
  managing the contents of an Amazon S3 account.
- jets3t-synchronize: A command-line application for synchronizing
  directories on your computer with an Amazon S3 account. Ideal for
  performing back-ups or synchronizing files between different computers.
- jets3t-uploader: A graphical application that Service Providers with S3
  accounts may provide to clients or customers without S3 accounts.
  jets3t-uploader allows users to upload files to S3 using a simple
  wizard-based work-flow, but all uploads must first be authorized by a
  Gatekeeper service
- gatekeeper: A servlet that acts as an authorization service running on a
  Service Provider's server to mediate access to S3 accounts.
  It processes requests from client applications such as JetS3t Uploader &
  CockpitLite, and authorizes the client application to perform operations
  such as uploads, downloads and deletes.

%package javadoc
Summary:             Javadoc for jets3t
%description javadoc
This package contains javadoc for jets3t.

%prep
%setup -q -n jets3t-Release-0.9.3
dos2unix dist-build.xml
%patch0 -p1
sed -i "s|log4j.jar|log4j12-1.2.17.jar|" dist-build.xml
%patch1 -p0
%patch2 -p0
rm -rf src/contribs/com/centerkey/utils/BareBonesBrowserLaunch.java
sed -i "s|contribs.com.centerkey.utils.BareBonesBrowserLaunch|com.centerkey.utils.BareBonesBrowserLaunch|" \
 src/org/jets3t/apps/cockpit/Cockpit.java \
 src/org/jets3t/apps/cockpit/gui/StartupDialog.java \
 src/org/jets3t/apps/cockpitlite/CockpitLite.java \
 src/org/jets3t/apps/uploader/Uploader.java \
 src/org/jets3t/apps/cockpit/Cockpit.java \
 src/org/jets3t/apps/cockpit/gui/StartupDialog.java \
 src/org/jets3t/apps/cockpitlite/CockpitLite.java \
 src/org/jets3t/apps/uploader/Uploader.java
find . -name "*.war" -delete
for s in test/org/jets3t/service/BaseStorageServiceTests.java;do
  native2ascii -encoding UTF8 ${s} ${s}
done
sed -i 's/\r//' LICENSE-2.0.txt NOTICE.txt resources/images/nuvola/license.txt
cp -p %{SOURCE5} .
cp -p %{SOURCE6} .
cp -p %{SOURCE7} .
cp -p %{SOURCE8} .
%pom_remove_plugin org.apache.maven.plugins:maven-jarsigner-plugin
%pom_remove_plugin org.apache.maven.plugins:maven-source-plugin
%pom_remove_plugin org.codehaus.mojo:appassembler-maven-plugin
%pom_remove_plugin org.codehaus.mojo:sonar-maven-plugin
%pom_remove_plugin org.apache.maven.plugins:maven-javadoc-plugin
%pom_remove_dep javax.activation:activation
%pom_add_dep com.centerkey.utils:BareBonesBrowserLaunch:3.1
%mvn_alias net.java.dev.jets3t:jets3t ":cockpit"
%mvn_alias net.java.dev.jets3t:jets3t ":cockpitlite"
%mvn_alias net.java.dev.jets3t:jets3t ":jets3t-gui"
%mvn_alias net.java.dev.jets3t:jets3t ":synchronize"
%mvn_alias net.java.dev.jets3t:jets3t ":uploader"

%build
%mvn_build -f
ant -f dist-build.xml -Ddir.servlets=$PWD/servlet rebuild-gatekeeper
for m in cockpitlite cockpit synchronize uploader; do
  %{_bindir}/pod2man -c '' -r '' jets3t-${m}.pod > jets3t-${m}.1 ;
done

%install
%mvn_install
mkdir -p %{buildroot}%{_datadir}/jets3t/jars
(
  cd %{buildroot}%{_javadir}
  ln -sf ../../java/jets3t/jets3t.jar %{buildroot}%{_datadir}/jets3t/jars/jets3t-%{version}.jar
  ln -sf ../../java/jets3t/jets3t.jar %{buildroot}%{_datadir}/jets3t/jars/jets3t-gui-%{version}.jar
)
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_datadir}/jets3t/bin
for TOOL in cockpit cockpitlite synchronize uploader
do
  install -pm 755 scripts/$TOOL.sh %{buildroot}%{_bindir}/jets3t-$TOOL
  ln -sf ../../../bin/jets3t-$TOOL %{buildroot}%{_datadir}/jets3t/bin/$TOOL.sh
(
  cd %{buildroot}%{_javadir}
  ln -sf ../../java/jets3t/jets3t.jar %{buildroot}%{_datadir}/jets3t/jars/jets3t-$TOOL-%{version}.jar
)
done
chmod 0755  %{buildroot}%{_datadir}/jets3t/bin/*
mkdir -p %{buildroot}%{_mandir}/man1
install -pm 644 jets3t-*.1 %{buildroot}%{_mandir}/man1/
mkdir -p %{buildroot}%{_sysconfdir}/jets3t %{buildroot}%{_datadir}/jets3t/configs
sed -i "s|{jets3t-version}|%{version}|" configs/cockpitlite.properties
cp -pr configs/* %{buildroot}%{_sysconfdir}/jets3t/
ln  -sf ../../../../etc/jets3t/cockpitlite.properties %{buildroot}%{_datadir}/jets3t/configs/
ln  -sf ../../../../etc/jets3t/commons-logging.properties %{buildroot}%{_datadir}/jets3t/configs/
ln  -sf ../../../../etc/jets3t/devpay_products.properties %{buildroot}%{_datadir}/jets3t/configs/
ln  -sf ../../../../etc/jets3t/jets3t.properties %{buildroot}%{_datadir}/jets3t/configs/
ln  -sf ../../../../etc/jets3t/log4j.properties %{buildroot}%{_datadir}/jets3t/configs/
ln  -sf ../../../../etc/jets3t/mime.types %{buildroot}%{_datadir}/jets3t/configs/
ln  -sf ../../../../etc/jets3t/simplelog.properties %{buildroot}%{_datadir}/jets3t/configs/
ln  -sf ../../../../etc/jets3t/synchronize.properties %{buildroot}%{_datadir}/jets3t/configs/
ln  -sf ../../../../etc/jets3t/test.properties %{buildroot}%{_datadir}/jets3t/configs/
ln  -sf ../../../../etc/jets3t/uploader.properties %{buildroot}%{_datadir}/jets3t/configs/
mkdir -p %{buildroot}%{_datadir}/jets3t/resources
cp -pr resources/* %{buildroot}%{_datadir}/jets3t/resources/
cp -pr servlets %{buildroot}%{_datadir}/jets3t/

%files -f .mfiles
%dir %{_javadir}/jets3t
%doc README.markdown RELEASE_NOTES.markdown
%license LICENSE-2.0.txt NOTICE.txt

%files app
%dir %{_sysconfdir}/jets3t
%config(noreplace) %{_sysconfdir}/jets3t/*
%{_bindir}/jets3t-*
%dir %{_datadir}/jets3t
%dir %{_datadir}/jets3t/bin
%dir %{_datadir}/jets3t/configs
%dir %{_datadir}/jets3t/jars
%dir %{_datadir}/jets3t/resources
%dir %{_datadir}/jets3t/servlets
%{_datadir}/jets3t/jars/*
%{_datadir}/jets3t/bin/*
%{_datadir}/jets3t/configs/*
%{_datadir}/jets3t/resources/*
%{_datadir}/jets3t/servlets/*
%{_mandir}/man1/*
%license LICENSE-2.0.txt NOTICE.txt

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

%changelog
* Fri Aug 21 2020 yaokai <yaokai13@huawei.com> - 0.9.3-1
- package init
