feat: add download files

This commit is contained in:
Sergey Krylov 2026-02-23 15:14:36 +03:00
parent fd2f08e8bc
commit 03fedef553
49 changed files with 5743 additions and 139 deletions

View File

@ -0,0 +1,198 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# List of comma-separated paths defining the contents of the "common"
# classloader. Prefixes should be used to define what is the repository type.
# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute.
# If left as blank,the JVM system loader will be used as Catalina's "common"
# loader.
# Examples:
# "foo": Add this folder as a class repository
# "foo/*.jar": Add all the JARs of the specified folder as class
# repositories
# "foo/bar.jar": Add bar.jar as a class repository
#
# Note: Values are enclosed in double quotes ("...") in case either the
# ${catalina.base} path or the ${catalina.home} path contains a comma.
# Because double quotes are used for quoting, the double quote character
# may not appear in a path.
common.loader="${catalina.base}/lib","${catalina.base}/lib/*.jar","${catalina.home}/lib","${catalina.home}/lib/*.jar"
#
# List of comma-separated paths defining the contents of the "server"
# classloader. Prefixes should be used to define what is the repository type.
# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute.
# If left as blank, the "common" loader will be used as Catalina's "server"
# loader.
# Examples:
# "foo": Add this folder as a class repository
# "foo/*.jar": Add all the JARs of the specified folder as class
# repositories
# "foo/bar.jar": Add bar.jar as a class repository
#
# Note: Values may be enclosed in double quotes ("...") in case either the
# ${catalina.base} path or the ${catalina.home} path contains a comma.
# Because double quotes are used for quoting, the double quote character
# may not appear in a path.
server.loader=
#
# List of comma-separated paths defining the contents of the "shared"
# classloader. Prefixes should be used to define what is the repository type.
# Path may be relative to the CATALINA_BASE path or absolute. If left as blank,
# the "common" loader will be used as Catalina's "shared" loader.
# Examples:
# "foo": Add this folder as a class repository
# "foo/*.jar": Add all the JARs of the specified folder as class
# repositories
# "foo/bar.jar": Add bar.jar as a class repository
# Please note that for single jars, e.g. bar.jar, you need the URL form
# starting with file:.
#
# Note: Values may be enclosed in double quotes ("...") in case either the
# ${catalina.base} path or the ${catalina.home} path contains a comma.
# Because double quotes are used for quoting, the double quote character
# may not appear in a path.
shared.loader=
# Default list of JAR files that should not be scanned using the JarScanner
# functionality. This is typically used to scan JARs for configuration
# information. JARs that do not contain such information may be excluded from
# the scan to speed up the scanning process. This is the default list. JARs on
# this list are excluded from all scans. The list must be a comma separated list
# of JAR file names.
# The list of JARs to skip may be over-ridden at a Context level for individual
# scan types by configuring a JarScanner with a nested JarScanFilter.
# The JARs listed below include:
# - Tomcat Bootstrap JARs
# - Tomcat API JARs
# - Catalina JARs
# - Jasper JARs
# - Tomcat JARs
# - Common non-Tomcat JARs
# - Test JARs (JUnit, Cobertura and dependencies)
tomcat.util.scan.StandardJarScanFilter.jarsToSkip=\
annotations-api.jar,\
ant-junit*.jar,\
ant-launcher*.jar,\
ant*.jar,\
asm-*.jar,\
aspectj*.jar,\
bcel*.jar,\
biz.aQute.bnd*.jar,\
bootstrap.jar,\
catalina-ant.jar,\
catalina-ha.jar,\
catalina-ssi.jar,\
catalina-storeconfig.jar,\
catalina-tribes.jar,\
catalina.jar,\
cglib-*.jar,\
cobertura-*.jar,\
commons-beanutils*.jar,\
commons-codec*.jar,\
commons-collections*.jar,\
commons-compress*.jar,\
commons-daemon.jar,\
commons-dbcp*.jar,\
commons-digester*.jar,\
commons-fileupload*.jar,\
commons-httpclient*.jar,\
commons-io*.jar,\
commons-lang*.jar,\
commons-logging*.jar,\
commons-math*.jar,\
commons-pool*.jar,\
derby-*.jar,\
dom4j-*.jar,\
easymock-*.jar,\
ecj-*.jar,\
el-api.jar,\
geronimo-spec-jaxrpc*.jar,\
h2*.jar,\
ha-api-*.jar,\
hamcrest-*.jar,\
hibernate*.jar,\
httpclient*.jar,\
icu4j-*.jar,\
jakartaee-migration-*.jar,\
jasper-el.jar,\
jasper.jar,\
jaspic-api.jar,\
jaxb-*.jar,\
jaxen-*.jar,\
jaxws-rt-*.jar,\
jdom-*.jar,\
jetty-*.jar,\
jmx-tools.jar,\
jmx.jar,\
jsp-api.jar,\
jstl.jar,\
jta*.jar,\
junit-*.jar,\
junit.jar,\
log4j*.jar,\
mail*.jar,\
objenesis-*.jar,\
oraclepki.jar,\
org.hamcrest.core_*.jar,\
org.junit_*.jar,\
oro-*.jar,\
servlet-api-*.jar,\
servlet-api.jar,\
slf4j*.jar,\
taglibs-standard-spec-*.jar,\
tagsoup-*.jar,\
tomcat-api.jar,\
tomcat-coyote.jar,\
tomcat-coyote-ffm.jar,\
tomcat-dbcp.jar,\
tomcat-i18n-*.jar,\
tomcat-jdbc.jar,\
tomcat-jni.jar,\
tomcat-juli-adapters.jar,\
tomcat-juli.jar,\
tomcat-util-scan.jar,\
tomcat-util.jar,\
tomcat-websocket.jar,\
tools.jar,\
unboundid-ldapsdk-*.jar,\
websocket-api.jar,\
websocket-client-api.jar,\
wsdl4j*.jar,\
xercesImpl.jar,\
xml-apis.jar,\
xmlParserAPIs-*.jar,\
xmlParserAPIs.jar,\
xom-*.jar
# Default list of JAR files that should be scanned that overrides the default
# jarsToSkip list above. This is typically used to include a specific JAR that
# has been excluded by a broad file name pattern in the jarsToSkip list.
# The list of JARs to scan may be over-ridden at a Context level for individual
# scan types by configuring a JarScanner with a nested JarScanFilter.
tomcat.util.scan.StandardJarScanFilter.jarsToScan=\
log4j-taglib*.jar,\
log4j-jakarta-web*.jar,\
log4javascript*.jar,\
slf4j-taglib*.jar
# String cache configuration.
tomcat.util.buf.StringCache.byte.enabled=true
#tomcat.util.buf.StringCache.char.enabled=true
#tomcat.util.buf.StringCache.trainThreshold=500000
#tomcat.util.buf.StringCache.cacheSize=5000

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- The contents of this file will be loaded for each web application -->
<Context>
<!-- Default set of monitored resources. If one of these changes, the -->
<!-- web application will be reloaded. -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<!-- Uncomment this to enable session persistence across Tomcat restarts -->
<!--
<Manager pathname="SESSIONS.ser" />
-->
</Context>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<jaspic-providers xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml jaspic-providers.xsd"
version="1.0">
<!-- No JASPIC providers configured by default -->
</jaspic-providers>

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<xs:schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://tomcat.apache.org/xml"
xmlns:jaspic="http://tomcat.apache.org/xml"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
version="1.0">
<xs:element name="jaspic-providers">
<xs:complexType>
<xs:sequence>
<xs:element name="provider" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="property" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" use="required" type="jaspic:propertyname" />
<xs:attribute name="value" use="required" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="className" type="xs:string" />
<xs:attribute name="layer" type="xs:string" />
<xs:attribute name="appContext" type="xs:string" />
<xs:attribute name="description" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="version" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:simpleType name="propertyname">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

View File

@ -0,0 +1,76 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
handlers = 1catalina.org.apache.juli.AsyncFileHandler, 2localhost.org.apache.juli.AsyncFileHandler, 3manager.org.apache.juli.AsyncFileHandler, 4host-manager.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler
.handlers = 1catalina.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler
############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################
1catalina.org.apache.juli.AsyncFileHandler.level = ALL
1catalina.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.
1catalina.org.apache.juli.AsyncFileHandler.maxDays = 90
1catalina.org.apache.juli.AsyncFileHandler.encoding = UTF-8
2localhost.org.apache.juli.AsyncFileHandler.level = ALL
2localhost.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost.
2localhost.org.apache.juli.AsyncFileHandler.maxDays = 90
2localhost.org.apache.juli.AsyncFileHandler.encoding = UTF-8
3manager.org.apache.juli.AsyncFileHandler.level = ALL
3manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.AsyncFileHandler.prefix = manager.
3manager.org.apache.juli.AsyncFileHandler.maxDays = 90
3manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8
4host-manager.org.apache.juli.AsyncFileHandler.level = ALL
4host-manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
4host-manager.org.apache.juli.AsyncFileHandler.prefix = host-manager.
4host-manager.org.apache.juli.AsyncFileHandler.maxDays = 90
4host-manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8
java.util.logging.ConsoleHandler.level = ALL
java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter
java.util.logging.ConsoleHandler.encoding = UTF-8
############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.AsyncFileHandler
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.AsyncFileHandler
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.AsyncFileHandler
# For example, set the org.apache.catalina.util.LifecycleBase logger to log
# each component that extends LifecycleBase changing state:
#org.apache.catalina.util.LifecycleBase.level = FINE
# To see debug messages for HTTP/2 handling, uncomment the following line:
#org.apache.coyote.http2.level = FINE
# To see debug messages for WebSocket handling, uncomment the following line:
#org.apache.tomcat.websocket.level = FINE

View File

@ -0,0 +1,154 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<!-- Security listener. Documentation at /docs/config/listeners.html
<Listener className="org.apache.catalina.security.SecurityListener" />
-->
<!-- OpenSSL support using Tomcat Native -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" />
<!-- OpenSSL support using FFM API from Java 22 -->
<!-- <Listener className="org.apache.catalina.core.OpenSSLLifecycleListener" /> -->
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina">
<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="4"/>
-->
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
HTTP Connector: /docs/config/http.html
AJP Connector: /docs/config/ajp.html
Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2
This connector uses the NIO implementation. The default
SSLImplementation will depend on the presence of the APR/native
library and the useOpenSSL attribute of the AprLifecycleListener.
Either JSSE or OpenSSL style configuration may be used regardless of
the SSLImplementation selected. JSSE style configuration is used below.
-->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true">
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
<SSLHostConfig>
<Certificate certificateKeystoreFile="conf/localhost-rsa.jks"
certificateKeystorePassword="changeit" type="RSA" />
</SSLHostConfig>
</Connector>
-->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<!--
<Connector protocol="AJP/1.3"
address="::1"
port="8009"
redirectPort="8443" />
-->
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->
<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina" defaultHost="localhost">
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t &quot;%r&quot; %s %b" />
</Host>
</Engine>
</Service>
</Server>

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<tomcat-users xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
version="1.0">
<!--
By default, no user is included in the "manager-gui" role required
to operate the "/manager/html" web application. If you wish to use this app,
you must define such a user - the username and password are arbitrary.
Built-in Tomcat manager roles:
- manager-gui - allows access to the HTML GUI and the status pages
- manager-script - allows access to the HTTP API and the status pages
- manager-jmx - allows access to the JMX proxy and the status pages
- manager-status - allows access to the status pages only
The users below are wrapped in a comment and are therefore ignored. If you
wish to configure one or more of these users for use with the manager web
application, do not forget to remove the <!.. ..> that surrounds them. You
will also need to set the passwords to something appropriate.
-->
<!--
<user username="admin" password="<must-be-changed>" roles="manager-gui"/>
<user username="robot" password="<must-be-changed>" roles="manager-script"/>
-->
<!--
The sample user and role entries below are intended for use with the
examples web application. They are wrapped in a comment and thus are ignored
when reading this file. If you wish to configure these users for use with the
examples web application, do not forget to remove the <!.. ..> that surrounds
them. You will also need to set the passwords to something appropriate.
-->
<!--
<role rolename="tomcat"/>
<role rolename="role1"/>
<user username="tomcat" password="<must-be-changed>" roles="tomcat"/>
<user username="both" password="<must-be-changed>" roles="tomcat,role1"/>
<user username="role1" password="<must-be-changed>" roles="role1"/>
-->
</tomcat-users>

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<xs:schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://tomcat.apache.org/xml"
xmlns:users="http://tomcat.apache.org/xml"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
version="1.0">
<xs:element name="tomcat-users">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="role">
<xs:complexType>
<xs:attribute name="rolename" use="required" type="users:entityname" />
<xs:attribute name="description" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element name="group">
<xs:complexType>
<xs:attribute name="groupname" use="required" type="users:entityname" />
<xs:attribute name="description" type="xs:string" />
<xs:attribute name="roles" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element name="user">
<xs:complexType>
<xs:attribute name="username" use="required" type="users:entityname" />
<xs:attribute name="fullname" type="xs:string" />
<xs:attribute name="password" type="xs:string" />
<xs:attribute name="roles" type="xs:string" />
<xs:attribute name="groups" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:choice>
<xs:attribute name="version" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:simpleType name="entityname">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

@ -1,26 +1,54 @@
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="en">
<head>
<title>Charm Profiles</title>
<%@ include file="style.html" %>
</head>
<body>
<%@ include file="header.jsp" %>
<div>
<h3 style="color: red">${requestScope.wordBundle.getWord("email-warning")}</h3>
<form method="post" action="/email">
<input type="hidden" name="_method" value="put"/>
<input type="hidden" name="id" value="${requestScope.profile.id}">
<table>
<tr>
<td><h3>${requestScope.wordBundle.getWord("email")}</h3></td>
<td><input type="email" name="email" value="${requestScope.profile.email}"></td>
</tr>
</table>
<button type="submit">${requestScope.wordBundle.getWord("save")}</button>
</form>
</div>
<%@ include file="footer.jsp" %>
</body>
<head>
<title>Charm Email</title>
<%@ include file="style.html" %>
</head>
<body>
<%@ include file="header.jsp" %>
<div>
<h3 style="color: red">${wordBundle.getWord("email-warning")}</h3>
<table>
<tr class="hiddenRow">
<form method="post" action="/email?id=${profile.id}" enctype="multipart/form-data">
<input type="hidden" name="_method" value="put"/>
<input type="hidden" name="id" value="${profile.id}">
<table>
<tr>
<td><h3>${wordBundle.getWord("email")}</h3></td>
<td><input type="email" name="email" value="${profile.email}"></td>
</tr>
</table>
<table>
<tr class="hiddenRow">
<td>
<input type="image" src="content/app/img/floppy-disk.png" width="75" alt="submit"
class="icon"/>
</td>
</tr>
</table>
</form>
</tr>
<tr class="hiddenRow">
<div style="color: red">
<c:forEach var="error" items="${errors}">
<span>${wordBundle.getWord(error)}</span>
<br>
</c:forEach>
</div>
</tr>
<tr class="hiddenRow">
<form method="post" action="/registration">
<input type="hidden" name="_method" value="delete"/>
<input type="hidden" name="id" value="${profile.id}">
<input type="image" src="content/app/img/cross.png" width="75" alt="submit" class="icon"/>
</form>
</tr>
</table>
</div>
<%@ include file="footer.jsp" %>
</body>
</html>

View File

@ -1,59 +1,76 @@
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="en">
<head>
<title>Charm Profile</title>
<%@ include file="style.html" %>
</head>
<body>
<%@ include file="header.jsp" %>
<div>
<form method="post" action="/profile">
<input type="hidden" name="_method" value="put"/>
<input type="hidden" name="id" value="${requestScope.profile.id}">
<table>
<tr>
<td><h3>${requestScope.wordBundle.getWord("email")}</h3></td>
<td><a href="/email?id=${requestScope.profile.id}">${requestScope.profile.email}</a></td>
</tr>
<tr>
<td><h3>${requestScope.wordBundle.getWord("name")}</h3></td>
<td><input type="text" name="name" value="${requestScope.profile.name}"></td>
</tr>
<tr>
<td><h3>${requestScope.wordBundle.getWord("surname")}</h3></td>
<td><input type="text" name="surname" value="${requestScope.profile.surname}"></td>
</tr>
<tr>
<td><h3>${requestScope.wordBundle.getWord("birth-date")}</h3></td>
<td><input type="date" name="birthDate" value="${requestScope.profile.birthDate}"></td>
</tr>
<tr>
<td><h3>${requestScope.wordBundle.getWord("about")}</h3></td>
<td><input type="text" name="about" value="${requestScope.profile.about}"></td>
</tr>
<tr>
<td><h3>${requestScope.wordBundle.getWord("gender")}</h3></td>
<td>
<select name="gender">
<option value="${requestScope.profile.gender}" selected hidden>
${requestScope.wordBundle.getWord(requestScope.profile.gender)}
</option>
<c:forEach var="gender" items="${applicationScope.genders}">
<option value="${gender}">${requestScope.wordBundle.getWord(gender)}</option>
</c:forEach>
</select>
</td>
</tr>
</table>
<button type="submit">${requestScope.wordBundle.getWord("save")}</button>
</form>
<form method="post" action="/registration">
<input type="hidden" name="_method" value="delete"/>
<input type="hidden" name="id" value="${requestScope.profile.id}">
<button type="submit">${requestScope.wordBundle.getWord("delete")}</button>
</form>
</div>
<%@ include file="footer.jsp" %>
</body>
<head>
<title>Charm Profile</title>
<%@ include file="style.html" %>
</head>
<body>
<%@ include file="header.jsp" %>
<div>
<form method="post" action="/profile?id=${profile.id}" enctype="multipart/form-data">
<input type="hidden" name="_method" value="put"/>
<input type="hidden" name="id" value="${profile.id}">
<table>
<tr>
<td><h3>${wordBundle.getWord("name")}</h3></td>
<td><input type="text" name="name" value="${profile.name}"></td>
</tr>
<tr>
<td><h3>${wordBundle.getWord("surname")}</h3></td>
<td><input type="text" name="surname" value="${profile.surname}"></td>
</tr>
<tr>
<td><h3>${wordBundle.getWord("birth-date")}</h3></td>
<td><input type="date" name="birthDate" value="${profile.birthDate}"></td>
</tr>
<tr>
<td><h3>${wordBundle.getWord("about")}</h3></td>
<td><textarea name="about" cols="100" maxlength="1000" rows="5" wrap="soft">${profile.about}</textarea></td>
</tr>
<tr>
<td><h3>${wordBundle.getWord("gender")}</h3></td>
<td>
<select name="gender">
<option value="${profile.gender}" selected hidden>
${wordBundle.getWord(profile.gender)}
</option>
<c:forEach var="gender" items="${applicationScope.genders}">
<option value="${gender}">${wordBundle.getWord(gender)}</option>
</c:forEach>
</select>
</td>
</tr>
<tr>
<td><h3>${wordBundle.getWord("photo")}</h3></td>
<td>
<c:if test="${profile.photo != null}">
<img src="content/profiles/${requestScope.profile.id}/${requestScope.profile.photo}" alt="" height="300">
</c:if>
<br>
<input type="button" value="${wordBundle.getWord('update')}" onclick="document.getElementById('file').click();" />
<input type="file" name="photo" id="file" style="display:none;">
</td>
</tr>
</table>
<table>
<tr class="hiddenRow">
<td>
<input type="image" src="content/app/img/floppy-disk.png" width="75" alt="submit" class="icon" />
</td>
<td>
<a href="/email?id=${profile.id}"><img src="content/app/img/key.png" alt="" width="75"></a>
</td>
</tr>
</table>
</form>
<div style="color: red">
<c:forEach var="error" items="${errors}">
<span>${wordBundle.getWord(error)}</span>
<br>
</c:forEach>
</div>
</div>
<%@ include file="footer.jsp" %>
</body>
</html>

View File

@ -1,57 +1,78 @@
<!DOCTYPE html>
<html lang="en">
<style>
.saveImage {
width: 75px;
}
input {
width: 500px;
font-size: 15px;
font-family: "Roboto", sans-serif;
}
select {
width: 500px;
font-size: 15px;
font-family: "Roboto", sans-serif;
}
img {
max-width: 500px;
max-height: 500px;
}
textarea {
resize: none;
width: 500px;
font-size: 15px;
font-family: "Roboto", sans-serif;
}
div {
text-align: center;
font-family: "Roboto", sans-serif;
}
table {
margin-left: auto;
margin-right: auto;
border-collapse: collapse;
}
td {
text-align: left;
padding: 10px;
}
tr {
text-align: center;
padding: 10px;
border: 1px solid;
border-top: none;
border-left: none;
border-right: none;
}
</style>
<style>
.icon {
width: 75px;
}
.langButton {
padding: 0px;
border: none;
background: 0;
}
.langImg {
width: 40px;
}
input {
width: 500px;
font-size: 15px;
font-family: "Roboto", sans-serif;
}
select {
width: 500px;
font-size: 15px;
font-family: "Roboto", sans-serif;
}
img {
max-width: 500px;
max-height: 500px;
}
.photo {
max-width: 300px;
max-height: 500px;
}
textarea {
resize: none;
width: 500px;
font-size: 15px;
font-family: "Roboto", sans-serif;
}
div {
text-align: center;
font-family: "Roboto", sans-serif;
}
table {
margin-left: auto;
margin-right: auto;
border-collapse: collapse;
}
td {
text-align: left;
padding: 10px;
}
tr {
text-align: center;
padding: 10px;
border: 1px solid;
border-top: none;
border-left: none;
border-right: none;
}
.hiddenRow {
text-align: center;
padding: 0px;
border: none;
}
</style>
</html>

View File

@ -0,0 +1,33 @@
package ru.charm.back.controller;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import ru.charm.back.service.ContentService;
import java.io.IOException;
import static jakarta.servlet.http.HttpServletResponse.SC_NOT_FOUND;
@WebServlet("/content/*")
@Slf4j
public class ContentController extends HttpServlet {
private final ContentService service = ContentService.getInstance();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
String contentPath = req.getRequestURI().replace("/content/", "");
resp.setContentType("application/octet-stream");
service.download(contentPath, resp.getOutputStream());
log.info("Content successfully downloaded: {}", contentPath);
} catch (IOException e) {
log.error("Content download failed: {}", e.getMessage());
resp.sendError(SC_NOT_FOUND);
}
}
}

View File

@ -1,6 +1,7 @@
package ru.charm.back.controller;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.MultipartConfig;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
@ -25,6 +26,7 @@ import static jakarta.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
@WebServlet("/email")
@Slf4j
@MultipartConfig
public class EmailController extends HttpServlet {
private final ProfileService service = ProfileService.getInstance();
private final RequestToProfileUpdateDtoMapper requestToProfileUpdateDtoMapper = RequestToProfileUpdateDtoMapper.getInstance();

View File

@ -1,6 +1,7 @@
package ru.charm.back.controller;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.MultipartConfig;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
@ -16,6 +17,7 @@ import java.util.Optional;
import static jakarta.servlet.http.HttpServletResponse.SC_NOT_FOUND;
@WebServlet("/profile")
@MultipartConfig
public class ProfileController extends HttpServlet {
private final ProfileService service = ProfileService.getInstance();
@ -27,6 +29,7 @@ public class ProfileController extends HttpServlet {
String forwardUri = null;
if (sId != null) {
Optional<ProfileGetDto> optProfileDto = service.findById(Long.parseLong(sId));
System.out.println("Optional profile" + optProfileDto.toString());
if (optProfileDto.isPresent()) {
req.setAttribute("profile", optProfileDto.get());
forwardUri = "/WEB-INF/jsp/profile.jsp";

View File

@ -17,4 +17,5 @@ public class ProfileGetDto {
private String about;
private Gender gender;
private Status status;
private String photo;
}

View File

@ -1,6 +1,7 @@
package ru.charm.back.dto;
import jakarta.servlet.http.Part;
import lombok.Data;
import ru.charm.back.model.Gender;
import ru.charm.back.model.Status;
@ -18,4 +19,5 @@ public class ProfileUpdateDto {
private String about;
private Gender gender;
private Status status;
private Part photo;
}

View File

@ -36,6 +36,7 @@ public class ProfileToProfileGetDtoMapper implements Mapper<Profile, ProfileGetD
dto.setAbout(profile.getAbout());
dto.setGender(profile.getGender());
dto.setStatus(profile.getStatus());
dto.setPhoto(profile.getPhoto());
return dto;
}
}

View File

@ -44,6 +44,9 @@ public class ProfileUpdateDtoToProfileMapper implements Mapper<ProfileUpdateDto,
if (dto.getStatus() != null) {
profile.setStatus(dto.getStatus());
}
if (dto.getPhoto() != null) {
profile.setPhoto(dto.getPhoto().getSubmittedFileName());
}
return profile;
}
}

View File

@ -1,6 +1,9 @@
package ru.charm.back.mapper;
import jakarta.servlet.http.HttpServletRequest;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import ru.charm.back.dto.ProfileUpdateDto;
import ru.charm.back.model.Gender;
import ru.charm.back.model.Status;
@ -9,13 +12,10 @@ import java.time.LocalDate;
import static ru.charm.back.utils.StringUtils.isBlank;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class RequestToProfileUpdateDtoMapper implements Mapper<HttpServletRequest, ProfileUpdateDto> {
private static final RequestToProfileUpdateDtoMapper INSTANCE = new RequestToProfileUpdateDtoMapper();
private RequestToProfileUpdateDtoMapper() {
}
public static RequestToProfileUpdateDtoMapper getInstance() {
return INSTANCE;
}
@ -25,6 +25,7 @@ public class RequestToProfileUpdateDtoMapper implements Mapper<HttpServletReques
return map(req, new ProfileUpdateDto());
}
@SneakyThrows
@Override
public ProfileUpdateDto map(HttpServletRequest req, ProfileUpdateDto dto) {
String id = req.getParameter("id");
@ -50,6 +51,7 @@ public class RequestToProfileUpdateDtoMapper implements Mapper<HttpServletReques
if (!isBlank(status)) {
dto.setStatus(Status.valueOf(status));
}
dto.setPhoto(req.getPart("photo"));
return dto;
}
}

View File

@ -1,5 +1,6 @@
package ru.charm.back.model;
import jakarta.servlet.http.Part;
import lombok.Data;
import java.time.LocalDate;
@ -15,4 +16,5 @@ public class Profile {
private String about;
private Gender gender;
private Status status;
private String photo;
}

View File

@ -0,0 +1,66 @@
package ru.charm.back.service;
import jakarta.servlet.ServletOutputStream;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import static java.nio.file.StandardOpenOption.CREATE;
import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@Slf4j
public class ContentService {
private static final ContentService INSTANCE = new ContentService();
public static ContentService getInstance() {
return INSTANCE;
}
private final static String BASE_PATH = "/Users/ksv741/Project/education/YouTube/tinder-clone/Tinder Clone/media";
public void upload(String contentPath, InputStream inputStream) throws IOException {
Path contentFullPath = getAbsolutePath(contentPath);
OutputStream outputStream = Files.exists(contentFullPath.getParent())
? Files.newOutputStream(contentFullPath, CREATE, TRUNCATE_EXISTING)
: null;
if (outputStream == null) {
throw new FileNotFoundException();
}
writeContent(inputStream, outputStream);
}
public void download(String contentPath, ServletOutputStream outputStream) throws IOException {
InputStream inputStream;
if (contentPath.startsWith("/app/")) {
String appPath = "/WEB-INF" + contentPath.replaceFirst("/app", "");
inputStream = ContentService.class.getClassLoader().getResourceAsStream(appPath);
} else {
Path contentFullPath = getAbsolutePath(contentPath);
inputStream = Files.exists(contentFullPath) ? Files.newInputStream(contentFullPath) : null;
}
if (inputStream == null) {
throw new FileNotFoundException();
}
writeContent(inputStream, outputStream);
}
private void writeContent(InputStream inputStream, OutputStream outputStream) throws IOException {
try (inputStream; outputStream) {
int currentByte;
while ((currentByte = inputStream.read()) != -1) {
outputStream.write(currentByte);
}
}
}
private Path getAbsolutePath(String contentPath) {
return Path.of(BASE_PATH, contentPath);
}
}

View File

@ -2,6 +2,7 @@ package ru.charm.back.service;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import ru.charm.back.dao.ProfileDao;
import ru.charm.back.dto.ProfileGetDto;
import ru.charm.back.dto.ProfileUpdateDto;
@ -9,6 +10,7 @@ import ru.charm.back.dto.RegistrationDto;
import ru.charm.back.mapper.ProfileToProfileGetDtoMapper;
import ru.charm.back.mapper.ProfileUpdateDtoToProfileMapper;
import ru.charm.back.mapper.RegistrationDtoToProfileMapper;
import ru.charm.back.model.Profile;
import ru.charm.back.model.exception.DuplicateEmailException;
import java.util.List;
@ -23,6 +25,8 @@ public class ProfileService {
private final ProfileDao dao = ProfileDao.getInstance();
private final ContentService contentService = ContentService.getInstance();
private final ProfileToProfileGetDtoMapper profileToProfileGetDtoMapper = ProfileToProfileGetDtoMapper.getInstance();
private final ProfileUpdateDtoToProfileMapper profileUpdateDtoToProfileMapper = ProfileUpdateDtoToProfileMapper.getInstance();
@ -45,12 +49,18 @@ public class ProfileService {
return dao.findAll().stream().map(profileToProfileGetDtoMapper::map).toList();
}
@SneakyThrows
public void update(ProfileUpdateDto dto) {
dao.findById(dto.getId())
.ifPresent(profile -> {
dao.update(profileUpdateDtoToProfileMapper.map(dto, profile));
}
Optional<Profile> optionalProfile = dao.findById(dto.getId());
if (optionalProfile.isPresent()) {
if (dto.getPhoto() != null) {
contentService.upload(
"/profiles/" + dto.getId() + "/" + dto.getPhoto().getSubmittedFileName(),
dto.getPhoto().getInputStream()
);
}
dao.update(profileUpdateDtoToProfileMapper.map(dto, optionalProfile.get()));
}
}
public boolean delete(Long id) {