first commit
This commit is contained in:
commit
29b899f409
|
|
@ -0,0 +1,4 @@
|
||||||
|
target
|
||||||
|
.git
|
||||||
|
Dockerfile
|
||||||
|
*.md
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
/mvnw text eol=lf
|
||||||
|
*.cmd text eol=crlf
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
HELP.md
|
||||||
|
target/
|
||||||
|
.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### STS ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
wrapperVersion=3.3.4
|
||||||
|
distributionType=only-script
|
||||||
|
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.16/apache-maven-3.9.16-bin.zip
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
# ============================
|
||||||
|
# 1. Build Stage (Maven + JDK)
|
||||||
|
# ============================
|
||||||
|
FROM maven:3.9.6-eclipse-temurin-21 AS build
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copiar pom.xml y descargar dependencias (cache)
|
||||||
|
COPY pom.xml .
|
||||||
|
RUN mvn -q -e -B dependency:go-offline
|
||||||
|
|
||||||
|
# Copiar el código fuente
|
||||||
|
COPY src ./src
|
||||||
|
|
||||||
|
# Compilar el proyecto
|
||||||
|
RUN mvn -q -e -B clean package -DskipTests
|
||||||
|
|
||||||
|
# ============================
|
||||||
|
# 2. Runtime Stage (JDK ligero)
|
||||||
|
# ============================
|
||||||
|
FROM eclipse-temurin:21-jre-alpine
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copiar el JAR generado
|
||||||
|
COPY --from=build /app/target/*.jar app.jar
|
||||||
|
|
||||||
|
# Puerto interno del contenedor
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
# Ejecutar Spring Boot
|
||||||
|
ENTRYPOINT ["java", "-jar", "/app/app.jar"]
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,179 @@
|
||||||
|
2026-06-10 10:44:57.989914+02:00 jdbc[4]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLSyntaxErrorException: Tabla "SPRING_SESSION" no encontrada
|
||||||
|
Table "SPRING_SESSION" not found; SQL statement:
|
||||||
|
INSERT INTO SPRING_SESSION (PRIMARY_ID, SESSION_ID, CREATION_TIME, LAST_ACCESS_TIME, MAX_INACTIVE_INTERVAL, EXPIRY_TIME, PRINCIPAL_NAME)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
|
[42102-240]
|
||||||
|
2026-06-10 10:44:57.989914+02:00 jdbc[3]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLSyntaxErrorException: Tabla "SPRING_SESSION" no encontrada
|
||||||
|
Table "SPRING_SESSION" not found; SQL statement:
|
||||||
|
INSERT INTO SPRING_SESSION (PRIMARY_ID, SESSION_ID, CREATION_TIME, LAST_ACCESS_TIME, MAX_INACTIVE_INTERVAL, EXPIRY_TIME, PRINCIPAL_NAME)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
|
[42102-240]
|
||||||
|
2026-06-10 10:44:57.995651+02:00 jdbc[4]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLSyntaxErrorException: Tabla "SPRING_SESSION" no encontrada
|
||||||
|
Table "SPRING_SESSION" not found; SQL statement:
|
||||||
|
INSERT INTO SPRING_SESSION (PRIMARY_ID, SESSION_ID, CREATION_TIME, LAST_ACCESS_TIME, MAX_INACTIVE_INTERVAL, EXPIRY_TIME, PRINCIPAL_NAME)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
|
[42102-240]
|
||||||
|
2026-06-10 10:44:57.995651+02:00 jdbc[3]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLSyntaxErrorException: Tabla "SPRING_SESSION" no encontrada
|
||||||
|
Table "SPRING_SESSION" not found; SQL statement:
|
||||||
|
INSERT INTO SPRING_SESSION (PRIMARY_ID, SESSION_ID, CREATION_TIME, LAST_ACCESS_TIME, MAX_INACTIVE_INTERVAL, EXPIRY_TIME, PRINCIPAL_NAME)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
|
[42102-240]
|
||||||
|
2026-06-10 10:44:58.002147+02:00 jdbc[3]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLSyntaxErrorException: Tabla "SPRING_SESSION" no encontrada
|
||||||
|
Table "SPRING_SESSION" not found; SQL statement:
|
||||||
|
INSERT INTO SPRING_SESSION (PRIMARY_ID, SESSION_ID, CREATION_TIME, LAST_ACCESS_TIME, MAX_INACTIVE_INTERVAL, EXPIRY_TIME, PRINCIPAL_NAME)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
|
[42102-240]
|
||||||
|
2026-06-10 10:44:58.002147+02:00 jdbc[3]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLSyntaxErrorException: Tabla "SPRING_SESSION" no encontrada
|
||||||
|
Table "SPRING_SESSION" not found; SQL statement:
|
||||||
|
INSERT INTO SPRING_SESSION (PRIMARY_ID, SESSION_ID, CREATION_TIME, LAST_ACCESS_TIME, MAX_INACTIVE_INTERVAL, EXPIRY_TIME, PRINCIPAL_NAME)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
|
[42102-240]
|
||||||
|
2026-06-10 10:45:00.001603+02:00 jdbc[3]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLSyntaxErrorException: Tabla "SPRING_SESSION" no encontrada
|
||||||
|
Table "SPRING_SESSION" not found; SQL statement:
|
||||||
|
DELETE FROM SPRING_SESSION
|
||||||
|
WHERE EXPIRY_TIME < ?
|
||||||
|
[42102-240]
|
||||||
|
2026-06-10 10:45:14.276050+02:00 jdbc[3]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLSyntaxErrorException: Tabla "SPRING_SESSION" no encontrada
|
||||||
|
Table "SPRING_SESSION" not found; SQL statement:
|
||||||
|
INSERT INTO SPRING_SESSION (PRIMARY_ID, SESSION_ID, CREATION_TIME, LAST_ACCESS_TIME, MAX_INACTIVE_INTERVAL, EXPIRY_TIME, PRINCIPAL_NAME)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
|
[42102-240]
|
||||||
|
2026-06-10 10:45:14.276050+02:00 jdbc[3]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLSyntaxErrorException: Tabla "SPRING_SESSION" no encontrada
|
||||||
|
Table "SPRING_SESSION" not found; SQL statement:
|
||||||
|
INSERT INTO SPRING_SESSION (PRIMARY_ID, SESSION_ID, CREATION_TIME, LAST_ACCESS_TIME, MAX_INACTIVE_INTERVAL, EXPIRY_TIME, PRINCIPAL_NAME)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
|
[42102-240]
|
||||||
|
2026-06-10 10:45:14.279132+02:00 jdbc[3]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLSyntaxErrorException: Tabla "SPRING_SESSION" no encontrada
|
||||||
|
Table "SPRING_SESSION" not found; SQL statement:
|
||||||
|
INSERT INTO SPRING_SESSION (PRIMARY_ID, SESSION_ID, CREATION_TIME, LAST_ACCESS_TIME, MAX_INACTIVE_INTERVAL, EXPIRY_TIME, PRINCIPAL_NAME)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
|
[42102-240]
|
||||||
|
2026-06-10 10:45:14.279132+02:00 jdbc[3]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLSyntaxErrorException: Tabla "SPRING_SESSION" no encontrada
|
||||||
|
Table "SPRING_SESSION" not found; SQL statement:
|
||||||
|
INSERT INTO SPRING_SESSION (PRIMARY_ID, SESSION_ID, CREATION_TIME, LAST_ACCESS_TIME, MAX_INACTIVE_INTERVAL, EXPIRY_TIME, PRINCIPAL_NAME)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
|
[42102-240]
|
||||||
|
2026-06-10 10:46:00.006709+02:00 jdbc[3]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLSyntaxErrorException: Tabla "SPRING_SESSION" no encontrada
|
||||||
|
Table "SPRING_SESSION" not found; SQL statement:
|
||||||
|
DELETE FROM SPRING_SESSION
|
||||||
|
WHERE EXPIRY_TIME < ?
|
||||||
|
[42102-240]
|
||||||
|
2026-06-10 10:47:00.001855+02:00 jdbc[3]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLSyntaxErrorException: Tabla "SPRING_SESSION" no encontrada
|
||||||
|
Table "SPRING_SESSION" not found; SQL statement:
|
||||||
|
DELETE FROM SPRING_SESSION
|
||||||
|
WHERE EXPIRY_TIME < ?
|
||||||
|
[42102-240]
|
||||||
|
2026-06-10 10:48:00.000639+02:00 jdbc[3]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLSyntaxErrorException: Tabla "SPRING_SESSION" no encontrada
|
||||||
|
Table "SPRING_SESSION" not found; SQL statement:
|
||||||
|
DELETE FROM SPRING_SESSION
|
||||||
|
WHERE EXPIRY_TIME < ?
|
||||||
|
[42102-240]
|
||||||
|
2026-06-10 10:49:00.001166+02:00 jdbc[3]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLSyntaxErrorException: Tabla "SPRING_SESSION" no encontrada
|
||||||
|
Table "SPRING_SESSION" not found; SQL statement:
|
||||||
|
DELETE FROM SPRING_SESSION
|
||||||
|
WHERE EXPIRY_TIME < ?
|
||||||
|
[42102-240]
|
||||||
|
2026-06-10 10:50:00.000135+02:00 jdbc[3]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLSyntaxErrorException: Tabla "SPRING_SESSION" no encontrada
|
||||||
|
Table "SPRING_SESSION" not found; SQL statement:
|
||||||
|
DELETE FROM SPRING_SESSION
|
||||||
|
WHERE EXPIRY_TIME < ?
|
||||||
|
[42102-240]
|
||||||
|
2026-06-10 10:50:58.055890+02:00 database: flush
|
||||||
|
org.h2.message.DbException: Error General : "org.h2.mvstore.MVStoreException: The file is locked: C:/Trabajo/Desarrollo/crminmobiliario/data/crmdb.mv.db [2.4.240/7]"
|
||||||
|
General error: "org.h2.mvstore.MVStoreException: The file is locked: C:/Trabajo/Desarrollo/crminmobiliario/data/crmdb.mv.db [2.4.240/7]" [50000-240]
|
||||||
|
at org.h2.message.DbException.get(DbException.java:212)
|
||||||
|
at org.h2.message.DbException.convert(DbException.java:407)
|
||||||
|
at org.h2.mvstore.db.Store.lambda$new$0(Store.java:122)
|
||||||
|
at org.h2.mvstore.MVStore.handleException(MVStore.java:1675)
|
||||||
|
at org.h2.mvstore.MVStore.panic(MVStore.java:502)
|
||||||
|
at org.h2.mvstore.MVStore.<init>(MVStore.java:296)
|
||||||
|
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:2164)
|
||||||
|
at org.h2.mvstore.db.Store.<init>(Store.java:133)
|
||||||
|
at org.h2.engine.Database.<init>(Database.java:328)
|
||||||
|
at org.h2.engine.Engine.openSession(Engine.java:92)
|
||||||
|
at org.h2.engine.Engine.openSession(Engine.java:222)
|
||||||
|
at org.h2.engine.Engine.createSession(Engine.java:201)
|
||||||
|
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:350)
|
||||||
|
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:124)
|
||||||
|
at org.h2.Driver.connect(Driver.java:59)
|
||||||
|
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:144)
|
||||||
|
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:373)
|
||||||
|
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:210)
|
||||||
|
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:488)
|
||||||
|
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:576)
|
||||||
|
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:97)
|
||||||
|
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:111)
|
||||||
|
at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:160)
|
||||||
|
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:118)
|
||||||
|
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:81)
|
||||||
|
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:329)
|
||||||
|
at org.springframework.boot.jdbc.init.PlatformPlaceholderDatabaseDriverResolver.getDatabaseDriver(PlatformPlaceholderDatabaseDriverResolver.java:140)
|
||||||
|
at org.springframework.boot.jdbc.init.PlatformPlaceholderDatabaseDriverResolver.determinePlatform(PlatformPlaceholderDatabaseDriverResolver.java:132)
|
||||||
|
at org.springframework.boot.jdbc.init.PlatformPlaceholderDatabaseDriverResolver.lambda$resolveAll$0(PlatformPlaceholderDatabaseDriverResolver.java:97)
|
||||||
|
at org.springframework.boot.jdbc.init.PlatformPlaceholderDatabaseDriverResolver.resolveAll(PlatformPlaceholderDatabaseDriverResolver.java:122)
|
||||||
|
at org.springframework.boot.jdbc.init.PlatformPlaceholderDatabaseDriverResolver.resolveAll(PlatformPlaceholderDatabaseDriverResolver.java:97)
|
||||||
|
at org.springframework.boot.jdbc.init.PropertiesBasedDataSourceScriptDatabaseInitializer.resolveSchemaLocations(PropertiesBasedDataSourceScriptDatabaseInitializer.java:90)
|
||||||
|
at org.springframework.boot.jdbc.init.PropertiesBasedDataSourceScriptDatabaseInitializer.getSettings(PropertiesBasedDataSourceScriptDatabaseInitializer.java:75)
|
||||||
|
at org.springframework.boot.jdbc.init.PropertiesBasedDataSourceScriptDatabaseInitializer.<init>(PropertiesBasedDataSourceScriptDatabaseInitializer.java:59)
|
||||||
|
at org.springframework.boot.session.jdbc.autoconfigure.JdbcSessionDataSourceScriptDatabaseInitializer.<init>(JdbcSessionDataSourceScriptDatabaseInitializer.java:48)
|
||||||
|
at org.springframework.boot.session.jdbc.autoconfigure.JdbcSessionAutoConfiguration.jdbcSessionDataSourceScriptDatabaseInitializer(JdbcSessionAutoConfiguration.java:73)
|
||||||
|
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
|
||||||
|
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
|
||||||
|
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.lambda$instantiate$0(SimpleInstantiationStrategy.java:155)
|
||||||
|
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiateWithFactoryMethod(SimpleInstantiationStrategy.java:72)
|
||||||
|
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:152)
|
||||||
|
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
|
||||||
|
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:645)
|
||||||
|
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1362)
|
||||||
|
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1194)
|
||||||
|
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:565)
|
||||||
|
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:525)
|
||||||
|
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:333)
|
||||||
|
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:371)
|
||||||
|
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:331)
|
||||||
|
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
|
||||||
|
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:309)
|
||||||
|
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:201)
|
||||||
|
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:977)
|
||||||
|
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:621)
|
||||||
|
at org.springframework.boot.web.server.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143)
|
||||||
|
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:756)
|
||||||
|
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:445)
|
||||||
|
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
|
||||||
|
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1365)
|
||||||
|
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354)
|
||||||
|
at es.tatvil.crminmobiliario.CrminmobiliarioApplication.main(CrminmobiliarioApplication.java:10)
|
||||||
|
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: Error General : "org.h2.mvstore.MVStoreException: The file is locked: C:/Trabajo/Desarrollo/crminmobiliario/data/crmdb.mv.db [2.4.240/7]"
|
||||||
|
General error: "org.h2.mvstore.MVStoreException: The file is locked: C:/Trabajo/Desarrollo/crminmobiliario/data/crmdb.mv.db [2.4.240/7]" [50000-240]
|
||||||
|
at org.h2.message.DbException.getJdbcSQLException(DbException.java:566)
|
||||||
|
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
|
||||||
|
... 62 more
|
||||||
|
Caused by: org.h2.mvstore.MVStoreException: The file is locked: C:/Trabajo/Desarrollo/crminmobiliario/data/crmdb.mv.db [2.4.240/7]
|
||||||
|
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:996)
|
||||||
|
at org.h2.mvstore.SingleFileStore.lockFileChannel(SingleFileStore.java:143)
|
||||||
|
at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:117)
|
||||||
|
at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:81)
|
||||||
|
at org.h2.mvstore.MVStore.<init>(MVStore.java:291)
|
||||||
|
... 56 more
|
||||||
|
2026-06-10 10:51:00.002089+02:00 jdbc[3]: exception
|
||||||
|
org.h2.jdbc.JdbcSQLSyntaxErrorException: Tabla "SPRING_SESSION" no encontrada
|
||||||
|
Table "SPRING_SESSION" not found; SQL statement:
|
||||||
|
DELETE FROM SPRING_SESSION
|
||||||
|
WHERE EXPIRY_TIME < ?
|
||||||
|
[42102-240]
|
||||||
|
|
@ -0,0 +1,295 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# 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.
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# Apache Maven Wrapper startup batch script, version 3.3.4
|
||||||
|
#
|
||||||
|
# Optional ENV vars
|
||||||
|
# -----------------
|
||||||
|
# JAVA_HOME - location of a JDK home dir, required when download maven via java source
|
||||||
|
# MVNW_REPOURL - repo url base for downloading maven distribution
|
||||||
|
# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
|
||||||
|
# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
set -euf
|
||||||
|
[ "${MVNW_VERBOSE-}" != debug ] || set -x
|
||||||
|
|
||||||
|
# OS specific support.
|
||||||
|
native_path() { printf %s\\n "$1"; }
|
||||||
|
case "$(uname)" in
|
||||||
|
CYGWIN* | MINGW*)
|
||||||
|
[ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")"
|
||||||
|
native_path() { cygpath --path --windows "$1"; }
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# set JAVACMD and JAVACCMD
|
||||||
|
set_java_home() {
|
||||||
|
# For Cygwin and MinGW, ensure paths are in Unix format before anything is touched
|
||||||
|
if [ -n "${JAVA_HOME-}" ]; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ]; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
JAVACCMD="$JAVA_HOME/jre/sh/javac"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
JAVACCMD="$JAVA_HOME/bin/javac"
|
||||||
|
|
||||||
|
if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then
|
||||||
|
echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2
|
||||||
|
echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="$(
|
||||||
|
'set' +e
|
||||||
|
'unset' -f command 2>/dev/null
|
||||||
|
'command' -v java
|
||||||
|
)" || :
|
||||||
|
JAVACCMD="$(
|
||||||
|
'set' +e
|
||||||
|
'unset' -f command 2>/dev/null
|
||||||
|
'command' -v javac
|
||||||
|
)" || :
|
||||||
|
|
||||||
|
if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then
|
||||||
|
echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# hash string like Java String::hashCode
|
||||||
|
hash_string() {
|
||||||
|
str="${1:-}" h=0
|
||||||
|
while [ -n "$str" ]; do
|
||||||
|
char="${str%"${str#?}"}"
|
||||||
|
h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296))
|
||||||
|
str="${str#?}"
|
||||||
|
done
|
||||||
|
printf %x\\n $h
|
||||||
|
}
|
||||||
|
|
||||||
|
verbose() { :; }
|
||||||
|
[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; }
|
||||||
|
|
||||||
|
die() {
|
||||||
|
printf %s\\n "$1" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
trim() {
|
||||||
|
# MWRAPPER-139:
|
||||||
|
# Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds.
|
||||||
|
# Needed for removing poorly interpreted newline sequences when running in more
|
||||||
|
# exotic environments such as mingw bash on Windows.
|
||||||
|
printf "%s" "${1}" | tr -d '[:space:]'
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptDir="$(dirname "$0")"
|
||||||
|
scriptName="$(basename "$0")"
|
||||||
|
|
||||||
|
# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
|
||||||
|
while IFS="=" read -r key value; do
|
||||||
|
case "${key-}" in
|
||||||
|
distributionUrl) distributionUrl=$(trim "${value-}") ;;
|
||||||
|
distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
|
||||||
|
esac
|
||||||
|
done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties"
|
||||||
|
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
|
||||||
|
|
||||||
|
case "${distributionUrl##*/}" in
|
||||||
|
maven-mvnd-*bin.*)
|
||||||
|
MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/
|
||||||
|
case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in
|
||||||
|
*AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;;
|
||||||
|
:Darwin*x86_64) distributionPlatform=darwin-amd64 ;;
|
||||||
|
:Darwin*arm64) distributionPlatform=darwin-aarch64 ;;
|
||||||
|
:Linux*x86_64*) distributionPlatform=linux-amd64 ;;
|
||||||
|
*)
|
||||||
|
echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2
|
||||||
|
distributionPlatform=linux-amd64
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
|
||||||
|
;;
|
||||||
|
maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
|
||||||
|
*) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# apply MVNW_REPOURL and calculate MAVEN_HOME
|
||||||
|
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
|
||||||
|
[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}"
|
||||||
|
distributionUrlName="${distributionUrl##*/}"
|
||||||
|
distributionUrlNameMain="${distributionUrlName%.*}"
|
||||||
|
distributionUrlNameMain="${distributionUrlNameMain%-bin}"
|
||||||
|
MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}"
|
||||||
|
MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")"
|
||||||
|
|
||||||
|
exec_maven() {
|
||||||
|
unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || :
|
||||||
|
exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -d "$MAVEN_HOME" ]; then
|
||||||
|
verbose "found existing MAVEN_HOME at $MAVEN_HOME"
|
||||||
|
exec_maven "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "${distributionUrl-}" in
|
||||||
|
*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;;
|
||||||
|
*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# prepare tmp dir
|
||||||
|
if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then
|
||||||
|
clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; }
|
||||||
|
trap clean HUP INT TERM EXIT
|
||||||
|
else
|
||||||
|
die "cannot create temp dir"
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p -- "${MAVEN_HOME%/*}"
|
||||||
|
|
||||||
|
# Download and Install Apache Maven
|
||||||
|
verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
|
||||||
|
verbose "Downloading from: $distributionUrl"
|
||||||
|
verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||||
|
|
||||||
|
# select .zip or .tar.gz
|
||||||
|
if ! command -v unzip >/dev/null; then
|
||||||
|
distributionUrl="${distributionUrl%.zip}.tar.gz"
|
||||||
|
distributionUrlName="${distributionUrl##*/}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# verbose opt
|
||||||
|
__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR=''
|
||||||
|
[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v
|
||||||
|
|
||||||
|
# normalize http auth
|
||||||
|
case "${MVNW_PASSWORD:+has-password}" in
|
||||||
|
'') MVNW_USERNAME='' MVNW_PASSWORD='' ;;
|
||||||
|
has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then
|
||||||
|
verbose "Found wget ... using wget"
|
||||||
|
wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl"
|
||||||
|
elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then
|
||||||
|
verbose "Found curl ... using curl"
|
||||||
|
curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl"
|
||||||
|
elif set_java_home; then
|
||||||
|
verbose "Falling back to use Java to download"
|
||||||
|
javaSource="$TMP_DOWNLOAD_DIR/Downloader.java"
|
||||||
|
targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||||
|
cat >"$javaSource" <<-END
|
||||||
|
public class Downloader extends java.net.Authenticator
|
||||||
|
{
|
||||||
|
protected java.net.PasswordAuthentication getPasswordAuthentication()
|
||||||
|
{
|
||||||
|
return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() );
|
||||||
|
}
|
||||||
|
public static void main( String[] args ) throws Exception
|
||||||
|
{
|
||||||
|
setDefault( new Downloader() );
|
||||||
|
java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
END
|
||||||
|
# For Cygwin/MinGW, switch paths to Windows format before running javac and java
|
||||||
|
verbose " - Compiling Downloader.java ..."
|
||||||
|
"$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java"
|
||||||
|
verbose " - Running Downloader.java ..."
|
||||||
|
"$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If specified, validate the SHA-256 sum of the Maven distribution zip file
|
||||||
|
if [ -n "${distributionSha256Sum-}" ]; then
|
||||||
|
distributionSha256Result=false
|
||||||
|
if [ "$MVN_CMD" = mvnd.sh ]; then
|
||||||
|
echo "Checksum validation is not supported for maven-mvnd." >&2
|
||||||
|
echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
|
||||||
|
exit 1
|
||||||
|
elif command -v sha256sum >/dev/null; then
|
||||||
|
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then
|
||||||
|
distributionSha256Result=true
|
||||||
|
fi
|
||||||
|
elif command -v shasum >/dev/null; then
|
||||||
|
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then
|
||||||
|
distributionSha256Result=true
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2
|
||||||
|
echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ $distributionSha256Result = false ]; then
|
||||||
|
echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2
|
||||||
|
echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# unzip and move
|
||||||
|
if command -v unzip >/dev/null; then
|
||||||
|
unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip"
|
||||||
|
else
|
||||||
|
tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Find the actual extracted directory name (handles snapshots where filename != directory name)
|
||||||
|
actualDistributionDir=""
|
||||||
|
|
||||||
|
# First try the expected directory name (for regular distributions)
|
||||||
|
if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then
|
||||||
|
if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then
|
||||||
|
actualDistributionDir="$distributionUrlNameMain"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If not found, search for any directory with the Maven executable (for snapshots)
|
||||||
|
if [ -z "$actualDistributionDir" ]; then
|
||||||
|
# enable globbing to iterate over items
|
||||||
|
set +f
|
||||||
|
for dir in "$TMP_DOWNLOAD_DIR"/*; do
|
||||||
|
if [ -d "$dir" ]; then
|
||||||
|
if [ -f "$dir/bin/$MVN_CMD" ]; then
|
||||||
|
actualDistributionDir="$(basename "$dir")"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
set -f
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$actualDistributionDir" ]; then
|
||||||
|
verbose "Contents of $TMP_DOWNLOAD_DIR:"
|
||||||
|
verbose "$(ls -la "$TMP_DOWNLOAD_DIR")"
|
||||||
|
die "Could not find Maven distribution directory in extracted archive"
|
||||||
|
fi
|
||||||
|
|
||||||
|
verbose "Found extracted Maven distribution directory: $actualDistributionDir"
|
||||||
|
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url"
|
||||||
|
mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
|
||||||
|
|
||||||
|
clean || :
|
||||||
|
exec_maven "$@"
|
||||||
|
|
@ -0,0 +1,189 @@
|
||||||
|
<# : batch portion
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
@REM or more contributor license agreements. See the NOTICE file
|
||||||
|
@REM distributed with this work for additional information
|
||||||
|
@REM regarding copyright ownership. The ASF licenses this file
|
||||||
|
@REM to you under the Apache License, Version 2.0 (the
|
||||||
|
@REM "License"); you may not use this file except in compliance
|
||||||
|
@REM with the License. You may obtain a copy of the License at
|
||||||
|
@REM
|
||||||
|
@REM http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@REM
|
||||||
|
@REM Unless required by applicable law or agreed to in writing,
|
||||||
|
@REM software distributed under the License is distributed on an
|
||||||
|
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
@REM KIND, either express or implied. See the License for the
|
||||||
|
@REM specific language governing permissions and limitations
|
||||||
|
@REM under the License.
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
@REM Apache Maven Wrapper startup batch script, version 3.3.4
|
||||||
|
@REM
|
||||||
|
@REM Optional ENV vars
|
||||||
|
@REM MVNW_REPOURL - repo url base for downloading maven distribution
|
||||||
|
@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
|
||||||
|
@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output
|
||||||
|
@REM ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0)
|
||||||
|
@SET __MVNW_CMD__=
|
||||||
|
@SET __MVNW_ERROR__=
|
||||||
|
@SET __MVNW_PSMODULEP_SAVE=%PSModulePath%
|
||||||
|
@SET PSModulePath=
|
||||||
|
@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @(
|
||||||
|
IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B)
|
||||||
|
)
|
||||||
|
@SET PSModulePath=%__MVNW_PSMODULEP_SAVE%
|
||||||
|
@SET __MVNW_PSMODULEP_SAVE=
|
||||||
|
@SET __MVNW_ARG0_NAME__=
|
||||||
|
@SET MVNW_USERNAME=
|
||||||
|
@SET MVNW_PASSWORD=
|
||||||
|
@IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*)
|
||||||
|
@echo Cannot start maven from wrapper >&2 && exit /b 1
|
||||||
|
@GOTO :EOF
|
||||||
|
: end batch / begin powershell #>
|
||||||
|
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
if ($env:MVNW_VERBOSE -eq "true") {
|
||||||
|
$VerbosePreference = "Continue"
|
||||||
|
}
|
||||||
|
|
||||||
|
# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties
|
||||||
|
$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl
|
||||||
|
if (!$distributionUrl) {
|
||||||
|
Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
|
||||||
|
}
|
||||||
|
|
||||||
|
switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) {
|
||||||
|
"maven-mvnd-*" {
|
||||||
|
$USE_MVND = $true
|
||||||
|
$distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip"
|
||||||
|
$MVN_CMD = "mvnd.cmd"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
default {
|
||||||
|
$USE_MVND = $false
|
||||||
|
$MVN_CMD = $script -replace '^mvnw','mvn'
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# apply MVNW_REPOURL and calculate MAVEN_HOME
|
||||||
|
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
|
||||||
|
if ($env:MVNW_REPOURL) {
|
||||||
|
$MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" }
|
||||||
|
$distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')"
|
||||||
|
}
|
||||||
|
$distributionUrlName = $distributionUrl -replace '^.*/',''
|
||||||
|
$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$',''
|
||||||
|
|
||||||
|
$MAVEN_M2_PATH = "$HOME/.m2"
|
||||||
|
if ($env:MAVEN_USER_HOME) {
|
||||||
|
$MAVEN_M2_PATH = "$env:MAVEN_USER_HOME"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not (Test-Path -Path $MAVEN_M2_PATH)) {
|
||||||
|
New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
$MAVEN_WRAPPER_DISTS = $null
|
||||||
|
if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) {
|
||||||
|
$MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists"
|
||||||
|
} else {
|
||||||
|
$MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists"
|
||||||
|
}
|
||||||
|
|
||||||
|
$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain"
|
||||||
|
$MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
|
||||||
|
$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME"
|
||||||
|
|
||||||
|
if (Test-Path -Path "$MAVEN_HOME" -PathType Container) {
|
||||||
|
Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME"
|
||||||
|
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
|
||||||
|
exit $?
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) {
|
||||||
|
Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl"
|
||||||
|
}
|
||||||
|
|
||||||
|
# prepare tmp dir
|
||||||
|
$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile
|
||||||
|
$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir"
|
||||||
|
$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null
|
||||||
|
trap {
|
||||||
|
if ($TMP_DOWNLOAD_DIR.Exists) {
|
||||||
|
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
|
||||||
|
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null
|
||||||
|
|
||||||
|
# Download and Install Apache Maven
|
||||||
|
Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
|
||||||
|
Write-Verbose "Downloading from: $distributionUrl"
|
||||||
|
Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
|
||||||
|
|
||||||
|
$webclient = New-Object System.Net.WebClient
|
||||||
|
if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) {
|
||||||
|
$webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD)
|
||||||
|
}
|
||||||
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
|
$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null
|
||||||
|
|
||||||
|
# If specified, validate the SHA-256 sum of the Maven distribution zip file
|
||||||
|
$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum
|
||||||
|
if ($distributionSha256Sum) {
|
||||||
|
if ($USE_MVND) {
|
||||||
|
Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties."
|
||||||
|
}
|
||||||
|
Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash
|
||||||
|
if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) {
|
||||||
|
Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# unzip and move
|
||||||
|
Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null
|
||||||
|
|
||||||
|
# Find the actual extracted directory name (handles snapshots where filename != directory name)
|
||||||
|
$actualDistributionDir = ""
|
||||||
|
|
||||||
|
# First try the expected directory name (for regular distributions)
|
||||||
|
$expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain"
|
||||||
|
$expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD"
|
||||||
|
if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) {
|
||||||
|
$actualDistributionDir = $distributionUrlNameMain
|
||||||
|
}
|
||||||
|
|
||||||
|
# If not found, search for any directory with the Maven executable (for snapshots)
|
||||||
|
if (!$actualDistributionDir) {
|
||||||
|
Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object {
|
||||||
|
$testPath = Join-Path $_.FullName "bin/$MVN_CMD"
|
||||||
|
if (Test-Path -Path $testPath -PathType Leaf) {
|
||||||
|
$actualDistributionDir = $_.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$actualDistributionDir) {
|
||||||
|
Write-Error "Could not find Maven distribution directory in extracted archive"
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir"
|
||||||
|
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null
|
||||||
|
try {
|
||||||
|
Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null
|
||||||
|
} catch {
|
||||||
|
if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) {
|
||||||
|
Write-Error "fail to move MAVEN_HOME"
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
|
||||||
|
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
|
||||||
|
|
@ -0,0 +1,95 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>4.0.6</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
<groupId>es.tatvil</groupId>
|
||||||
|
<artifactId>crminmobiliario</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<name/>
|
||||||
|
<description/>
|
||||||
|
<url/>
|
||||||
|
<licenses>
|
||||||
|
<license/>
|
||||||
|
</licenses>
|
||||||
|
<developers>
|
||||||
|
<developer/>
|
||||||
|
</developers>
|
||||||
|
<scm>
|
||||||
|
<connection/>
|
||||||
|
<developerConnection/>
|
||||||
|
<tag/>
|
||||||
|
<url/>
|
||||||
|
</scm>
|
||||||
|
<properties>
|
||||||
|
<java.version>21</java.version>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-session-jdbc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-webmvc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.h2database</groupId>
|
||||||
|
<artifactId>h2</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-jpa-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-session-jdbc-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-webmvc-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
package es.tatvil.crminmobiliario;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class CrminmobiliarioApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(CrminmobiliarioApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
package es.tatvil.crminmobiliario.controller;
|
||||||
|
|
||||||
|
import es.tatvil.crminmobiliario.model.Usuario;
|
||||||
|
import es.tatvil.crminmobiliario.repository.UsuarioRepository;
|
||||||
|
import es.tatvil.crminmobiliario.service.UsuarioService;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class AuthController {
|
||||||
|
|
||||||
|
private final UsuarioService usuarioService;
|
||||||
|
private final UsuarioRepository usuarioRepository;
|
||||||
|
|
||||||
|
public AuthController(UsuarioService usuarioService, UsuarioRepository usuarioRepository) {
|
||||||
|
this.usuarioService = usuarioService;
|
||||||
|
this.usuarioRepository = usuarioRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/login")
|
||||||
|
public String loginPage(@RequestParam(required = false) String registered,
|
||||||
|
@RequestParam(required = false) String error,
|
||||||
|
Model model) {
|
||||||
|
if (registered != null) {
|
||||||
|
model.addAttribute("message", "Registro exitoso. Ingresa con tu usuario.");
|
||||||
|
}
|
||||||
|
if (error != null) {
|
||||||
|
model.addAttribute("error", "Usuario o contraseña incorrectos.");
|
||||||
|
}
|
||||||
|
return "login";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/register")
|
||||||
|
public String registerForm(Model model) {
|
||||||
|
model.addAttribute("usuario", new Usuario());
|
||||||
|
return "register";
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/register")
|
||||||
|
public String registerSubmit(@ModelAttribute Usuario usuario, Model model) {
|
||||||
|
if (usuarioRepository.existsByUsername(usuario.getUsername())) {
|
||||||
|
model.addAttribute("error", "El nombre de usuario ya existe.");
|
||||||
|
return "register";
|
||||||
|
}
|
||||||
|
|
||||||
|
usuarioService.registrarUsuario(usuario);
|
||||||
|
return "redirect:/login?registered";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
package es.tatvil.crminmobiliario.controller;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import java.security.Principal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.TextStyle;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/api")
|
||||||
|
public class HomeController {
|
||||||
|
|
||||||
|
@GetMapping("/home-data")
|
||||||
|
@ResponseBody
|
||||||
|
public Map<String, String> homeData() {
|
||||||
|
Map<String, String> data = new HashMap<>();
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
|
||||||
|
data.put("fechaHoy", formatFecha(today));
|
||||||
|
data.put("tiempoHtml", "<p>Datos del tiempo no disponibles todavía.</p>");
|
||||||
|
data.put("cumplesHtml", "<p><strong>CUMPLEAÑOS</strong><br>No hay cumpleaños cargados.</p>");
|
||||||
|
data.put("diaInternacionalHtml", "<p>No hay celebración internacional cargada.</p>");
|
||||||
|
data.put("santosHoyHtml", "<p><strong>SANTOS</strong><br>No hay santos cargados.</p>");
|
||||||
|
data.put("santosProximosHtml", "<p>No hay santos próximos cargados.</p>");
|
||||||
|
data.put("boeHtml", "<p>No hay información del BOE disponible.</p>");
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String formatFecha(LocalDate date) {
|
||||||
|
String nombreDia = date.getDayOfWeek().getDisplayName(TextStyle.FULL, new Locale("es"));
|
||||||
|
String nombreMes = date.getMonth().getDisplayName(TextStyle.FULL, new Locale("es"));
|
||||||
|
return String.format("%s, %d de %s de %d", capitalize(nombreDia), date.getDayOfMonth(), capitalize(nombreMes), date.getYear());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String capitalize(String value) {
|
||||||
|
if (value == null || value.isBlank()) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return Character.toUpperCase(value.charAt(0)) + value.substring(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package es.tatvil.crminmobiliario.controller;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
import java.security.Principal;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class IndexController {
|
||||||
|
|
||||||
|
@GetMapping("/")
|
||||||
|
public String index(Model model, Principal principal) {
|
||||||
|
if (principal != null) {
|
||||||
|
model.addAttribute("username", principal.getName());
|
||||||
|
}
|
||||||
|
return "index";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
package es.tatvil.crminmobiliario.model;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "usuarios")
|
||||||
|
public class Usuario {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Column(nullable = false, unique = true)
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
private String role = "USER";
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
private boolean enabled = true;
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRole() {
|
||||||
|
return role;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRole(String role) {
|
||||||
|
this.role = role;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package es.tatvil.crminmobiliario.repository;
|
||||||
|
|
||||||
|
import es.tatvil.crminmobiliario.model.Usuario;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface UsuarioRepository extends JpaRepository<Usuario, Long> {
|
||||||
|
Optional<Usuario> findByUsername(String username);
|
||||||
|
boolean existsByUsername(String username);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
package es.tatvil.crminmobiliario.security;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class SecurityConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public PasswordEncoder passwordEncoder() {
|
||||||
|
return new BCryptPasswordEncoder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||||
|
http.authorizeHttpRequests(auth -> auth
|
||||||
|
.requestMatchers("/", "/login", "/register", "/css/**", "/js/**", "/img/**").permitAll()
|
||||||
|
.anyRequest().authenticated())
|
||||||
|
.formLogin(login -> login
|
||||||
|
.loginPage("/login")
|
||||||
|
.defaultSuccessUrl("/", true)
|
||||||
|
.permitAll())
|
||||||
|
.logout(logout -> logout
|
||||||
|
.logoutSuccessUrl("/")
|
||||||
|
.permitAll());
|
||||||
|
|
||||||
|
return http.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
package es.tatvil.crminmobiliario.service;
|
||||||
|
|
||||||
|
import es.tatvil.crminmobiliario.model.Usuario;
|
||||||
|
import es.tatvil.crminmobiliario.repository.UsuarioRepository;
|
||||||
|
import org.springframework.security.core.userdetails.User;
|
||||||
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||||
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UsuarioService implements UserDetailsService {
|
||||||
|
|
||||||
|
private final UsuarioRepository usuarioRepository;
|
||||||
|
private final PasswordEncoder passwordEncoder;
|
||||||
|
|
||||||
|
public UsuarioService(UsuarioRepository usuarioRepository, PasswordEncoder passwordEncoder) {
|
||||||
|
this.usuarioRepository = usuarioRepository;
|
||||||
|
this.passwordEncoder = passwordEncoder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||||
|
Usuario usuario = usuarioRepository.findByUsername(username)
|
||||||
|
.orElseThrow(() -> new UsernameNotFoundException("Usuario no encontrado: " + username));
|
||||||
|
|
||||||
|
return User.withUsername(usuario.getUsername())
|
||||||
|
.password(usuario.getPassword())
|
||||||
|
.roles(usuario.getRole())
|
||||||
|
.disabled(!usuario.isEnabled())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Usuario registrarUsuario(Usuario usuario) {
|
||||||
|
usuario.setPassword(passwordEncoder.encode(usuario.getPassword()));
|
||||||
|
usuario.setRole("USER");
|
||||||
|
usuario.setEnabled(true);
|
||||||
|
return usuarioRepository.save(usuario);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
spring.application.name=crminmobiliario
|
||||||
|
spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
|
||||||
|
spring.datasource.driver-class-name=org.h2.Driver
|
||||||
|
spring.datasource.username=sa
|
||||||
|
spring.datasource.password=
|
||||||
|
spring.jpa.hibernate.ddl-auto=update
|
||||||
|
spring.session.store-type=jdbc
|
||||||
|
spring.session.jdbc.initialize-schema=always
|
||||||
|
spring.sql.init.mode=never
|
||||||
|
|
@ -0,0 +1,567 @@
|
||||||
|
*
|
||||||
|
{
|
||||||
|
font-family: Gotham, Verdana, Geneva, Tahoma, sans-serif;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
--color-oscuro:#0054a4;
|
||||||
|
--color-medio: #007dc3;
|
||||||
|
--color-claro: #a4d7f4;
|
||||||
|
--color-secundario: #ff9900;
|
||||||
|
--color-secundario-claro: #ffc24a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.columna h3
|
||||||
|
{
|
||||||
|
position: fixed;
|
||||||
|
width:100%;
|
||||||
|
text-align: center;
|
||||||
|
color: var(--color-oscuro);
|
||||||
|
padding-top:3%;
|
||||||
|
top: 2%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.columna .cuerpo-columna
|
||||||
|
{
|
||||||
|
/* position: fixed;
|
||||||
|
width:100%;
|
||||||
|
text-align: center;
|
||||||
|
color: var(--color-oscuro);
|
||||||
|
padding-top:3%;
|
||||||
|
top: 20%; */
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-principal{
|
||||||
|
position: fixed;
|
||||||
|
width: 100%;
|
||||||
|
list-style-type: none;
|
||||||
|
top:100px;
|
||||||
|
background-color: var(--color-oscuro);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
.menu-principal.a {
|
||||||
|
color: white;
|
||||||
|
text-align: center;
|
||||||
|
padding: 14px 16px;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
menu-principal.a:hover {
|
||||||
|
color: var(--color-medio);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
.active {
|
||||||
|
background-color: var(--color-secundario);
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.menu-principal ul {
|
||||||
|
list-style-type: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: var(--color-oscuro);
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-principal li {
|
||||||
|
display: inline;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-principal li a {
|
||||||
|
display: block;
|
||||||
|
color: white;
|
||||||
|
text-align: center;
|
||||||
|
padding: 14px 16px;
|
||||||
|
text-decoration: none;
|
||||||
|
background-color: var(--color-oscuro);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Change the link color to #111 (black) on hover */
|
||||||
|
.menu-principal li a:hover {
|
||||||
|
background-color: var(--color-medio);
|
||||||
|
}
|
||||||
|
.titulo
|
||||||
|
{
|
||||||
|
width: 100%;
|
||||||
|
position: fixed;
|
||||||
|
font-size:1.25em;
|
||||||
|
padding: 5px;
|
||||||
|
top: 0px;
|
||||||
|
height: 100px;
|
||||||
|
text-align: center;
|
||||||
|
color: var(--color-claro);
|
||||||
|
background-color: var(--color-oscuro);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
body
|
||||||
|
{
|
||||||
|
top:140px;
|
||||||
|
position: fixed;
|
||||||
|
width:100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.cuerpo
|
||||||
|
{
|
||||||
|
position: fixed;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
|
align-content: strech;
|
||||||
|
height: 60%;
|
||||||
|
top: 140px;
|
||||||
|
padding: 2.5px;
|
||||||
|
text-align: center;
|
||||||
|
color: var(--color-oscuro);
|
||||||
|
background-color: white;
|
||||||
|
text-decoration: none;
|
||||||
|
border: 5px solid var(--color-oscuro);
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cuerpo-20
|
||||||
|
{
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
|
align-content: strech;
|
||||||
|
height: 150px;
|
||||||
|
|
||||||
|
padding: 2.5px;
|
||||||
|
text-align: center;
|
||||||
|
color: var(--color-oscuro);
|
||||||
|
background-color: white;
|
||||||
|
text-decoration: none;
|
||||||
|
border: 5px solid var(--color-oscuro);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cuerpo-80
|
||||||
|
{
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
|
align-content: strech;
|
||||||
|
height: 90%;
|
||||||
|
|
||||||
|
padding: 2.5px;
|
||||||
|
text-align: center;
|
||||||
|
color: var(--color-oscuro);
|
||||||
|
background-color: white;
|
||||||
|
text-decoration: none;
|
||||||
|
border: 5px solid var(--color-oscuro);
|
||||||
|
}
|
||||||
|
|
||||||
|
.columna
|
||||||
|
{
|
||||||
|
border: 2.5px solid var(--color-oscuro);
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 1%;
|
||||||
|
margin: 1%;
|
||||||
|
width: 25%;
|
||||||
|
height: 90%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.columna-movil {
|
||||||
|
width: 100%; /* Cambiar el ancho a 100% para ocupar toda la pantalla */
|
||||||
|
float: none; /* Eliminar el apilamiento horizontal */
|
||||||
|
margin-right: 0; /* Eliminar el margen derecho */
|
||||||
|
margin-bottom: 10px; /* Reducir el espacio debajo de las columnas */
|
||||||
|
}
|
||||||
|
|
||||||
|
.borde
|
||||||
|
{
|
||||||
|
border: 2.5px solid var(--color-oscuro);
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.tabla
|
||||||
|
{
|
||||||
|
width: 100%;
|
||||||
|
height:100%
|
||||||
|
}
|
||||||
|
|
||||||
|
.lista
|
||||||
|
{
|
||||||
|
text-align:center;
|
||||||
|
border-bottom: 1px solid var(--color-claro);
|
||||||
|
border-left: 1px solid var(--color-claro);
|
||||||
|
padding: 2.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.calendario
|
||||||
|
{
|
||||||
|
text-align:center;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hoy
|
||||||
|
{
|
||||||
|
border-radius: 50px;
|
||||||
|
background-color: var(--color-oscuro);
|
||||||
|
color: var(--color-claro);
|
||||||
|
}
|
||||||
|
|
||||||
|
.header
|
||||||
|
{
|
||||||
|
position: fixed;
|
||||||
|
padding: 2%;
|
||||||
|
text-align: center;
|
||||||
|
color: var(--color-oscuro);
|
||||||
|
text-decoration: none;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.buscar
|
||||||
|
{
|
||||||
|
padding: 1%;
|
||||||
|
margin: 1%;
|
||||||
|
text-align: center;
|
||||||
|
color: var(--color-oscuro);
|
||||||
|
text-decoration: none;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.centrar
|
||||||
|
{
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.parrafo {
|
||||||
|
background-color:var(--color-claro);
|
||||||
|
color:var(--color-oscuro);
|
||||||
|
border:5px solid var(--color-oscuro);
|
||||||
|
padding: 5%;
|
||||||
|
font-family: Gotham, Verdana, Geneva, Tahoma, sans-serif;
|
||||||
|
font-size: larger;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitulo
|
||||||
|
{
|
||||||
|
font-size:1.5em;
|
||||||
|
padding: 5px;
|
||||||
|
text-align: center;
|
||||||
|
color: var(--color-oscuro);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container
|
||||||
|
{
|
||||||
|
position:absolute;
|
||||||
|
width: 100%;
|
||||||
|
background-color: white;
|
||||||
|
height: 80%;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.elemento
|
||||||
|
{
|
||||||
|
position: relative;
|
||||||
|
background-color: var(--color-oscuro);
|
||||||
|
padding: 10px;
|
||||||
|
width: 40%;
|
||||||
|
text-align: center;
|
||||||
|
margin: 3%;
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 5px 5px var(--color-claro);
|
||||||
|
display: inline-block;
|
||||||
|
max-width: 300px;
|
||||||
|
}
|
||||||
|
.elemento a
|
||||||
|
{
|
||||||
|
color: var(--color-claro);
|
||||||
|
text-decoration: none;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer
|
||||||
|
{
|
||||||
|
position:fixed;
|
||||||
|
bottom: 0;
|
||||||
|
width:98%;
|
||||||
|
padding: 1%;
|
||||||
|
text-align: center;
|
||||||
|
color:var(--color-claro);
|
||||||
|
background-color: var(--color-oscuro);
|
||||||
|
}
|
||||||
|
a
|
||||||
|
{color: var(--color-medio);}
|
||||||
|
|
||||||
|
/* Formularios */
|
||||||
|
|
||||||
|
.formulario
|
||||||
|
{
|
||||||
|
margin-left: 1%;
|
||||||
|
margin-right: 1%;
|
||||||
|
width:96%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.boton
|
||||||
|
{
|
||||||
|
background-color: var(--color-oscuro);
|
||||||
|
border: none;
|
||||||
|
color: var(--color-claro);
|
||||||
|
padding: 15px 15px;
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none;
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 16px;
|
||||||
|
margin: 2%;
|
||||||
|
border-radius: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.boton:hover
|
||||||
|
{
|
||||||
|
color: var(--color-medio);
|
||||||
|
}
|
||||||
|
|
||||||
|
.boton-buscar
|
||||||
|
{
|
||||||
|
background-color: var(--color-oscuro);
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
|
padding: 1%;
|
||||||
|
margin: 1%;
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none;
|
||||||
|
font-size: 16px;
|
||||||
|
border-radius: 12px;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.registro
|
||||||
|
{
|
||||||
|
width: 100%;
|
||||||
|
display: inline-block;
|
||||||
|
position:absolute;
|
||||||
|
padding: 3%
|
||||||
|
}
|
||||||
|
|
||||||
|
.etiqueta
|
||||||
|
{
|
||||||
|
position:relative;
|
||||||
|
width:200px;
|
||||||
|
padding: .5%;
|
||||||
|
margin-left: 2%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.campo
|
||||||
|
{
|
||||||
|
width:96%;
|
||||||
|
padding: 1%;
|
||||||
|
margin: 1%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.campo-200
|
||||||
|
{
|
||||||
|
width:200px;
|
||||||
|
padding: 12px 20px;
|
||||||
|
margin: 8px 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border: 1.5px solid var(--color-oscuro);
|
||||||
|
border-radius: 10px;
|
||||||
|
position:relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.campo-2
|
||||||
|
{
|
||||||
|
width:18%;
|
||||||
|
padding: .5%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.campo-4
|
||||||
|
{
|
||||||
|
width:34%;
|
||||||
|
padding: .5%;
|
||||||
|
/* margin: 1%;
|
||||||
|
box-sizing: border-box; */
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.campo-8
|
||||||
|
{
|
||||||
|
width:74%;
|
||||||
|
padding: .5%;
|
||||||
|
/* margin: 1%;
|
||||||
|
box-sizing: border-box; */
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dato
|
||||||
|
{
|
||||||
|
display: inline-block;
|
||||||
|
padding: 1%;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.grupo-datos
|
||||||
|
{
|
||||||
|
display: inline-block;
|
||||||
|
/* border: solid 1.5px var(--color-oscuro); */
|
||||||
|
border-radius: 10px;
|
||||||
|
width:90%;
|
||||||
|
margin:1%;
|
||||||
|
align-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create a custom checkbox */
|
||||||
|
.casilla {
|
||||||
|
position: relative;
|
||||||
|
height: 25px;
|
||||||
|
width: 25px;
|
||||||
|
background-color: var(--color-claro);
|
||||||
|
border: var(--color-oscuro);
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid-container {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: auto auto auto;
|
||||||
|
grid-gap: 10px;
|
||||||
|
background-color: var(--color-oscuro);
|
||||||
|
padding: 10px;
|
||||||
|
font-size: 20px;
|
||||||
|
border: var(--color-oscuro) 10px solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid-container > div {
|
||||||
|
background-color: var(--color-claro);
|
||||||
|
text-align: center;
|
||||||
|
padding: 20px 0;
|
||||||
|
border-radius: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid-container > div > table
|
||||||
|
{
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.autor
|
||||||
|
{
|
||||||
|
text-align:right;
|
||||||
|
}
|
||||||
|
|
||||||
|
select
|
||||||
|
{
|
||||||
|
background: var(--color-claro);
|
||||||
|
border: var(--color-oscuro) 1px;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
height: 40px;
|
||||||
|
padding: 5px;
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input
|
||||||
|
{
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* input [type='date']
|
||||||
|
{
|
||||||
|
margin: 8px 0;
|
||||||
|
background: var(--color-claro);
|
||||||
|
border: var(--color-oscuro) 1px;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
height: 50px;
|
||||||
|
padding: 5px;
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input [type='number']
|
||||||
|
{
|
||||||
|
margin: 8px 0;
|
||||||
|
background: var(--color-claro);
|
||||||
|
border: var(--color-oscuro) 1px;
|
||||||
|
font-size:100px;
|
||||||
|
height: 100px;
|
||||||
|
padding: 5px;
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=text]:focus
|
||||||
|
{
|
||||||
|
border: 3px solid var(--color-oscuro);
|
||||||
|
background-color: var(--color-claro);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Customize the label (the container) */
|
||||||
|
.container {
|
||||||
|
display: block;
|
||||||
|
position: relative;
|
||||||
|
padding-left: 35px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 22px;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hide the browser's default checkbox */
|
||||||
|
.container input {
|
||||||
|
position: absolute;
|
||||||
|
opacity: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
height: 0;
|
||||||
|
width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create a custom checkbox */
|
||||||
|
.checkmark {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
height: 25px;
|
||||||
|
width: 25px;
|
||||||
|
background-color: #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* On mouse-over, add a grey background color */
|
||||||
|
.container:hover input ~ .checkmark {
|
||||||
|
background-color: #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* When the checkbox is checked, add a blue background */
|
||||||
|
.container input:checked ~ .checkmark {
|
||||||
|
background-color: #2196F3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create
|
||||||
|
k:after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Show the checkmark when checked */
|
||||||
|
.container input:checked ~ .checkmark:after {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Style the checkmark/indicator */
|
||||||
|
.container .checkmark:after {
|
||||||
|
left: 9px;
|
||||||
|
top: 5px;
|
||||||
|
width: 5px;
|
||||||
|
height: 10px;
|
||||||
|
border: solid white;
|
||||||
|
border-width: 0 3px 3px 0;
|
||||||
|
-webkit-transform: rotate(45deg);
|
||||||
|
-ms-transform: rotate(45deg);
|
||||||
|
transform: rotate(45deg);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="es">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Diario</title>
|
||||||
|
<link rel="stylesheet" href="/css/style.css">
|
||||||
|
<link rel="icon" type="image/png" href="img/icono.png" />
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap" rel="stylesheet">
|
||||||
|
<script src="/js/app.js" defer></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="titulo">
|
||||||
|
<h1>DIARIO</h1>
|
||||||
|
<h3 id="fecha-hoy">Cargando fecha...</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="cuerpo">
|
||||||
|
<div id="calendario" style="order: 1" class="columna">
|
||||||
|
<!-- Calendario del mes actual -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="order: 2" class="columna">
|
||||||
|
<h3>El tiempo en Madrid</h3>
|
||||||
|
<div id="tiempo">
|
||||||
|
<p>Cargando datos del tiempo...</p>
|
||||||
|
</div>
|
||||||
|
<br><a class="boton" href="../weather/">Histórico del tiempo</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="order: 3" class="columna">
|
||||||
|
<div id="cumpleanos">
|
||||||
|
<p>Cargando cumpleaños...</p>
|
||||||
|
</div>
|
||||||
|
<div id="dia-internacional"></div>
|
||||||
|
<div id="santos-hoy"></div>
|
||||||
|
<div id="santos-proximos"></div>
|
||||||
|
<div id="boe"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<p>Diario generado con Spring Boot y JavaScript.</p>
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
fetch('/api/home-data')
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
document.getElementById('fecha-hoy').textContent = data.fechaHoy;
|
||||||
|
document.getElementById('tiempo').innerHTML = data.tiempoHtml;
|
||||||
|
document.getElementById('cumpleanos').innerHTML = data.cumplesHtml;
|
||||||
|
document.getElementById('dia-internacional').innerHTML = data.diaInternacionalHtml;
|
||||||
|
document.getElementById('santos-hoy').innerHTML = data.santosHoyHtml;
|
||||||
|
document.getElementById('santos-proximos').innerHTML = data.santosProximosHtml;
|
||||||
|
document.getElementById('boe').innerHTML = data.boeHtml;
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error al cargar datos:', error);
|
||||||
|
document.getElementById('tiempo').textContent = 'No se pudieron cargar los datos del tiempo.';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="es" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Diario</title>
|
||||||
|
<link rel="stylesheet" href="/css/style.css" />
|
||||||
|
<link rel="icon" type="image/png" href="/img/icono.png" />
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap" rel="stylesheet" />
|
||||||
|
<script src="/js/app.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="titulo">
|
||||||
|
<h1>DIARIO</h1>
|
||||||
|
<div class="usuario-barra">
|
||||||
|
<p th:if="${username}">Bienvenido, <strong th:text="${username}"></strong></p>
|
||||||
|
<div th:if="${username == null}">
|
||||||
|
<a class="boton" href="/login">Iniciar sesión</a>
|
||||||
|
<a class="boton" href="/register">Registrarse</a>
|
||||||
|
</div>
|
||||||
|
<div th:if="${username}">
|
||||||
|
<a class="boton" href="/logout">Cerrar sesión</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="cuerpo">
|
||||||
|
<div id="calendario" style="order: 1" class="columna">
|
||||||
|
<!-- Calendario del mes actual -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="order: 2" class="columna">
|
||||||
|
<h3>El tiempo en Madrid</h3>
|
||||||
|
<table style="width: 100%;">
|
||||||
|
<tr>
|
||||||
|
<td>Los datos del tiempo se mostrarán aquí.</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<br />
|
||||||
|
<a class="boton" href="../weather/">Histórico del tiempo</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="cumpleanos">
|
||||||
|
<p>Cargando cumpleaños...</p>
|
||||||
|
</div>
|
||||||
|
<div id="dia-internacional"></div>
|
||||||
|
<div id="santos-hoy"></div>
|
||||||
|
<div id="santos-proximos"></div>
|
||||||
|
<div id="boe"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<p>Diario generado con Spring Boot y JavaScript.</p>
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="es" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Iniciar sesión</title>
|
||||||
|
<link rel="stylesheet" href="/css/style.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="titulo">
|
||||||
|
<h1>Iniciar sesión</h1>
|
||||||
|
</div>
|
||||||
|
<div class="cuerpo">
|
||||||
|
<div class="formulario">
|
||||||
|
<div th:if="${message}" class="alert success" th:text="${message}"></div>
|
||||||
|
<div th:if="${error}" class="alert error" th:text="${error}"></div>
|
||||||
|
<form method="post" action="/login">
|
||||||
|
<label for="username">Usuario</label>
|
||||||
|
<input type="text" id="username" name="username" required />
|
||||||
|
|
||||||
|
<label for="password">Contraseña</label>
|
||||||
|
<input type="password" id="password" name="password" required />
|
||||||
|
|
||||||
|
<button type="submit">Entrar</button>
|
||||||
|
</form>
|
||||||
|
<p>¿No tienes cuenta? <a href="/register">Regístrate aquí</a></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="es" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Registro</title>
|
||||||
|
<link rel="stylesheet" href="/css/style.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="titulo">
|
||||||
|
<h1>Registro de usuario</h1>
|
||||||
|
</div>
|
||||||
|
<div class="cuerpo">
|
||||||
|
<div class="formulario">
|
||||||
|
<div th:if="${error}" class="alert error" th:text="${error}"></div>
|
||||||
|
<form method="post" action="/register">
|
||||||
|
<label for="username">Usuario</label>
|
||||||
|
<input type="text" id="username" name="username" th:value="${usuario.username}" required />
|
||||||
|
|
||||||
|
<label for="password">Contraseña</label>
|
||||||
|
<input type="password" id="password" name="password" required />
|
||||||
|
|
||||||
|
<button type="submit">Crear cuenta</button>
|
||||||
|
</form>
|
||||||
|
<p>¿Ya tienes cuenta? <a href="/login">Inicia sesión</a></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
package es.tatvil.crminmobiliario;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
class CrminmobiliarioApplicationTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void contextLoads() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
|
||||||
|
spring.datasource.driver-class-name=org.h2.Driver
|
||||||
|
spring.datasource.username=sa
|
||||||
|
spring.datasource.password=
|
||||||
|
spring.jpa.hibernate.ddl-auto=create-drop
|
||||||
|
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
|
||||||
|
spring.sql.init.mode=embedded
|
||||||
Loading…
Reference in New Issue